org.ejml.alg.dense.decomposition.svd
Class SvdImplicitQrDecompose

java.lang.Object
  extended by org.ejml.alg.dense.decomposition.svd.SvdImplicitQrDecompose
All Implemented Interfaces:
DecompositionInterface<DenseMatrix64F>, SingularValueDecomposition<DenseMatrix64F>

public class SvdImplicitQrDecompose
extends Object
implements SingularValueDecomposition<DenseMatrix64F>

Computes the Singular value decomposition of a matrix using the implicit QR algorithm for singular value decomposition. It works by first by transforming the matrix to a bidiagonal A=U*B*VT form, then it implicitly computing the eigenvalues of the BTB matrix, which are the same as the singular values in the original A matrix.

Based off of the description provided in:

David S. Watkins, "Fundamentals of Matrix Computations," Second Edition. Page 404-411

Author:
Peter Abeles

Constructor Summary
SvdImplicitQrDecompose(boolean compact, boolean computeU, boolean computeV)
           
 
Method Summary
 boolean decompose(DenseMatrix64F orig)
          Computes the decomposition of the input matrix.
 double[] getSingularValues()
          Returns the singular values.
 DenseMatrix64F getU(boolean transpose)
           Returns the orthogonal 'U' matrix.
 DenseMatrix64F getV(boolean transpose)
           Returns the orthogonal 'V' matrix.
 DenseMatrix64F getW(DenseMatrix64F W)
          Returns a diagonal matrix with the singular values.
 boolean inputModified()
          Is the input matrix to DecompositionInterface.decompose(org.ejml.data.Matrix64F) is modified during the decomposition process.
 boolean isCompact()
          If true then compact matrices are returned.
 int numberOfSingularValues()
          The number of singular values in the matrix.
 int numCols()
          Number of columns in the decomposed matrix.
 int numRows()
          Number of rows in the decomposed matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SvdImplicitQrDecompose

public SvdImplicitQrDecompose(boolean compact,
                              boolean computeU,
                              boolean computeV)
Method Detail

getSingularValues

public double[] getSingularValues()
Description copied from interface: SingularValueDecomposition
Returns the singular values. This is the diagonal elements of the W matrix in the decomposition. Ordering of singular values is not guaranteed..

Specified by:
getSingularValues in interface SingularValueDecomposition<DenseMatrix64F>
Returns:
Singular values. Note this array can be longer than the number of singular values. Extra elements have no meaning.

numberOfSingularValues

public int numberOfSingularValues()
Description copied from interface: SingularValueDecomposition
The number of singular values in the matrix. This is equal to the length of the smallest side.

Specified by:
numberOfSingularValues in interface SingularValueDecomposition<DenseMatrix64F>
Returns:
Number of singular values in the matrix.

isCompact

public boolean isCompact()
Description copied from interface: SingularValueDecomposition
If true then compact matrices are returned.

Specified by:
isCompact in interface SingularValueDecomposition<DenseMatrix64F>
Returns:
true if results use compact notation.

getU

public DenseMatrix64F getU(boolean transpose)
Description copied from interface: SingularValueDecomposition

Returns the orthogonal 'U' matrix.

Internally the SVD algorithm might compute U transposed or it might not. To avoid an unnecessary double transpose the option is provided to select if the transpose is returned.

Specified by:
getU in interface SingularValueDecomposition<DenseMatrix64F>
Parameters:
transpose - If the returned U is transposed.
Returns:
An orthogonal matrix.

getV

public DenseMatrix64F getV(boolean transpose)
Description copied from interface: SingularValueDecomposition

Returns the orthogonal 'V' matrix.

Internally the SVD algorithm might compute V transposed or it might not. To avoid an unnecessary double transpose the option is provided to select if the transpose is returned.

Specified by:
getV in interface SingularValueDecomposition<DenseMatrix64F>
Parameters:
transpose - If the returned V is transposed.
Returns:
An orthogonal matrix.

getW

public DenseMatrix64F getW(DenseMatrix64F W)
Description copied from interface: SingularValueDecomposition
Returns a diagonal matrix with the singular values. Order of the singular values is not guaranteed.

Specified by:
getW in interface SingularValueDecomposition<DenseMatrix64F>
Parameters:
W - If not null then the W matrix is written to it. Modified.
Returns:
Diagonal matrix with singular values along the diagonal.

decompose

public boolean decompose(DenseMatrix64F orig)
Description copied from interface: DecompositionInterface
Computes the decomposition of the input matrix. Depending on the implementation the input matrix might be stored internally or modified. If it is modified then the function DecompositionInterface.inputModified() will return true and the matrix should not be modified until the decomposition is no longer needed.

Specified by:
decompose in interface DecompositionInterface<DenseMatrix64F>
Parameters:
orig - The matrix which is being decomposed. Modification is implementation dependent.
Returns:
Returns if it was able to decompose the matrix.

inputModified

public boolean inputModified()
Description copied from interface: DecompositionInterface
Is the input matrix to DecompositionInterface.decompose(org.ejml.data.Matrix64F) is modified during the decomposition process.

Specified by:
inputModified in interface DecompositionInterface<DenseMatrix64F>
Returns:
true if the input matrix to decompose() is modified.

numRows

public int numRows()
Description copied from interface: SingularValueDecomposition
Number of rows in the decomposed matrix.

Specified by:
numRows in interface SingularValueDecomposition<DenseMatrix64F>
Returns:
Number of rows in the decomposed matrix.

numCols

public int numCols()
Description copied from interface: SingularValueDecomposition
Number of columns in the decomposed matrix.

Specified by:
numCols in interface SingularValueDecomposition<DenseMatrix64F>
Returns:
Number of columns in the decomposed matrix.


Copyright © 2012. All Rights Reserved.