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_invert must be True).

  • The transformation must be fully set up (i.e., is_setup must be True).

  • The jacobian dx and dp can only be computed if the transformation supports it (i.e., has_invert_dx and has_invert_dp must be True).

Note

The relation between invert and apply is given by the flags is_left_invertible (\(T^{-1} \circ T = \text{Id}\)) and is_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 _invert method.

Returns:

Contains the inverted input points and the Jacobian matrices (if requested). The inverted input points can be accessed using the x attribute with shape \((\dots, n_i)\). The Jacobian matrices can be accessed using the jacobian_dx and jacobian_dp attributes with shapes \((\dots, n_i, n_o)\) and \((\dots, n_i, n_p)\), or None if not computed.

Return type:

pysdic.TransformationResult

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 dx or dp are True.

Developer Notes#

Subclasses must implement the _invert method. This method should:

  1. Accept a NumPy array of shape \((n_\text{points}, n_o)\).

  2. Return three objects:

    • x_i: shape \((n_\text{points}, n_i)\).

    • jacobian_dx: shape \((n_\text{points}, n_i, n_o)\) if dx=True, else None.

    • jacobian_dp: shape \((n_\text{points}, n_i, n_p)\) if dp=True, else None.

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