Find singular values and vectors
s = svds(A)
s = svds(A,k)
s = svds(A,k,sigma)
s = svds(A,k,'L')
s = svds(A,k,sigma,options)
[U,S,V] = svds(A,...)
[U,S,V,flag] = svds(A,...)
s = svds(A) computes the six largest singular values and associated singular vectors of matrix A. If A is m-by-n, svds(A) manipulates eigenvalues and vectors returned by eigs(B), where B = [sparse(m,m) A; A' sparse(n,n)], to find a few singular values and vectors of A. The positive eigenvalues of the symmetric matrix B are the same as the singular values of A.
s = svds(A,k,sigma) computes the k singular values closest to the scalar shift sigma. For example, s = svds(A,k,0) computes the k smallest singular values and associated singular vectors.
s = svds(A,k,sigma,options) sets some parameters (see eigs):
Option Structure Fields and Descriptions
Convergence tolerance: norm(AV-US,1)<=tol*norm(A,1)
Maximum number of iterations
Number of values displayed each iteration
svds checks the accuracy of the computed singular vectors. If the vectors they are not accurate enough returns fewer singular values than requested. To obtain the requested number of singular values, try decreasing the error tolerance in the options structure.
U is m-by-k with orthonormal columns
S is k-by-k diagonal
V is n-by-k with orthonormal columns
U*S*V' is the closest rank k approximation to A
west0479 is a real 479-by-479 sparse matrix. svd calculates all 479 singular values. svds picks out the largest and smallest singular values.
load west0479 s = svd(full(west0479)) sl = svds(west0479,4) ss = svds(west0479,6,0)
These plots show some of the singular values of west0479 as computed by svd and svds.
The largest singular value of west0479 can be computed a few different ways:
svds(west0479,1) = 3.189517598808622e+05 max(svd(full(west0479))) = 3.18951759880862e+05 norm(full(west0479)) = 3.189517598808623e+05
normest(west0479) = 3.189385666549991e+05
svds(A,k) uses eigs to find the k largest magnitude eigenvalues and corresponding eigenvectors of B = [0 A; A' 0].
svds(A,k,0) uses eigs to find the 2k smallest magnitude eigenvalues and corresponding eigenvectors of B = [0 A; A' 0], and then selects the k positive eigenvalues and their eigenvectors.