# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.algebra.linear.matrix.doubles.factorization.svd

## Class SVD

• java.lang.Object
• com.numericalmethod.suanshu.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.
Wikipedia: Singular value decomposition
• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
static class  SVD.Method
• ### Field Summary

Fields
Modifier and Type Field and Description
static SVD.Method DEFAULT_METHOD
The default algorithm for computing SVD.
• ### Constructor Summary

Constructors
Constructor and 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.
• ### 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 matrix
doUV - 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 matrix
doUV - false if to compute only the singular values but not U and V
epsilon - 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 matrix
doUV - false if to compute only the singular values but not U and V
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
method - 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 interface SVDDecomposition
Returns:
the singular values
• #### U

public Matrix U()
Description copied from interface: SVDDecomposition
Get the U matrix as in SVD decomposition.
Specified by:
U in interface SVDDecomposition
Returns:
U
• #### Ut

public Matrix Ut()
Description copied from interface: SVDDecomposition
Get the transpose of U, i.e., U().t().
Specified by:
Ut in interface SVDDecomposition
Returns:
U().t()
• #### V

public Matrix V()
Description copied from interface: SVDDecomposition
Get the V matrix as in SVD decomposition.
Specified by:
V in interface SVDDecomposition
Returns:
V