org.ejml.ops
Class SingularOps

java.lang.Object
  extended by org.ejml.ops.SingularOps

public class SingularOps
extends Object

Operations related to singular value decomposition.

Author:
Peter Abeles

Constructor Summary
SingularOps()
           
 
Method Summary
static void checkSvdMatrixSize(DenseMatrix64F U, boolean tranU, DenseMatrix64F W, DenseMatrix64F V, boolean tranV)
          Checks to see if all the provided matrices are the expected size for an SVD.
static void descendingOrder(DenseMatrix64F U, boolean tranU, DenseMatrix64F W, DenseMatrix64F V, boolean tranV)
           Adjusts the matrices so that the singular values are in descending order.
static void descendingOrder(DenseMatrix64F U, boolean tranU, double[] singularValues, int numSingularValues, DenseMatrix64F V, boolean tranV)
           Similar to descendingOrder(org.ejml.data.DenseMatrix64F, boolean, org.ejml.data.DenseMatrix64F, org.ejml.data.DenseMatrix64F, boolean) but takes in an array of singular values instead.
static int nullity(SingularValueDecomposition svd, double threshold)
          Extracts the nullity of a matrix using a preexisting decomposition.
static DenseMatrix64F nullSpace(SingularValueDecomposition<DenseMatrix64F> svd, DenseMatrix64F v)
           Computes the null space from the provided singular value.
static int rank(SingularValueDecomposition svd, double threshold)
          Extracts the rank of a matrix using a preexisting decomposition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingularOps

public SingularOps()
Method Detail

descendingOrder

public static void descendingOrder(DenseMatrix64F U,
                                   boolean tranU,
                                   DenseMatrix64F W,
                                   DenseMatrix64F V,
                                   boolean tranV)

Adjusts the matrices so that the singular values are in descending order.

In most implementations of SVD the singular values are automatically arranged in in descending order. In EJML this is not the case since it is often not needed and some computations can be saved by not doing that.

Parameters:
U - Matrix. Modified.
tranU - is U transposed or not.
W - Diagonal matrix with singular values. Modified.
V - Matrix. Modified.
tranV - is V transposed or not.

descendingOrder

public static void descendingOrder(DenseMatrix64F U,
                                   boolean tranU,
                                   double[] singularValues,
                                   int numSingularValues,
                                   DenseMatrix64F V,
                                   boolean tranV)

Similar to descendingOrder(org.ejml.data.DenseMatrix64F, boolean, org.ejml.data.DenseMatrix64F, org.ejml.data.DenseMatrix64F, boolean) but takes in an array of singular values instead.

Parameters:
U - Matrix. Modified.
tranU - is U transposed or not.
singularValues - Array of singular values. Modified.
numSingularValues - Number of elements in singularValues array
V - Matrix. Modified.
tranV - is V transposed or not.

checkSvdMatrixSize

public static void checkSvdMatrixSize(DenseMatrix64F U,
                                      boolean tranU,
                                      DenseMatrix64F W,
                                      DenseMatrix64F V,
                                      boolean tranV)
Checks to see if all the provided matrices are the expected size for an SVD. If an error is encounted then an exception is thrown. This automatically handles compact and non-compact formats


nullSpace

public static DenseMatrix64F nullSpace(SingularValueDecomposition<DenseMatrix64F> svd,
                                       DenseMatrix64F v)

Computes the null space from the provided singular value. The null space is found by finding the row in V associated with the smallest singular value and it is assumed that there is only one singular value close to zero.

No sanity check is done to ensure that the smallest singular value is sufficiently small. Depending on the matrix's dimension a non-compact SVD might be required.

Parameters:
svd - A precomputed decomposition. Not modified.
v - Where the null space is written to. If null then a new matrix is declared. Modified.
Returns:
The null space.

rank

public static int rank(SingularValueDecomposition svd,
                       double threshold)
Extracts the rank of a matrix using a preexisting decomposition.

Parameters:
svd - A precomputed decomposition. Not modified.
threshold - Tolerance used to determine of a singular value is singular.
Returns:
The rank of the decomposed matrix.

nullity

public static int nullity(SingularValueDecomposition svd,
                          double threshold)
Extracts the nullity of a matrix using a preexisting decomposition.

Parameters:
svd - A precomputed decomposition. Not modified.
threshold - Tolerance used to determine of a singular value is singular.
Returns:
The nullity of the decomposed matrix.


Copyright © 2012. All Rights Reserved.