Class SingularValueDecompositionImpl
- All Implemented Interfaces:
SingularValueDecomposition
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).
- Since:
- 2.0
-
Constructor Summary
ConstructorsConstructorDescriptionCalculates the compact Singular Value Decomposition of the given matrix. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturn the condition number of the matrix.getCovariance(double minSingularValue) Returns the n × n covariance matrix.doublegetNorm()Returns the L2 norm of the matrix.intgetRank()Return the effective numerical matrix rank.getS()Returns the diagonal matrix Σ of the decomposition.double[]Returns the diagonal elements of the matrix Σ of the decomposition.Get a solver for finding the A × X = B solution in least square sense.getU()Returns the matrix U of the decomposition.getUT()Returns the transpose of the matrix U of the decomposition.getV()Returns the matrix V of the decomposition.getVT()Returns the transpose of the matrix V of the decomposition.
-
Constructor Details
-
SingularValueDecompositionImpl
Calculates the compact Singular Value Decomposition of the given matrix.- Parameters:
matrix- The matrix to decompose.- Throws:
InvalidMatrixException- (wrapping aConvergenceExceptionif algorithm fails to converge
-
-
Method Details
-
getU
Returns the matrix U of the decomposition.U is an orthogonal matrix, i.e. its transpose is also its inverse.
- Specified by:
getUin interfaceSingularValueDecomposition- Returns:
- the U matrix
- Throws:
InvalidMatrixException- See Also:
-
getUT
Returns the transpose of the matrix U of the decomposition.U is an orthogonal matrix, i.e. its transpose is also its inverse.
- Specified by:
getUTin interfaceSingularValueDecomposition- Returns:
- the U matrix (or null if decomposed matrix is singular)
- Throws:
InvalidMatrixException- See Also:
-
getS
Returns the diagonal matrix Σ of the decomposition.Σ is a diagonal matrix. The singular values are provided in non-increasing order, for compatibility with Jama.
- Specified by:
getSin interfaceSingularValueDecomposition- Returns:
- the Σ matrix
- Throws:
InvalidMatrixException
-
getSingularValues
Returns the diagonal elements of the matrix Σ of the decomposition.The singular values are provided in non-increasing order, for compatibility with Jama.
- Specified by:
getSingularValuesin interfaceSingularValueDecomposition- Returns:
- the diagonal elements of the Σ matrix
- Throws:
InvalidMatrixException
-
getV
Returns the matrix V of the decomposition.V is an orthogonal matrix, i.e. its transpose is also its inverse.
- Specified by:
getVin interfaceSingularValueDecomposition- Returns:
- the V matrix (or null if decomposed matrix is singular)
- Throws:
InvalidMatrixException- See Also:
-
getVT
Returns the transpose of the matrix V of the decomposition.V is an orthogonal matrix, i.e. its transpose is also its inverse.
- Specified by:
getVTin interfaceSingularValueDecomposition- Returns:
- the V matrix (or null if decomposed matrix is singular)
- Throws:
InvalidMatrixException- See Also:
-
getCovariance
Returns the n × n covariance matrix.The covariance matrix is V × J × VT where J is the diagonal matrix of the inverse of the squares of the singular values.
- Specified by:
getCovariancein interfaceSingularValueDecomposition- Parameters:
minSingularValue- value below which singular values are ignored (a 0 or negative value implies all singular value will be used)- Returns:
- covariance matrix
-
getNorm
Returns the L2 norm of the matrix.The L2 norm is max(|A × u|2 / |u|2), where |.|2 denotes the vectorial 2-norm (i.e. the traditional euclidian norm).
- Specified by:
getNormin interfaceSingularValueDecomposition- Returns:
- norm
- Throws:
InvalidMatrixException
-
getConditionNumber
Return the condition number of the matrix.- Specified by:
getConditionNumberin interfaceSingularValueDecomposition- Returns:
- condition number of the matrix
- Throws:
InvalidMatrixException
-
getRank
Return the effective numerical matrix rank.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.
- Specified by:
getRankin interfaceSingularValueDecomposition- Returns:
- effective numerical matrix rank
- Throws:
IllegalStateException
-
getSolver
Get a solver for finding the A × X = B solution in least square sense.- Specified by:
getSolverin interfaceSingularValueDecomposition- Returns:
- a solver
-