Class RealSVD
- All Implemented Interfaces:
Decomposition<Matrix>
Instances of this class can be used to compute the singular value decomposition (SVD) of a real dense matrix.
That is, decompose a rectangular matrix
M
as M=USV<sup>T</sup>
where U
and V
are
orthogonal matrices whose columns are the left and right singular vectors of M
and S
is a rectangular
diagonal matrix containing the singular values of M
.-
Field Summary
-
Constructor Summary
ConstructorDescriptionRealSVD()
Creates a decomposer to compute the singular value decomposition of a real matrix.RealSVD
(boolean computeUV) Creates a decomposer to compute the singular value decomposition of a real matrix.RealSVD
(boolean computeUV, boolean reduced) Creates a decomposer to compute the singular value decomposition of a real matrix. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
extractNormalizedCols
(Matrix singularVecs, int j) Extracts the singular vectors, normalizes them and sets the columns ofU
andV
to be the left/right singular vectors.protected void
Initializes the unitaryU
andV
matrices for the SVD.protected Matrix
invDirectSum
(Matrix src) Computes the inverse direct sum of a matrix and its hermitian transpose.protected Matrix
makeEigenPairs
(Matrix B, double[] eigVals) Gets the eigen values and vectors of symmetric the block matrix which corresponds to the singular values and vectors of the matrix being decomposed.protected void
makeEigenVals
(Matrix B, double[] eigVals) Gets the eigen values of the symmetric block matrix which corresponds to the singular values of the matrix being decomposed.
-
Constructor Details
-
RealSVD
public RealSVD()Creates a decomposer to compute the singular value decomposition of a real matrix. The left and right singular vectors will be computed. -
RealSVD
public RealSVD(boolean computeUV) Creates a decomposer to compute the singular value decomposition of a real matrix.- Parameters:
computeUV
- A flag which indicates if the orthogonal matricesQ
andV
should be computed (i.e. the singular vectors). By default, this is true.
- If true, theQ
andV
matrices will be computed.
- If false, theQ
andV
matrices will not be computed. If they are not needed, this may provide a performance improvement.
-
RealSVD
public RealSVD(boolean computeUV, boolean reduced) Creates a decomposer to compute the singular value decomposition of a real matrix.- Parameters:
computeUV
- A flag which indicates if the orthogonal matricesQ
andV
should be computed (i.e. the singular vectors). By default, this is true.
- If true, theQ
andV
matrices will be computed.
- If false, theQ
andV
matrices will not be computed. If they are not needed, this may provide a performance improvement.reduced
- Flag which indicates if the reduced (or full) SVD should be computed. This is false by default.
- If true, reduced SVD is computed. - If false, the full SVD is computed.
-
-
Method Details
-
invDirectSum
Computes the inverse direct sum of a matrix and its hermitian transpose.- Specified by:
invDirectSum
in classSVD<Matrix>
- Parameters:
src
- Matrix to inverse direct add with its hermitian transpose.- Returns:
- The inverse direct sum of the
src
matrix with its hermitian transpose.
-
makeEigenPairs
Gets the eigen values and vectors of symmetric the block matrix which corresponds to the singular values and vectors of the matrix being decomposed.- Specified by:
makeEigenPairs
in classSVD<Matrix>
- Parameters:
B
- Symmetric block matrix to compute the eigenvalues of.eigVals
- Storage for eigenvalues.- Returns:
- The eigenvalues and eigenvectors of the symmetric block matrix which corresponds to the singular values and vectors of the matrix being decomposed.
-
makeEigenVals
Gets the eigen values of the symmetric block matrix which corresponds to the singular values of the matrix being decomposed.- Specified by:
makeEigenVals
in classSVD<Matrix>
- Parameters:
B
- Symmetric block matrix to compute the eigenvalues of.eigVals
- Storage for eigenvalues.
-
initUV
-
extractNormalizedCols
Extracts the singular vectors, normalizes them and sets the columns ofU
andV
to be the left/right singular vectors.- Specified by:
extractNormalizedCols
in classSVD<Matrix>
- Parameters:
singularVecs
- Computed left and right singular vectors.j
- Index of the column ofU
andV
to set.
-