Class SVD
- java.lang.Object
-
- dev.nm.algebra.linear.matrix.doubles.factorization.svd.SVD
-
- All Implemented Interfaces:
SVDDecomposition
public class SVD extends Object implements SVDDecomposition
SVD decomposition decomposes a matrix A of dimension m x n, where m >= n, such that U' * A * V = D, or U * D * V' = A.- U is orthogonal and has the dimension m x n.
- D is diagonal and has the dimension n x n.
- V is orthogonal and has the dimension n x n.
- See Also:
- Wikipedia: Singular value decomposition
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSVD.Method
-
Field Summary
Fields Modifier and Type Field Description static SVD.MethodDEFAULT_METHODThe default algorithm for computing SVD.
-
Constructor Summary
Constructors Constructor Description SVD(Matrix A, boolean doUV)Runs the SVD decomposition on a matrix.SVD(Matrix A, boolean doUV, double epsilon)Runs the SVD decomposition on a matrix.SVD(Matrix A, boolean doUV, double epsilon, SVD.Method method)Runs the SVD decomposition on a matrix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DiagonalMatrixD()Get the D matrix as in SVD decomposition.double[]getSingularValues()Get the normalized, hence positive, singular values.MatrixU()Get the U matrix as in SVD decomposition.MatrixUt()Get the transpose of U, i.e.,U().t().MatrixV()Get the V matrix as in SVD decomposition.
-
-
-
Field Detail
-
DEFAULT_METHOD
public static final SVD.Method DEFAULT_METHOD
The default algorithm for computing SVD.
-
-
Constructor Detail
-
SVD
public SVD(Matrix A, boolean doUV)
Runs the SVD decomposition on a matrix.- Parameters:
A- a matrixdoUV-falseif to compute only the singular values but not U and V
-
SVD
public SVD(Matrix A, boolean doUV, double epsilon)
Runs the SVD decomposition on a matrix.- Parameters:
A- a matrixdoUV-falseif to compute only the singular values but not U and Vepsilon- a precision parameter: when a number |x| ≤ ε, it is considered 0
-
SVD
public SVD(Matrix A, boolean doUV, double epsilon, SVD.Method method)
Runs the SVD decomposition on a matrix.- Parameters:
A- a matrixdoUV-falseif to compute only the singular values but not U and Vepsilon- a precision parameter: when a number |x| ≤ ε, it is considered 0method- the algorithm for computing the decomposition
-
-
Method Detail
-
getSingularValues
public double[] getSingularValues()
Description copied from interface:SVDDecompositionGet the normalized, hence positive, singular values. They may differ from the values in D if this computation turns off normalization.- Specified by:
getSingularValuesin interfaceSVDDecomposition- Returns:
- the singular values
-
D
public DiagonalMatrix D()
Description copied from interface:SVDDecompositionGet the D matrix as in SVD decomposition.- Specified by:
Din interfaceSVDDecomposition- Returns:
- D
-
U
public Matrix U()
Description copied from interface:SVDDecompositionGet the U matrix as in SVD decomposition.- Specified by:
Uin interfaceSVDDecomposition- Returns:
- U
-
Ut
public Matrix Ut()
Description copied from interface:SVDDecompositionGet the transpose of U, i.e.,U().t().- Specified by:
Utin interfaceSVDDecomposition- Returns:
U().t()
-
V
public Matrix V()
Description copied from interface:SVDDecompositionGet the V matrix as in SVD decomposition.- Specified by:
Vin interfaceSVDDecomposition- Returns:
- V
-
-