我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

svds

Find singular values and vectors

Syntax

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,...)

Description

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) computes the k largest singular values and associated singular vectors of matrix 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,'L') computes the k largest singular values (the default).

s = svds(A,k,sigma,options) sets some parameters (see eigs):

Option Structure Fields and Descriptions

Field name

Parameter

Default

options.tol

Convergence tolerance: norm(AV-US,1)<=tol*norm(A,1)

1e-10

options.maxit

Maximum number of iterations

300

options.disp

Number of values displayed each iteration

0

svds checks the accuracy of the computed singular vectors. If the vectors are not accurate enough, then svds returns fewer singular values than requested. To obtain the requested number of singular values, try decreasing the error tolerance in the options structure.

[U,S,V] = svds(A,...) returns three output arguments, and if A is m-by-n:

  • 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

[U,S,V,flag] = svds(A,...) returns a convergence flag. If eigs converged, then norm(A*V-U*S,1) <= tol*norm(A,1) and flag is 0. If eigs did not converge, then flag is 1.

    Note   svds is best used to find a few singular values of a large, sparse matrix. To find all the singular values of such a matrix, svd(full(A)) will usually perform better than svds(A,min(size(A))).

Examples

expand all

Singular Values of Sparse Matrix

west0479 is a real 479-by-479 sparse matrix. svd calculates all 479 singular values. svds picks out only the largest and smallest singular values.

load west0479
s = svd(full(west0479));
sl = svds(west0479,4);
ss = svds(west0479,6,0);
Warning: NORMEST did not converge for 100 iterations with tolerance 1e-06 

These plots show some of the singular values of west0479 as computed by svd and svds.

subplot(2,1,1)
plot(s(1:4),'ks')
hold on
plot(sl,'k+')
hold off
title('4 largest singular values of west0479')
legend('svd(A)','svds(A,4)')
xlim([0.5 4.5])

subplot(2,1,2)
plot(s(end-5:end),'ks')
hold on
plot(ss,'k+')
hold off
title('6 smallest singular values of west0479')
legend('svd(A)','svds(A,6,0)')
xlim([0.5 6.5])

The largest singular value of west0479 can be computed a few different ways:

svds(west0479,1)
max(svd(full(west0479)))
norm(full(west0479))
ans =

   3.1895e+05


ans =

   3.1895e+05


ans =

   3.1895e+05

Or, to estimate the largest singular value:

normest(west0479)
Warning: NORMEST did not converge for 100 iterations with tolerance 1e-06 

ans =

   3.1854e+05

More About

expand all

Algorithms

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.

See Also

|

Was this topic helpful?