pysolvegn.build_affine_parametrization#
- build_affine_parametrization(modes, offset=None, *, sparse=None)[source]#
Build a
Parametrizationbased on an affine transformation.The parametrization maps the optimized input parameters \(\mathbf{p}_{in}\) to the output parameters passed to the terms according to:
\[\mathbf{p}_{out} = M \mathbf{p}_{in} + \mathbf{p}_0\]where \(M\) is the transformation matrix and \(\mathbf{p}_0\) is an optional offset.
The corresponding Jacobian is constant:
\[\mathbf{J}_P = \frac{\partial \mathbf{p}_{out}} {\partial \mathbf{p}_{in}} = M.\]- Parameters:
modes (Union[ArrayLike, scipy.sparse.spmatrix]) – The matrix of the affine transformation with shape
(n_p_outputs, n_parameters), a dense array or ascipy.sparsematrix.offset (Optional[ArrayLike], optional) – The offset of the affine transformation with shape
(n_p_outputs,). IfNone, a zero offset is used.sparse (Optional[bool], optional (default:
None)) – If True, the Jacobian is ascipy.sparse.csr_matrix; if False, a densenumpy.ndarray. If None, the Jacobian has the format ofmodes(sparse for ascipy.sparsematrix, dense otherwise).
- Returns:
A
Parametrizationimplementing the affine transformation.- Return type:
Examples
A two-dimensional parameterization from one optimized parameter:
>>> parametrization = build_affine_parametrization( ... modes=[[1.0], [2.0]], ... offset=[0.0, 1.0], ... )
This defines:
\[\begin{split}\begin{bmatrix} p_{out,0} \\ p_{out,1} \end{bmatrix} = \begin{bmatrix} 1 \\ 2 \end{bmatrix} p_{in} + \begin{bmatrix} 0 \\ 1 \end{bmatrix}.\end{split}\]