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 byproject()
. Ifstate
is one-dimensional then \(||\cdot||\) is the vector 2-norm. Ifstate
is two-dimensional then \(||\cdot||\) is the matrix 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 errornorm(state - project(state)) / norm(state)
. IfFalse
, return the absolute projection errornorm(state - project(state))
.
- Returns:
- float
Relative error of the projection (
relative=True
) or absolute error of the projection (relative=False
).