Class SvdImplicitQrDecompose_DDRM
- All Implemented Interfaces:
DecompositionInterface<DMatrixRMaj>
,SingularValueDecomposition<DMatrixRMaj>
,SingularValueDecomposition_F64<DMatrixRMaj>
- Direct Known Subclasses:
SvdImplicitQrDecompose_MT_DDRM
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
-
Field Summary
Modifier and TypeFieldDescriptionprotected BidiagonalDecomposition_F64<DMatrixRMaj>
protected boolean
protected boolean
protected boolean
protected boolean
protected int
protected int
protected int
protected int
protected boolean
protected boolean
protected SvdImplicitQrAlgorithm_DDRM
protected boolean
-
Constructor Summary
ConstructorDescriptionSvdImplicitQrDecompose_DDRM
(boolean compact, boolean computeU, boolean computeV, boolean canUseTallBidiagonal) Configures the class -
Method Summary
Modifier and TypeMethodDescriptionprotected void
boolean
decompose
(DMatrixRMaj orig) Computes the decomposition of the input matrix.double[]
Returns the singular values.getU
(@Nullable DMatrixRMaj U, boolean transpose) Returns the orthogonal 'U' matrix.getV
(@Nullable DMatrixRMaj V, boolean transpose) Returns the orthogonal 'V' matrix.getW
(@Nullable DMatrixRMaj W) Returns a diagonal matrix with the singular values.boolean
Checks if the input matrix toDecompositionInterface.decompose(org.ejml.data.Matrix)
is modified during the decomposition process.boolean
If true then compact matrices are returned.int
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.protected void
transpose
(@NotNull DMatrixRMaj V, DMatrixRMaj Vt)
-
Field Details
-
numRows
protected int numRows -
numCols
protected int numCols -
numRowsT
protected int numRowsT -
numColsT
protected int numColsT -
canUseTallBidiagonal
protected boolean canUseTallBidiagonal -
bidiag
-
qralg
-
compact
protected boolean compact -
computeU
protected boolean computeU -
computeV
protected boolean computeV -
prefComputeU
protected boolean prefComputeU -
prefComputeV
protected boolean prefComputeV -
transposed
protected boolean transposed
-
-
Constructor Details
-
SvdImplicitQrDecompose_DDRM
public SvdImplicitQrDecompose_DDRM(boolean compact, boolean computeU, boolean computeV, boolean canUseTallBidiagonal) Configures the class- Parameters:
compact
- Compute a compact SVDcomputeU
- If true it will compute the U matrixcomputeV
- If true it will compute the V matrixcanUseTallBidiagonal
- If true then it can choose to use a tall Bidiagonal decomposition to improve runtime performance.
-
-
Method Details
-
getSingularValues
public double[] getSingularValues()Description copied from interface:SingularValueDecomposition_F64
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 interfaceSingularValueDecomposition_F64<DMatrixRMaj>
- 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 interfaceSingularValueDecomposition<DMatrixRMaj>
- 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 interfaceSingularValueDecomposition<DMatrixRMaj>
- Returns:
- true if results use compact notation.
-
getU
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 interfaceSingularValueDecomposition<DMatrixRMaj>
- Parameters:
U
- Optional storage for U. If null a new instance or internally maintained matrix is returned. Modified.transpose
- If the returned U is transposed.- Returns:
- An orthogonal matrix.
-
getV
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 interfaceSingularValueDecomposition<DMatrixRMaj>
- Parameters:
V
- Optional storage for v. If null a new instance or internally maintained matrix is returned. Modified.transpose
- If the returned V is transposed.- Returns:
- An orthogonal matrix.
-
transpose
-
getW
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 interfaceSingularValueDecomposition<DMatrixRMaj>
- 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.
-
decompose
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 functionDecompositionInterface.inputModified()
will return true and the matrix should not be modified until the decomposition is no longer needed.- Specified by:
decompose
in interfaceDecompositionInterface<DMatrixRMaj>
- 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
Checks if the input matrix toDecompositionInterface.decompose(org.ejml.data.Matrix)
is modified during the decomposition process.- Specified by:
inputModified
in interfaceDecompositionInterface<DMatrixRMaj>
- Returns:
- true if the input matrix to decompose() is modified.
-
declareBidiagonalDecomposition
protected void declareBidiagonalDecomposition() -
numRows
public int numRows()Description copied from interface:SingularValueDecomposition
Number of rows in the decomposed matrix.- Specified by:
numRows
in interfaceSingularValueDecomposition<DMatrixRMaj>
- 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 interfaceSingularValueDecomposition<DMatrixRMaj>
- Returns:
- Number of columns in the decomposed matrix.
-