org.ejml.alg.dense.decomposition.svd
Class SafeSvd
- java.lang.Object
-
- org.ejml.alg.dense.decomposition.svd.SafeSvd
-
- All Implemented Interfaces:
- DecompositionInterface<DenseMatrix64F>, SingularValueDecomposition<DenseMatrix64F>
public class SafeSvd extends java.lang.Object implements SingularValueDecomposition<DenseMatrix64F>
Wraps around aSingularValueDecompositionand ensures that the input is not modified.
-
-
Constructor Summary
Constructors Constructor and Description SafeSvd(SingularValueDecomposition<DenseMatrix64F> alg)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleandecompose(DenseMatrix64F orig)Computes the decomposition of the input matrix.double[]getSingularValues()Returns the singular values.DenseMatrix64FgetU(DenseMatrix64F U, boolean transposed)Returns the orthogonal 'U' matrix.DenseMatrix64FgetV(DenseMatrix64F V, boolean transposed)Returns the orthogonal 'V' matrix.DenseMatrix64FgetW(DenseMatrix64F W)Returns a diagonal matrix with the singular values.booleaninputModified()Is the input matrix toDecompositionInterface.decompose(org.ejml.data.Matrix)is modified during the decomposition process.booleanisCompact()If true then compact matrices are returned.intnumberOfSingularValues()The number of singular values in the matrix.intnumCols()Number of columns in the decomposed matrix.intnumRows()Number of rows in the decomposed matrix.
-
-
-
Constructor Detail
-
SafeSvd
public SafeSvd(SingularValueDecomposition<DenseMatrix64F> alg)
-
-
Method Detail
-
getSingularValues
public double[] getSingularValues()
Description copied from interface:SingularValueDecompositionReturns the singular values. This is the diagonal elements of the W matrix in the decomposition. Ordering of singular values is not guaranteed..- Specified by:
getSingularValuesin interfaceSingularValueDecomposition<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:SingularValueDecompositionThe number of singular values in the matrix. This is equal to the length of the smallest side.- Specified by:
numberOfSingularValuesin interfaceSingularValueDecomposition<DenseMatrix64F>- Returns:
- Number of singular values in the matrix.
-
isCompact
public boolean isCompact()
Description copied from interface:SingularValueDecompositionIf true then compact matrices are returned.- Specified by:
isCompactin interfaceSingularValueDecomposition<DenseMatrix64F>- Returns:
- true if results use compact notation.
-
getU
public DenseMatrix64F getU(DenseMatrix64F U, boolean transposed)
Description copied from interface:SingularValueDecompositionReturns 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:
getUin interfaceSingularValueDecomposition<DenseMatrix64F>- Parameters:
U- Optional storage for U. If null a new instance or internally maintained matrix is returned. Modified.transposed- If the returned U is transposed.- Returns:
- An orthogonal matrix.
-
getV
public DenseMatrix64F getV(DenseMatrix64F V, boolean transposed)
Description copied from interface:SingularValueDecompositionReturns 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:
getVin interfaceSingularValueDecomposition<DenseMatrix64F>- Parameters:
V- Optional storage for v. If null a new instance or internally maintained matrix is returned. Modified.transposed- If the returned V is transposed.- Returns:
- An orthogonal matrix.
-
getW
public DenseMatrix64F getW(DenseMatrix64F W)
Description copied from interface:SingularValueDecompositionReturns a diagonal matrix with the singular values. Order of the singular values is not guaranteed.- Specified by:
getWin interfaceSingularValueDecomposition<DenseMatrix64F>- Parameters:
W- Optional storage for W. If null a new instance or internally maintained matrix is returned. Modified.- Returns:
- Diagonal matrix with singular values along the diagonal.
-
numRows
public int numRows()
Description copied from interface:SingularValueDecompositionNumber of rows in the decomposed matrix.- Specified by:
numRowsin interfaceSingularValueDecomposition<DenseMatrix64F>- Returns:
- Number of rows in the decomposed matrix.
-
numCols
public int numCols()
Description copied from interface:SingularValueDecompositionNumber of columns in the decomposed matrix.- Specified by:
numColsin interfaceSingularValueDecomposition<DenseMatrix64F>- Returns:
- Number of columns in the decomposed matrix.
-
decompose
public boolean decompose(DenseMatrix64F orig)
Description copied from interface:DecompositionInterfaceComputes 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 functionDecompositionInterface.inputModified()will return true and the matrix should not be modified until the decomposition is no longer needed.- Specified by:
decomposein interfaceDecompositionInterface<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:DecompositionInterfaceIs the input matrix toDecompositionInterface.decompose(org.ejml.data.Matrix)is modified during the decomposition process.- Specified by:
inputModifiedin interfaceDecompositionInterface<DenseMatrix64F>- Returns:
- true if the input matrix to decompose() is modified.
-
-
DMelt 3.0 © DataMelt by jWork.ORG