pysdic.AffineParametrization#
AffineParametrization class#
- class AffineParametrization(modes, offset=None)[source]#
Bases:
ParametrizationA parametrization \(P\) defined by an affine map from the input parametric space \(\mathbb{R}^{n_i}\) to the output parametric space \(\mathbb{R}^{n_o}\).
\[\vec{p_o} = P(\vec{p_i}) = \mathbf{M} \vec{p_i} + \vec{p_0}\]where \(\mathbf{M}\) is the matrix of the modes with shape \((n_o, n_i)\) and \(\vec{p_0}\) is the offset with shape \((n_o,)\). Each column of \(\mathbf{M}\) is a mode, i.e. the direction of the output space driven by one input parameter.
The Jacobian of the parametrization is constant:
\[\mathbf{J}_p = \frac{\partial P}{\partial \vec{p_i}} = \mathbf{M}\]If \(\mathbf{M}\) is invertible (square with full rank), the parametrization can be decoded with:
\[\vec{p_i} = P^{-1}(\vec{p_o}) = \mathbf{M}^{-1} (\vec{p_o} - \vec{p_0})\]and the parametrization is both left and right invertible. Otherwise, the
decodemethod is not available.See also
Class
pysdic.Parametrizationfor the base class of parametrizations.
Note
The
modesandoffsetare constants of the parametrization. They are stored as read-only copies and cannot be modified after initialization.- Parameters:
modes (ArrayLike) – The matrix of the modes \(\mathbf{M}\) with shape \((n_o, n_i)\).
offset (Optional[ArrayLike], optional (default:
None)) – The offset \(\vec{p_0}\) with shape \((n_o,)\). If None, a zero offset is used.
Examples
A parametrization of two output parameters driven by a single input parameter:
parametrization = AffineParametrization( modes=[[1.0], [2.0]], offset=[0.0, 1.0], ) parametrization.encode([3.0]).p # array([3., 7.]) parametrization.has_decode # False (M is not square)
This defines:
\[\begin{split}\begin{bmatrix} p_{o,1} \\ p_{o,2} \end{bmatrix} = \begin{bmatrix} 1 \\ 2 \end{bmatrix} p_{i} + \begin{bmatrix} 0 \\ 1 \end{bmatrix}\end{split}\]With an invertible matrix, the parametrization can also be decoded:
parametrization = AffineParametrization( modes=[[2.0, 0.0], [1.0, 1.0]], ) parametrization.encode([1.0, 1.0]).p # array([2., 2.]) parametrization.decode([2.0, 2.0]).p # array([1., 1.])
Instantiation#
The AffineParametrization class is instantiated directly with its constructor:
With a matrix of modes \(\mathbf{M}\) of shape \((n_o, n_i)\):
AffineParametrization(modes)(zero offset).With a matrix of modes and an offset \(\vec{p_0}\) of shape \((n_o,)\):
AffineParametrization(modes, offset).
The decode method is only available if \(\mathbf{M}\) is square with full rank.
Implemented methods and attributes#
The following sections provide an overview of the attributes and methods defined
in the pysdic.AffineParametrization class.
Attributes#
The pysdic.AffineParametrization defines the following attributes
(the constants modes and offset are read-only):
[Get] the input dimension \(n_i\) of the parametrization, i.e. the number of modes (columns of \(\mathbf{M}\)). |
|
[Get] the matrix of the modes \(\mathbf{M}\) of the parametrization. |
|
[Get] the offset \(\vec{p_0}\) of the parametrization. |
|
[Get] the output dimension \(n_o\) of the parametrization, i.e. the number of rows of \(\mathbf{M}\). |
Encoding and decoding#
Use the encode and decode methods from
pysdic.Parametrization to perform the parametrization:
encode: mapsp_i→p_o = M p_i + p_0.decode: mapsp_o→p_i = M^{-1} (p_o - p_0)(only if \(\mathbf{M}\) is invertible).
The Jacobian with respect to the parameters can be computed by enabling the dp flag:
dp=True: compute ∂p_o / ∂p_i (constant, equal to \(\mathbf{M}\))
|
Apply the affine parametrization to input parameters \(\vec{p_i}\). |
|
Apply the inverse affine map to output parameters \(\vec{p_o}\). |