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 class
SVD.Method
-
Field Summary
Fields Modifier and Type Field Description static SVD.Method
DEFAULT_METHOD
The 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 DiagonalMatrix
D()
Get the D matrix as in SVD decomposition.double[]
getSingularValues()
Get the normalized, hence positive, singular values.Matrix
U()
Get the U matrix as in SVD decomposition.Matrix
Ut()
Get the transpose of U, i.e.,U().t()
.Matrix
V()
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
-false
if 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
-false
if 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
-false
if 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:SVDDecomposition
Get the normalized, hence positive, singular values. They may differ from the values in D if this computation turns off normalization.- Specified by:
getSingularValues
in interfaceSVDDecomposition
- Returns:
- the singular values
-
D
public DiagonalMatrix D()
Description copied from interface:SVDDecomposition
Get the D matrix as in SVD decomposition.- Specified by:
D
in interfaceSVDDecomposition
- Returns:
- D
-
U
public Matrix U()
Description copied from interface:SVDDecomposition
Get the U matrix as in SVD decomposition.- Specified by:
U
in interfaceSVDDecomposition
- Returns:
- U
-
Ut
public Matrix Ut()
Description copied from interface:SVDDecomposition
Get the transpose of U, i.e.,U().t()
.- Specified by:
Ut
in interfaceSVDDecomposition
- Returns:
U().t()
-
V
public Matrix V()
Description copied from interface:SVDDecomposition
Get the V matrix as in SVD decomposition.- Specified by:
V
in interfaceSVDDecomposition
- Returns:
- V
-
-