public class SingularValueDecomposition extends Object implements Cloneable, Serializable
Constructor and Description |
---|
SingularValueDecomposition(Matrix A)
Creates a new SVD of the matrix
A such that A = U Σ VT. |
SingularValueDecomposition(Matrix A,
int maxIterations)
Creates a new SVD of the matrix
A such that A = U Σ VT. |
SingularValueDecomposition(Matrix U,
Matrix V,
double[] s)
Sets the values for a SVD explicitly.
|
Modifier and Type | Method and Description |
---|---|
double |
absDet()
Computes the absolute value of the determinant for the full matrix.
|
SingularValueDecomposition |
clone() |
double |
getCondition()
Returns the condition number of the matrix.
|
double[] |
getInverseSingularValues()
Returns an array containing the inverse singular values.
|
double[] |
getInverseSingularValues(double tol)
Returns an array containing the inverse singular values.
|
double |
getNorm2()
Returns the 2 norm of the matrix, which is the maximal singular value.
|
double |
getPseudoDet()
Computes the pseudo determinant of the matrix, which corresponds to absolute value of
the determinant of the full rank square sub matrix that contains all non zero singular values.
|
double |
getPseudoDet(double tol)
Computes the pseudo determinant of the matrix, which corresponds to absolute value of
the determinant of the full rank square sub matrix that contains all non singular values > tol.
|
Matrix |
getPseudoInverse()
Returns the Moore–Penrose pseudo inverse of the matrix.
|
Matrix |
getPseudoInverse(double tol)
Returns the Moore–Penrose pseudo inverse of the matrix.
|
int |
getRank()
Returns the numerical rank of the matrix.
|
int |
getRank(double tol)
Returns the numerical rank of the matrix.
|
Matrix |
getS()
Returns the diagonal matrix S such that the SVD product results in the original matrix.
|
double[] |
getSingularValues()
Returns a copy of the sorted array of the singular values, include the near zero ones.
|
Matrix |
getU()
Returns the backing matrix U of the SVD.
|
Matrix |
getV()
Returns the backing matrix V of the SVD.
|
boolean |
isFullRank()
Indicates whether or not the input matrix was of full rank, full
rank matrices are more numerically stable.
|
Matrix |
solve(Matrix B)
Solves the linear system of equations for A x = B by using the equation
x = A-1 B = V S-1 UT B
When A is not full rank, this results in a more numerically stable approximation that minimizes the least squares error. |
Matrix |
solve(Matrix b,
ExecutorService threadpool)
Solves the linear system of equations for A x = B by using the equation
x = A-1 B = V S-1 UT B
When A is not full rank, this results in a more numerically stable approximation that minimizes the least squares error. |
Vec |
solve(Vec b)
Solves the linear system of equations for A x = b by using the equation
x = A-1 b = V S-1 UT b
When A is not full rank, this results in a more numerically stable approximation that minimizes the least squares error. |
public SingularValueDecomposition(Matrix A)
A
such that A = U Σ VT. The matrix
A
will be modified and used as temp space when computing the SVD.A
- the matrix to create the SVD ofpublic SingularValueDecomposition(Matrix A, int maxIterations)
A
such that A = U Σ VT. The matrix
A
will be modified and used as temp space when computing the SVD.A
- the matrix to create the SVD ofmaxIterations
- the maximum number of iterations to perform per singular value till convergence.public SingularValueDecomposition(Matrix U, Matrix V, double[] s)
U
- the U matrix of an SVDV
- the V matrix of an SVDs
- the singular sorted by magnitude of an SVDpublic Matrix getU()
public Matrix getV()
public double[] getSingularValues()
public Matrix getS()
public double getNorm2()
public double getCondition()
Double.POSITIVE_INFINITY
.public int getRank()
public boolean isFullRank()
public int getRank(double tol)
tol
- the cut of for singular valuespublic double[] getInverseSingularValues()
public double[] getInverseSingularValues(double tol)
tol
- the cut of for singular valuespublic Matrix getPseudoInverse()
public Matrix getPseudoInverse(double tol)
tol
- the tolerance for singular values to ignorepublic double getPseudoDet()
public double getPseudoDet(double tol)
tol
- the cut of for singular valuespublic double absDet()
abs
(determinant)public Vec solve(Vec b)
x = A-1 b = V S-1 UT b
b
- the vector to solve forpublic Matrix solve(Matrix B)
x = A-1 B = V S-1 UT B
B
- the matrix to solve forpublic Matrix solve(Matrix b, ExecutorService threadpool)
x = A-1 B = V S-1 UT B
b
- the matrix to solve forthreadpool
- public SingularValueDecomposition clone()
Copyright © 2017. All rights reserved.