Package no.uib.cipr.matrix
Class SVD
- java.lang.Object
-
- no.uib.cipr.matrix.SVD
-
public class SVD extends java.lang.ObjectComputes singular value decompositions
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SVDfactor(DenseMatrix A)Computes an SVDstatic SVDfactorize(Matrix A)Convenience method for computing a full SVDdouble[]getS()Returns the singular values (stored in descending order)DenseMatrixgetU()Returns the left singular vectors, column-wise.DenseMatrixgetVt()Returns the right singular vectors, row-wise.booleanhasSingularVectors()True if singular vectors are stored
-
-
-
Constructor Detail
-
SVD
public SVD(int m, int n)Creates an empty SVD which will compute all singular values and vectors- Parameters:
m- Number of rowsn- Number of columns
-
SVD
public SVD(int m, int n, boolean vectors)Creates an empty SVD- Parameters:
m- Number of rowsn- Number of columnsvectors- True to compute the singular vectors, false for just the singular values
-
-
Method Detail
-
factorize
public static SVD factorize(Matrix A) throws NotConvergedException
Convenience method for computing a full SVD- Parameters:
A- Matrix to decompose, not modified- Returns:
- Newly allocated factorization
- Throws:
NotConvergedException
-
factor
public SVD factor(DenseMatrix A) throws NotConvergedException
Computes an SVD- Parameters:
A- Matrix to decompose. Size must conform, and it will be overwritten on return. Pass a copy to avoid this- Returns:
- The current decomposition
- Throws:
NotConvergedException
-
hasSingularVectors
public boolean hasSingularVectors()
True if singular vectors are stored
-
getU
public DenseMatrix getU()
Returns the left singular vectors, column-wise. Not available for partial decompositions- Returns:
- Matrix of size m*m
-
getVt
public DenseMatrix getVt()
Returns the right singular vectors, row-wise. Not available for partial decompositions- Returns:
- Matrix of size n*n
-
getS
public double[] getS()
Returns the singular values (stored in descending order)- Returns:
- Array of size min(m,n)
-
-