romtools.vector_space.utils.truncater#
Constructing a basis via POD typically entails computing the SVD of a snapshot matrix, .. math:
\mathbf{U} ,\mathbf{\Sigma} = \mathrm{svd}(\mathbf{S})
and then selecting the first \(K\) left singular vectors (i.e., the first \(K\) columns of \(\mathbf{U}\)). Typically, \(K\) is determined through the decay of the singular values.
The truncater class is desined to truncate a basis. We provide concrete implementations that truncate based on a specified number of basis vectors and the decay of the singular values
Classes
|
Truncates to a specified number of singular vectors, as specified in the constructor |
|
Truncates based on the decay of singular values, i.e., will define \(K\) to be the number of singular values such that the cumulative energy retained is greater than some threshold. |
|
Interface for the Truncater class. |
No op implementation |
- class romtools.vector_space.utils.truncater.BasisSizeTruncater(basis_dimension)[source]#
Bases:
objectTruncates to a specified number of singular vectors, as specified in the constructor
This class conforms to LeftSingularVectorTruncater protocol.
- Parameters:
basis_dimension (int)
- get_energy()[source]#
- Returns:
The energy criteria corresponding to the truncated basis
- Return type:
float
- truncate(basis, singular_values)[source]#
Truncate the basis based on the specified dimension.
- Parameters:
basis (np.ndarray) – The original basis matrix.
singular_values (np.ndarray) – The array of singular values associated with the basis matrix.
- Returns:
The truncated basis matrix with the specified dimension.
- Return type:
np.ndarray
- class romtools.vector_space.utils.truncater.EnergyBasedTruncater(threshold)[source]#
Bases:
objectTruncates based on the decay of singular values, i.e., will define \(K\) to be the number of singular values such that the cumulative energy retained is greater than some threshold.
This class conforms to LeftSingularVectorTruncater protocol.
- Parameters:
threshold (float)
- get_energy()[source]#
- Returns:
The energy criteria corresponding to the truncated basis
- Return type:
float
- truncate(basis, singular_values)[source]#
Truncate the basis based on the energy threshold.
- Parameters:
basis (np.ndarray) – The original basis matrix.
singular_values (np.ndarray) – The array of singular values associated with the basis matrix.
- Returns:
The truncated basis matrix based on the energy threshold.
- Return type:
np.ndarray