svdcp(x,H,r)
The second solution is obtained from the same criterion, but after replacing each xi by xi-xi*vi[,1]*vi[,1]'. And so on for the successive solutions 1,2,...,r . The biggest number of solutions may be r=inf(p,qi), when the xi's are supposed with full rank; then rmax=min([min(H),p]).
x<-matrix(runif(200),10,20)
s<-svdcp(x,c(5,5,10),1)
ss<-svd(x);ss$d[1]^2
sum(s$s2)
Run the code above in your browser using DataLab