public class DecompositionSVD
extends java.lang.Object
implements java.io.Serializable
For an m-by-n matrix A, the singular value decomposition is an m-by-(m or n) orthogonal matrix U, a (m or n)-by-n diagonal matrix S, and an n-by-n orthogonal matrix V so that A = U*S*V'.
The singular values, sigma[k] = S[k][k], are ordered so that sigma[0] >= sigma[1] >= ... >= sigma[n-1].
The singular value decompostion always exists, so the constructor will never fail. The matrix condition number and the effective numerical rank can be computed from this decomposition.
This class is mainly based on SingularValueDecomposition class in Jama in which
SVD sometimes fails on cases m < n. The bug has been fixed by Ron Boisvert
Constructor and Description |
---|
DecompositionSVD(SimpleMatrix Arg)
Old Constructor
Construct the singular value decomposition Structure to access U, S and V. |
DecompositionSVD(SimpleMatrix Arg,
boolean thin,
boolean wantu,
boolean wantv)
Construct the singular value decomposition, i.e.
|
Modifier and Type | Method and Description |
---|---|
double |
cond()
Two norm condition number
|
SimpleMatrix |
getreciprocalS()
Return the diagonal matrix of the reciprocals of the singular values
|
SimpleMatrix |
getS()
Return the diagonal matrix of singular values
|
double[] |
getSingularValues()
Return the one-dimensional array of singular values
|
SimpleMatrix |
getU()
Return the left singular vectors
|
SimpleMatrix |
getV()
Return the right singular vectors
|
SimpleMatrix |
inverse(boolean omit)
Return the Moore-Penrose (generalized) inverse
Slightly modified version of Kim van der Linde's code
|
double |
norm2()
Two norm
|
int |
rank()
Effective numerical matrix rank
|
public DecompositionSVD(SimpleMatrix Arg)
Arg
- Rectangular matrixpublic DecompositionSVD(SimpleMatrix Arg, boolean thin, boolean wantu, boolean wantv)
Arg
- Rectangular matrixthin
- If true U is economy sizedwantu
- If true generate the U matrixwantv
- If true generate the V matrixpublic SimpleMatrix getU()
public SimpleMatrix getV()
public double[] getSingularValues()
public SimpleMatrix getS()
public SimpleMatrix getreciprocalS()
public SimpleMatrix inverse(boolean omit)
omit
- if true tolerance based omitting of negligible singular valuespublic double norm2()
public double cond()
public int rank()