- #U,S,V = SVD of (t(Xr)Xr)^{-1} * t(Xr) * Yr
- s = svd( MASS::ginv(crossprod(matricize(X[Z_indice,]))) %*%
- crossprod(matricize(X[Z_indice,]),matricize(Y[Z_indice,])) )
- S = s$d
- #Set m-rank(r) singular values to zero, and recompose
- #best rank(r) approximation of the initial product
- if(rank[r] < length(S))
- S[(rank[r]+1):length(S)] = 0
- phi[,,r] = s$u %*% diag(S) %*% t(s$v) %*% Rho[,,r]
+ # U,S,V = SVD of (t(Xr)Xr)^{-1} * t(Xr) * Yr
+ s <- svd(MASS::ginv(crossprod(matricize(X[Z_indice, ]))) %*%
+ crossprod(matricize(X[Z_indice, ]), matricize(Y[Z_indice, ])))
+ S <- s$d
+ # Set m-rank(r) singular values to zero, and recompose best rank(r) approximation
+ # of the initial product
+ if (rank[r] < length(S))
+ S[(rank[r] + 1):length(S)] <- 0
+ phi[, , r] <- s$u %*% diag(S) %*% t(s$v) %*% Rho[, , r]