Catalano.Math.Decompositions
Class SingularValueDecomposition
- java.lang.Object
-
- Catalano.Math.Decompositions.SingularValueDecomposition
-
- All Implemented Interfaces:
- java.io.Serializable
public class SingularValueDecomposition extends java.lang.Object implements java.io.SerializableSingular Value Decomposition.For an m-by-n matrix A with m >= n, the singular value decomposition is an m-by-n orthogonal matrix U, an n-by-n diagonal matrix S, and an n-by-n orthogonal matrix V so that A = U*S*V'.
The singular values, sigma[k] = S[k][k], are ordered so that sigma[0] >= sigma[1] >= ... >= sigma[n-1].
The singular value decompostion always exists, so the constructor will never fail. The matrix condition number and the effective numerical rank can be computed from this decomposition.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description SingularValueDecomposition(double[][] matrix)Initializes a new instance of the SingularValueDecomposition class.SingularValueDecomposition(double[][] matrix, boolean wantU, boolean wantV)Initializes a new instance of the SingularValueDecomposition class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublecond()Two norm condition number.double[][]getS()Get Diagonal matrix of singular values.double[]getSingularValues()Return the one-dimensional array of singular valuesdouble[][]getU()Get Left singular vectors.double[][]getV()Get Right singular vectors.double[][]inverse()booleanisWantU()Check if need to compute U.booleanisWantV()Check if need to compute V.doublenorm2()Two norm.intrank()Effective numerical matrix rank.voidsetWantU(boolean wantu)Compute U.voidsetWantV(boolean wantv)Compute V.doublethreshold()
-
-
-
Constructor Detail
-
SingularValueDecomposition
public SingularValueDecomposition(double[][] matrix, boolean wantU, boolean wantV)Initializes a new instance of the SingularValueDecomposition class.- Parameters:
matrix- Matrix.wantU- Compute U.wantV- Compute V.
-
SingularValueDecomposition
public SingularValueDecomposition(double[][] matrix)
Initializes a new instance of the SingularValueDecomposition class.- Parameters:
matrix- The matrix to be decomposed.- Throws:
java.lang.IllegalArgumentException- Matrix does not have any rows or columns.
-
-
Method Detail
-
isWantU
public boolean isWantU()
Check if need to compute U.- Returns:
- True if the U is computed, otherwise false.
-
setWantU
public void setWantU(boolean wantu)
Compute U.- Parameters:
wantu- True if need to compute U, otherwise false.
-
isWantV
public boolean isWantV()
Check if need to compute V.- Returns:
- True if the V is computed, otherwise false.
-
setWantV
public void setWantV(boolean wantv)
Compute V.- Parameters:
wantv- True if need to compute V, otherwise false.
-
getU
public double[][] getU()
Get Left singular vectors.- Returns:
- Left singular vectors.
-
getV
public double[][] getV()
Get Right singular vectors.- Returns:
- Right singular vectors.
-
getSingularValues
public double[] getSingularValues()
Return the one-dimensional array of singular values- Returns:
- diagonal of S.
-
getS
public double[][] getS()
Get Diagonal matrix of singular values.- Returns:
- Diagonal matrix of singular values.
-
norm2
public double norm2()
Two norm. max(S).- Returns:
- Two norm.
-
cond
public double cond()
Two norm condition number. max(S)/min(S)- Returns:
- Two norm condition number.
-
rank
public int rank()
Effective numerical matrix rank.- Returns:
- Number of nonnegligible singular values.
-
threshold
public double threshold()
-
inverse
public double[][] inverse()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG