pysdic.Parametrization.decode#

Parametrization.decode(p_o, *, dp=False, **kwargs)[source]#

Apply the decoding map \(P^{-1}\) to the output parameters \(\vec{p_o} \in \mathbb{R}^{n_o}\) to return the decoded parameters \(\vec{p_i} \in \mathbb{R}^{n_i}\).

\[\vec{p_i} = P^{-1}(\vec{p_o})\]

Important

  • The decode method can only be used if the parametrization implements it (i.e., has_decode must be True).

  • The jacobian dp can only be computed if the parametrization supports it (i.e., has_decode_dp must be True).

Note

The relation between decode and encode is given by the flags is_left_invertible (\(P^{-1} \circ P = \text{Id}\)) and is_right_invertible (\(P \circ P^{-1} = \text{Id}\)).

Parameters:
  • p_o (ArrayLike) – Output parameters \(\vec{p_o}\) with shape \((n_o,)\) to which the decoding map will be applied.

  • dp (bool, optional (default: False)) – Whether to compute the Jacobian with respect to the output parameters. (i.e., \(\mathbf{J}_p = \frac{\partial P^{-1}}{\partial \vec{p_o}}\)).

  • **kwargs – Additional arguments passed to the underlying _decode method.

Returns:

Contains the decoded parameters accessible using the p attribute with shape \((n_i,)\), and the Jacobian matrix with respect to the output parameters accessible using the jacobian_dp attribute with shape \((n_i, n_o)\) if computed, or None otherwise.

Return type:

pysdic.ParametrizationResult

Notes

The jacobian dp has the following structure:

jacobian_dp[0, 0]  # ∂p_i1/∂p_o1
jacobian_dp[0, 1]  # ∂p_i1/∂p_o2
jacobian_dp[1, 0]  # ∂p_i2/∂p_o1
jacobian_dp[1, 1]  # ∂p_i2/∂p_o2
jacobian_dp[i, j]  # ∂p_ii/∂p_oj

Developers notes#

Subclasses must implement the _decode method. This method should:

  1. Accept a NumPy array of shape \((n_o,)\).

  2. Return \(\vec{p_i}\) Numpy array of shape \((n_i,)\) and optionally the Jacobian matrix with respect to the output parameters as a 2D array of shape \((n_i, n_o)\) if dp is True, or None otherwise.

The shapes of the outputs of _decode are checked, and a RuntimeError is raised if they do not match the expected shapes.