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_applymust 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_apply_dxandhas_apply_dpmust be True).
Note
This method is called by
__call__to allow the transformation to be applied directly to points using the syntaxtransformation(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
_applymethod.
- Returns:
Contains the transformed points and the Jacobian matrices (if requested). The transformed points can be accessed using the
xattribute with shape \((\dots, n_o)\). The Jacobian matrices can be accessed using thejacobian_dxandjacobian_dpattributes with shapes \((\dots, n_o, n_i)\) and \((\dots, n_o, n_p)\), or None if not computed.- Return type:
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
dxordpare True.Developer Notes#
Subclasses must implement the
_applymethod. This method should:Accept a NumPy array of shape \((n_\text{points}, n_i)\).
Return three objects:
x_o: shape \((n_\text{points}, n_o)\).jacobian_dx: shape \((n_\text{points}, n_o, n_i)\) ifdx=True, else None.jacobian_dp: shape \((n_\text{points}, n_o, n_p)\) ifdp=True, else None.
The shapes of the outputs of
_applyare checked, and aRuntimeErroris raised if they do not match the expected shapes.