pysdic.Transformation.apply#

Transformation.apply(x_i, *, dx=False, dp=False, **kwargs)[source]#

Apply the transformation to the given points \(\vec{x_i} \in \mathbb{R}^{n_i}\) to return the transformed points \(\vec{x_o} \in \mathbb{R}^{n_o}\).

\[\vec{x_o} = T(\vec{x_i}; \vec{p})\]

Important

  • The apply method can only be used if the transformation implements it (i.e., has_apply 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_apply_dx and has_apply_dp must be True).

Note

This method is called by __call__ to allow the transformation to be applied directly to points using the syntax transformation(x_i).

Parameters:
  • x_i (ArrayLike) – Input points \(\vec{x_i}\) with shape \((\dots, n_i)\) to which the transformation will be applied. A single point must be reshaped to \((1, n_i)\) before being passed to this method.

  • dx (bool, optional (default: False)) – If True, compute the Jacobian with respect to the input points (i.e., \(\mathbf{J}_x = \frac{\partial T}{\partial \vec{x_i}}\)).

  • dp (bool, optional (default: False)) – If True, compute the Jacobian with respect to the parameters (i.e., \(\mathbf{J}_p = \frac{\partial T}{\partial \vec{p}}\)).

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

Returns:

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

Return type:

pysdic.TransformationResult

Jacobians#

Two Jacobian matrices can optionally be computed:

  • dx: Jacobian of the transformed points with respect to the input points. Shape: \((\dots, n_o, n_i)\) where \(n_i\) is the input dimension and \(n_o\) is the output dimension. Example:

    jacobian_dx[..., 0, 0]  # ∂x_o/∂x_i
    jacobian_dx[..., 0, 1]  # ∂x_o/∂y_i
    jacobian_dx[..., 1, 0]  # ∂y_o/∂x_i
    jacobian_dx[..., 1, 1]  # ∂y_o/∂y_i
    
  • dp: Jacobian of the transformed points with respect to the transformation parameters. Shape: \((\dots, n_o, n_p)\) where \(n_p\) is the number of parameters. Example:

    jacobian_dp[..., 0, 0]  # ∂x_o/∂λ_1
    jacobian_dp[..., 0, 1]  # ∂x_o/∂λ_2
    jacobian_dp[..., 1, 0]  # ∂y_o/∂λ_1
    jacobian_dp[..., 1, 1]  # ∂y_o/∂λ_2
    

The Jacobians are only computed if dx or dp are True.

Developer Notes#

Subclasses must implement the _apply method. This method should:

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

  2. Return three objects:

    • x_o: shape \((n_\text{points}, n_o)\).

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

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

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