Navigation

Operators and Keywords

Function List:

C++ API

: s = svds (A)
: s = svds (A, k)
: s = svds (A, k, sigma)
: s = svds (A, k, sigma, opts)
: [u, s, v] = svds (…)
: [u, s, v, flag] = svds (…)

Find a few singular values of the matrix A.

The singular values are calculated using

[m, n] = size (A);
s = eigs ([sparse(m, m), A;
                     A', sparse(n, n)])

The eigenvalues returned by eigs correspond to the singular values of A. The number of singular values to calculate is given by k and defaults to 6.

The argument sigma specifies which singular values to find. When sigma is the string 'L', the default, the largest singular values of A are found. Otherwise, sigma must be a real scalar and the singular values closest to sigma are found. As a corollary, sigma = 0 finds the smallest singular values. Note that for relatively small values of sigma, there is a chance that the requested number of singular values will not be found. In that case sigma should be increased.

opts is a structure defining options that svds will pass to eigs. The possible fields of this structure are documented in eigs. By default, svds sets the following three fields:

tol

The required convergence tolerance for the singular values. The default value is 1e-10. eigs is passed tol / sqrt(2).

maxit

The maximum number of iterations. The default is 300.

disp

The level of diagnostic printout (0|1|2). If disp is 0 then diagnostics are disabled. The default value is 0.

If more than one output is requested then svds will return an approximation of the singular value decomposition of A

A_approx = u*s*v'

where A_approx is a matrix of size A but only rank k.

flag returns 0 if the algorithm has succesfully converged, and 1 otherwise. The test for convergence is

norm (A*v - u*s, 1) <= tol * norm (A, 1)

svds is best for finding only a few singular values from a large sparse matrix. Otherwise, svd (full (A)) will likely be more efficient.

See also: svd, eigs.

Package: octave