# post/__init__.py
r"""Tools for computing errors of reduced-order model solutions.

.. currentmodule:: opinf.post


Absolute and Relative Error
===========================

Given a norm :math:`\|\cdot\|`, "true" data :math:`\mathbf{Q}`, and an
approximation :math:`\breve{\mathbf{Q}}` to :math:`\mathbf{Q}`, the absolute
and relative errors of the approximation :math:`\breve{\mathbf{Q}}` are defined
as

.. math::
    e_{\text{absolute}}
    = \|\mathbf{Q} - \breve{\mathbf{Q}}\|,
    \qquad
    e_{\text{relative}}
    = \frac{e_{\text{absolute}}}{\|\mathbf{Q}\|}
    = \frac{\|\mathbf{Q} - \breve{\mathbf{Q}}\|}{\|\mathbf{Q}\|}.

In the context of this package, :math:`\mathbf{Q}\in\mathbb{R}^{n \times k}` is
typically a matrix whose :math:`j`th column is the true state vector at time
:math:`t_{j}`, and the approximation :math:`\breve{\mathbf{Q}}\in\mathbb{R}^{n
\times k}` is the corresponding matrix of reduced-order model solutions.


Projection Error
================

The projection error is defined by the low-dimensional representation of the
state, not the solution of a reduced-order model *per se*. For a true state
:math:`\mathbf{q} \in \mathbb{R}^{n}`, consider the  low-dimensional (linear)
approximation

.. math::
    \breve{\mathbf{q}} = \mathbf{V}_{r}\widehat{\mathbf{q}},

where :math:`\mathbf{V}_{r}\in\mathbb{R}^{n\times r}`. The projection error
associated with this approximation is

.. math::
    \|\mathbf{q} - \breve{\mathbf{q}}\|
    = \|\mathbf{q} - \mathbf{V}_{r}\mathbf{V}_{r}^{\mathsf{T}}\mathbf{q}\|.

The following function computes this projection error, given a basis matrix
:math:`\mathbf{V}_{r}`.

.. autosummary::
    :toctree: _autosummaries
    :nosignatures:

    projection_error

This function is also available as :func:`opinf.pre.projection_error`; basis
classes such as :class:`opinf.pre.PODBasis` also have a ``projection_error()``
method.


Reduced-order Model Error
=========================

The following functions compute the error between a true state solution
:math:`\mathbf{q}(t) \in \mathbb{R}^{n}` of the system of interest and an
approximation :math:`\breve{\mathbf{q}}(t) \in \mathbb{R}^{n}` generated by
a reduced-order model.
Each uses a different norm to measure the absolute and relative errors.

.. autosummary::
    :toctree: _autosummaries
    :nosignatures:

    frobenius_error
    lp_error
    Lp_error
"""

from ._errors import *
