Search code examples
c++armadillosvdeigenvalue

Sparse svd in Armadillo (C++)


According to, http://arma.sourceforge.net/docs.html#part_c , Armadillo has support for following functions:

eig_sym
eig_gen
eigs_sym
eigs_gen
svd
svd_econ

But there does not seem to be a function like "svds_econ", which operates on "sparse" matrix and returns singular values and vectors.

Is there a way to achieve this functionality in Armadillo?


Solution

  • The sparse SVD can be computed indirectly. For example, first calculate X'*X or X*X', and then pass the resultant matrix to eigs_sym(). Another way is to first construct a sparse matrix like [zeros(m,m) X; X' zeros(n,n)], where m and n indicate the number of rows and columns in X.

    You may also want to scale X by its 1-norm beforehand, to increase stability.