public class SingularValueDecomposition extends Object
For an m-by-n matrix A with m ≥ n, the singular value decomposition is an m-by-n orthogonal matrix U, an n-by-n diagonal matrix Σ, and an n-by-n orthogonal matrix V so that A = U*Σ*V'.
For m < n, only the first m columns of V are computed and Σ is m-by-m.
The singular values, σk = Σkk, are ordered so that σ0 ≥ σ1 ≥ ... ≥ σn-1.
The singular value decompostion 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.
| Modifier and Type | Method and Description |
|---|---|
double |
condition()
Returns the L2 norm condition number, which is max(S) / min(S).
|
static SingularValueDecomposition |
decompose(double[][] A)
Returns the singular value decomposition.
|
static SingularValueDecomposition |
decompose(IMatrix A,
int k)
Find k largest approximate singular triples of a matrix by the
Lanczos algorithm.
|
static SingularValueDecomposition |
decompose(IMatrix A,
int k,
double kappa)
Find k largest approximate singular triples of a matrix by the
Lanczos algorithm.
|
double[][] |
getS()
Returns the diagonal matrix of singular values
|
double[] |
getSingularValues()
Returns the one-dimensional array of singular values, ordered by
from largest to smallest.
|
double[][] |
getU()
Returns the left singular vectors
|
double[][] |
getV()
Returns the right singular vectors
|
double |
norm()
Returns the L2 matrix norm.
|
int |
nullity()
Returns the dimension of null space.
|
double[][] |
nullspace()
Returns a matrix of which columns give an orthonormal basis for the null space.
|
double[][] |
range()
Returns a matrix of which columns give an orthonormal basis for the range space.
|
int |
rank()
Returns the effective numerical matrix rank.
|
void |
solve(double[][] B,
double[][] X)
Solve A * X = B using the pseudoinverse of A as obtained by SVD.
|
void |
solve(double[] b,
double[] x)
Solve A * x = b using the pseudoinverse of A as obtained by SVD.
|
public double[][] getU()
public double[][] getV()
public double[] getSingularValues()
public double[][] getS()
public double norm()
public int rank()
public int nullity()
public double condition()
public double[][] range()
public double[][] nullspace()
public void solve(double[] b,
double[] x)
public void solve(double[][] B,
double[][] X)
public static SingularValueDecomposition decompose(IMatrix A, int k)
A - the matrix supporting matrix vector multiplication operation.k - the number of singular triples we wish to compute for the input matrix.
This number cannot exceed the size of A.public static SingularValueDecomposition decompose(IMatrix A, int k, double kappa)
A - the matrix supporting matrix vector multiplication operation.k - the number of singular triples we wish to compute for the input matrix.
This number cannot exceed the size of A.kappa - relative accuracy of ritz values acceptable as singular values.public static SingularValueDecomposition decompose(double[][] A)
A - rectangular matrix. Row number should be equal to or larger
than column number for current implementation.Copyright © 2015. All rights reserved.