Class Matrix.SVD
 All Implemented Interfaces:
Serializable
 Enclosing class:
Matrix
For an mbyn matrix A with m >= n
, the singular value decomposition is
an mbyn orthogonal matrix U, an nbyn diagonal matrix Σ, and
an nbyn orthogonal matrix V so that A = U*Σ*V'.
For m < n
, only the first m columns of V are computed and Σ is mbym.
The singular values, σ_{k} = Σ_{kk}, are ordered so that σ_{0} ≥ σ_{1} ≥ ... ≥ σ_{n1}.
The singular value decomposition always exists. The matrix condition number and the effective numerical rank can be computed from this decomposition.
SVD is a very powerful technique for dealing with sets of equations or matrices that are either singular or else numerically very close to singular. In many cases where Gaussian elimination and LU decomposition fail to give satisfactory results, SVD will diagnose precisely what the problem is. SVD is also the method of choice for solving most linear least squares problems.
Applications which employ the SVD include computing the pseudoinverse, least squares fitting of data, matrix approximation, and determining the rank, range and null space of a matrix. The SVD is also applied extensively to the study of linear inverse problems, and is useful in the analysis of regularization methods such as that of Tikhonov. It is widely used in statistics where it is related to principal component analysis. Yet another usage is latent semantic indexing in natural language text processing.
 See Also:

Field Summary

Constructor Summary

Method Summary
Modifier and TypeMethodDescriptiondouble
Returns the L_{2} norm condition number, which is max(S) / min(S).diag()
Returns the diagonal matrix of singular values.double
norm()
Returns the L_{2} matrix norm that is the largest singular value.int
nullity()
Returns the dimension of null space.Returns the matrix which columns are the orthonormal basis for the null space.pinv()
Returns the pseudo inverse.range()
Returns the matrix which columns are the orthonormal basis for the range space.int
rank()
Returns the effective numerical matrix rank.double[]
solve
(double[] b) Solves the least squares min  B  A*X .

Field Details

m
public final int mThe number of rows of matrix. 
n
public final int nThe number of columns of matrix. 
s
public final double[] sThe singular values in descending order. 
U
The left singular vectors U. 
V
The right singular vectors V.


Constructor Details

SVD
public SVD(int m, int n, double[] s) Constructor. Parameters:
m
 the number of rows of matrix.n
 the number of columns of matrix.s
 the singular values in descending order.

SVD
Constructor. Parameters:
s
 the singular values in descending order.U
 the left singular vectorsV
 the right singular vectors.


Method Details

diag
Returns the diagonal matrix of singular values. Returns:
 the diagonal matrix of singular values.

norm
public double norm()Returns the L_{2} matrix norm that is the largest singular value. Returns:
 L_{2} matrix norm.

rank
public int rank()Returns the effective numerical matrix rank. The number of nonnegligible singular values. Returns:
 the effective numerical matrix rank.

nullity
public int nullity()Returns the dimension of null space. The number of negligible singular values. Returns:
 the dimension of null space.

condition
public double condition()Returns the L_{2} norm condition number, which is max(S) / min(S). A system of equations is considered to be wellconditioned if a small change in the coefficient matrix or a small change on the right hand side results in a small change in the solution vector. Otherwise, it is called illconditioned. Condition number is defined as the product of the norm of A and the norm of A^{1}. If we use the usual L_{2} norm on vectors and the associated matrix norm, then the condition number is the ratio of the largest singular value of matrix A to the smallest. The condition number depends on the underlying norm. However, regardless of the norm, it is always greater or equal to 1. If it is close to one, the matrix is well conditioned. If the condition number is large, then the matrix is said to be illconditioned. A matrix that is not invertible has the condition number equal to infinity. Returns:
 L_{2} norm condition number.

range
Returns the matrix which columns are the orthonormal basis for the range space. Returns null if the rank is zero (if and only if zero matrix). Returns:
 the range space span matrix.

nullspace
Returns the matrix which columns are the orthonormal basis for the null space. Returns null if the matrix is of full rank. Returns:
 the null space span matrix.

pinv
Returns the pseudo inverse. Returns:
 the pseudo inverse.

solve
public double[] solve(double[] b) Solves the least squares min  B  A*X . Parameters:
b
 the right hand side of overdetermined linear system. Returns:
 the solution vector beta that minimizes Y  X*beta.
 Throws:
RuntimeException
 when matrix is rank deficient.
