SVD¶
-
class
hcipy.util.
SVD
(M, num_modes=None)¶ Bases:
object
The Singular Value Decomposition for the provided matrix.
This class wraps two versions of the SVD in numpy and scipy, and provides easy access to singular modes (as mode bases) and allows for calculation of the SVD for a limited number of modes.
When a sparse matrix is passed, and no number of modes is given, all but one mode will be calculated. The reason is that the sparse SVD implementation in Scipy doesn’t allow calculation of all modes. If all modes are required, the user must pass a densified version of the matrix (ie. M.toarray()).
- Parameters
- Mndarray or any sparse matrix
The matrix on which to perform the SVD.
- num_modesint or None
The number of singular values and modes to calculate. If this is None, and M is not sparse, all modes will be computed. If this is None and M is sparse, all but one mode will be computed.
Attributes Summary
The matrix for which the SVD was calculated.
The singular values of the matrix.
The U matrix of the SVD.
The V^T matrix of the SVD.
The left singular modes of the matrix, as a ModeBasis.
The number of singular modes that were calculated in this SVD.
The right singular modes of the matrix, as a ModeBasis.
The singular values of the matrix.
The raw U, S, and V^T matrices of the SVD as a tuple.
Attributes Documentation
-
M
¶ The matrix for which the SVD was calculated.
-
S
¶ The singular values of the matrix.
-
U
¶ The U matrix of the SVD.
-
Vt
¶ The V^T matrix of the SVD.
-
left_singular_modes
¶ The left singular modes of the matrix, as a ModeBasis.
-
num_modes
¶ The number of singular modes that were calculated in this SVD.
-
right_singular_modes
¶ The right singular modes of the matrix, as a ModeBasis.
-
singular_values
¶ The singular values of the matrix.
-
svd
¶ The raw U, S, and V^T matrices of the SVD as a tuple.