projection_error()#

PODBasis.projection_error(state, relative=True) float#

Compute the error of the basis representation of a state or states.

This function computes \(\frac{\|\Q - \mathcal{P}(\Q)\|}{\|\Q\|}\), where \(\Q\) is the state and \(\mathcal{P}\) is the projection defined by project(). If state is one-dimensional then \(||\cdot||\) is the vector 2-norm. If state is two-dimensional then \(||\cdot||\) is the Frobenius norm.

Parameters
state(n,) or (n, k) ndarray

High-dimensional state vector, or a collection of k such vectors organized as the columns of a matrix.

relativebool

If True (default), return the relative projection error norm(state - project(state)) / norm(state). If False, return the absolute projection error norm(state - project(state)).

Returns
float

Relative error of the projection (relative=True) or absolute error of the projection (relative=False).