pysdic.ComposedTransformation._apply#
- ComposedTransformation._apply(x_i, *, dx=False, dp=False, kwargs=None, bypass_dp=None)[source]#
Apply the composition of transformations to the input points \(\vec{x_i}\) to produce the output points \(\vec{x_o}\).
\[\vec{x_o} = T_n(T_{n-1}(...T_1(\vec{x_i})...))\]Lets \(\vec{y}_0 = \vec{x_i}\) and \(\vec{y}_k = T_k(\vec{y}_{k-1}; \vec{p}_k)\) be the intermediate points. The Jacobian with respect to the input points is computed using the chain rule across the sequence of transformations:
\[\mathbf{J}_x = \frac{\partial T_n}{\partial \vec{y}_{n-1}} \cdot ... \cdot \frac{\partial T_2}{\partial \vec{y}_1} \cdot \frac{\partial T_1}{\partial \vec{x_i}}\]The Jacobian with respect to the parameters is the concatenation of the Jacobians with respect to the parameters of each transformation, propagated through the transformations applied after it:
\[\mathbf{J}_p = \begin{bmatrix} \frac{\partial T}{\partial \vec{p}_1} & \frac{\partial T}{\partial \vec{p}_2} & \dots & \frac{\partial T}{\partial \vec{p}_n} \end{bmatrix} \quad \text{with} \quad \frac{\partial T}{\partial \vec{p}_k} = \frac{\partial T_n}{\partial \vec{y}_{n-1}} \cdot ... \cdot \frac{\partial T_{k+1}}{\partial \vec{y}_k} \cdot \frac{\partial T_k}{\partial \vec{p}_k}\]- Parameters:
x_i (numpy.ndarray) – The input points to transform, with shape \((n_\text{points}, n_i)\) where \(n_i\) is the input dimension of the first transformation in the composition.
dx (bool, optional (default:
False)) – If True, compute the Jacobian with respect to the input points.dp (bool, optional (default:
False)) – If True, compute the Jacobian with respect to the parameters.kwargs (Optional[List[Optional[Dict[str, Any]]]], optional (default:
None)) – A list of dictionaries containing additional keyword arguments to pass to each transformation’s apply method. The list must have the same length as the number of transformations in the composition, in the order \([T_1, T_2, ..., T_n]\).Noneelements are replaced by empty dictionaries.bypass_dp (Optional[Sequence[bool]], optional (default:
None)) – A sequence of booleans with the same length as the number of transformations, in the order \([T_1, T_2, ..., T_n]\). Ifdp=True, the Jacobian with respect to the parameters of the transformations withTrueis not computed (nor propagated) and its columns injacobian_dpare filled with NaN. If None, no Jacobian is bypassed. Ignored ifdp=False.
- Returns:
numpy.ndarray – The transformed output points, with shape \((n_\text{points}, n_o)\) where \(n_o\) is the output dimension of the last transformation in the composition.
Optional[numpy.ndarray] – The Jacobian matrix with respect to the input points if
dx=True, with shape \((n_\text{points}, n_o, n_i)\), or None ifdx=False.Optional[numpy.ndarray] – The Jacobian matrix with respect to the parameters if
dp=True, with shape \((n_\text{points}, n_o, n_p)\), or None ifdp=False, where \(n_p\) is the total number of parameters of the composition.
- Return type: