public class SingularValueDecomposition extends Object implements Decomposition
The Singular Value Decomposition of matrix A is a set of three matrices: U, Σ and V such that A = U × Σ × VT. Let A be a m × n matrix, then U is a m × p orthogonal matrix, Σ is a p × p diagonal matrix with positive or null elements, V is a p × n orthogonal matrix (hence VT is also orthogonal) where p=min(m,n).
This class is similar to the class with similar name from the JAMA library, with the following changes:
norm2
method which has been renamed as getNorm
,cond
method which has been renamed as getConditionNumber
,rank
method which has been renamed as getRank
,getUT
method has been added,getVT
method has been added,getSolver
method has been added,getCovariance
method has been added.This class is up-to-date with commons-math 3.6.1.
Constructor and Description |
---|
SingularValueDecomposition()
Simple constructor.
|
SingularValueDecomposition(RealMatrix matrix)
Simple constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
checkDecompositionPerformed()
Check decomposition has been performed.
|
void |
decompose(RealMatrix matrix)
Run the decomposition process on the input matrix.
|
double |
getConditionNumber()
Return the condition number of the matrix.
|
RealMatrix |
getCovariance(double minSingularValue)
Returns the n × n covariance matrix.
|
double |
getInverseConditionNumber()
Computes the inverse of the condition number.
|
double |
getNorm()
Returns the L2 norm of the matrix.
|
int |
getRank()
Return the effective numerical matrix rank.
|
RealMatrix |
getS()
Returns the diagonal matrix Σ of the decomposition.
|
double[] |
getSingularValues()
Returns the diagonal elements of the matrix Σ of the decomposition.
|
DecompositionSolver |
getSolver()
Gets a solver for finding the A × X = B solution in exact linear sense.
|
RealMatrix |
getU()
Returns the matrix U of the decomposition.
|
RealMatrix |
getUT()
Returns the transpose of the matrix U of the decomposition.
|
RealMatrix |
getV()
Returns the matrix V of the decomposition.
|
RealMatrix |
getVT()
Returns the transpose of the matrix V of the decomposition.
|
public SingularValueDecomposition()
Once the decomposition object is built, the method decompose(RealMatrix)
needs to be called on the expected matrix to run the decomposition process before calling
any others methods. Otherwise the data won't be initialize.
public SingularValueDecomposition(RealMatrix matrix)
The decomposition is directly computed on the input matrix. There is no need to run the method
decompose(RealMatrix)
separately.
matrix
- The matrix to decompose.public void decompose(RealMatrix matrix)
Calculates the compact Singular Value Decomposition of the given matrix.
decompose
in interface Decomposition
matrix
- The matrix to decompose.public RealMatrix getU()
U is an orthogonal matrix, i.e. its transpose is also its inverse.
getUT()
public RealMatrix getUT()
U is an orthogonal matrix, i.e. its transpose is also its inverse.
getU()
public RealMatrix getS()
Σ is a diagonal matrix. The singular values are provided in non-increasing order, for compatibility with Jama.
public double[] getSingularValues()
The singular values are provided in non-increasing order, for compatibility with Jama.
public RealMatrix getV()
V is an orthogonal matrix, i.e. its transpose is also its inverse.
getVT()
public RealMatrix getVT()
V is an orthogonal matrix, i.e. its transpose is also its inverse.
getV()
public RealMatrix getCovariance(double minSingularValue)
The covariance matrix is V × J × VT where J is the diagonal matrix of the inverse of the squares of the singular values.
minSingularValue
- value below which singular values are ignored
(a 0 or negative value implies all singular value will be used)IllegalArgumentException
- if minSingularValue is larger than
the largest singular value, meaning all singular values are ignoredpublic double getNorm()
The L2 norm is max(|A × u|2 / |u|2), where |.|2 denotes the vectorial 2-norm (i.e. the traditional euclidian norm).
public double getConditionNumber()
public double getInverseConditionNumber()
condition
number
will become undefined.public int getRank()
The effective numerical rank is the number of non-negligible singular values. The threshold used to identify non-negligible terms is max(m,n) × ulp(s1) where ulp(s1) is the least significant bit of the largest singular value.
public DecompositionSolver getSolver()
getSolver
in interface Decomposition
public void checkDecompositionPerformed()
ArithmeticException
- thrown if decomposition has not been performed yetCopyright © 2020 CNES. All rights reserved.