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

BasisSizeTruncater(basis_dimension)

Truncates to a specified number of singular vectors, as specified in the constructor

EnergyBasedTruncater(threshold)

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.

LeftSingularVectorTruncater(*args, **kwargs)

Interface for the Truncater class.

NoOpTruncater()

No op implementation

class romtools.vector_space.utils.truncater.BasisSizeTruncater(basis_dimension)[source]#

Bases: object

Truncates 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: object

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.

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

class romtools.vector_space.utils.truncater.LeftSingularVectorTruncater(*args, **kwargs)[source]#

Bases: Protocol

Interface for the Truncater class.

truncate(basis, singular_values)[source]#

Truncate left singular vectors

Parameters:
  • basis (ndarray)

  • singular_values (ndarray)

Return type:

ndarray

class romtools.vector_space.utils.truncater.NoOpTruncater[source]#

Bases: object

No op implementation

This class conforms to LeftSingularVectorTruncater protocol.