public class SingularValueDecomposition extends Object
For an m×n matrix A with m ≥ n, the singular value decomposition is an m×n orthogonal matrix U, an n×n diagonal matrix S, and an n×n orthogonal matrix V so that A = U⋅S⋅V*.
The singular values, σ[k] = S[k][k], are ordered so that σ[0] ≥ σ[1] ≥ ... ≥ σ[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 a slight modification of the Java class by the JAMA Java Matrix Package by NIST, see http://math.nist.gov/javanumerics/jama/Constructor and Description |
---|
SingularValueDecomposition(Matrix A)
Construct the singular value decomposition Structure to access U, S and V.
|
Modifier and Type | Method and Description |
---|---|
double |
cond()
Two norm condition number defined as the ratio max(S)/min(S) of the
maximum and the minimum singular value of this matrix.
|
Matrix |
getS()
Returns the diagonal matrix S of singular values
|
double[] |
getSingularValues()
Return the one-dimensional array of singular values
|
Matrix |
getU()
Returns the left singular vectors U
|
Matrix |
getV()
Returns the right singular vectors V
|
double |
norm2()
Returns the two norm of this matrix.
|
int |
rank()
Effective numerical matrix rank
|
public SingularValueDecomposition(Matrix A)
A
- a rectangular matrix with numbers of rows ≥ numbers of columnsIllegalArgumentException
- if number of rows < number of columnspublic Matrix getU()
public Matrix getV()
public double[] getSingularValues()
public Matrix getS()
public double norm2()
||A||2 = max||x||=1 ||Ax||
where ||x|| is the usual Euclidean norm for vectors. In fact, ||A||2 is the maximum singular value of A.public double cond()
public int rank()