pysdic.Transformation.invert#
- Transformation.invert(x_o, *, dx=False, dp=False, **kwargs)[source]#
Apply the inverse map \(T^{-1}\) to the given output points \(\vec{x_o} \in \mathbb{R}^{n_o}\) to return the corresponding input points \(\vec{x_i} \in \mathbb{R}^{n_i}\).
\[\vec{x_i} = T^{-1}(\vec{x_o}; \vec{p})\]Important
The invert method can only be used if the transformation implements it (i.e.,
has_invertmust be True).The transformation must be fully set up (i.e.,
is_setupmust be True).The jacobian
dxanddpcan only be computed if the transformation supports it (i.e.,has_invert_dxandhas_invert_dpmust be True).
Note
The relation between
invertandapplyis given by the flagsis_left_invertible(\(T^{-1} \circ T = \text{Id}\)) andis_right_invertible(\(T \circ T^{-1} = \text{Id}\)).- Parameters:
x_o (ArrayLike) – Output points \(\vec{x_o}\) with shape \((\dots, n_o)\) for which to compute the inverse transformation. A single point must be reshaped to \((1, n_o)\) before being passed to this method.
dx (bool, optional (default:
False)) – If True, compute the Jacobian with respect to the output points (i.e., \(\mathbf{J}_x = \frac{\partial T^{-1}}{\partial \vec{x_o}}\)).dp (bool, optional (default:
False)) – If True, compute the Jacobian with respect to the parameters (i.e., \(\mathbf{J}_p = \frac{\partial T^{-1}}{\partial \vec{p}}\)).**kwargs – Additional arguments passed to the underlying
_invertmethod.
- Returns:
Contains the inverted input points and the Jacobian matrices (if requested). The inverted input points can be accessed using the
xattribute with shape \((\dots, n_i)\). The Jacobian matrices can be accessed using thejacobian_dxandjacobian_dpattributes with shapes \((\dots, n_i, n_o)\) and \((\dots, n_i, n_p)\), or None if not computed.- Return type:
Jacobians#
Two Jacobian matrices can optionally be computed:
dx: Jacobian of the inverted input points with respect to the output points. Shape: \((\dots, n_i, n_o)\) where \(n_i\) is the input dimension and \(n_o\) is the output dimension. Example:jacobian_dx[..., 0, 0] # ∂x_i/∂x_o jacobian_dx[..., 0, 1] # ∂x_i/∂y_o jacobian_dx[..., 1, 0] # ∂y_i/∂x_o jacobian_dx[..., 1, 1] # ∂y_i/∂y_o
dp: Jacobian of the inverted input points with respect to the transformation parameters. Shape: \((\dots, n_i, n_p)\) where \(n_p\) is the number of parameters. Example:jacobian_dp[..., 0, 0] # ∂x_i/∂λ_1 jacobian_dp[..., 0, 1] # ∂x_i/∂λ_2 jacobian_dp[..., 1, 0] # ∂y_i/∂λ_1 jacobian_dp[..., 1, 1] # ∂y_i/∂λ_2
The Jacobians are only computed if
dxordpare True.Developer Notes#
Subclasses must implement the
_invertmethod. This method should:Accept a NumPy array of shape \((n_\text{points}, n_o)\).
Return three objects:
x_i: shape \((n_\text{points}, n_i)\).jacobian_dx: shape \((n_\text{points}, n_i, n_o)\) ifdx=True, else None.jacobian_dp: shape \((n_\text{points}, n_i, n_p)\) ifdp=True, else None.
The shapes of the outputs of
_invertare checked, and aRuntimeErroris raised if they do not match the expected shapes.