polynomials_on_simplices.calculus.affine_map module

Functionality for dealing with affine maps \(\Phi : \mathbb{R}^m \to \mathbb{R}^n\) with

\[\Phi(x) = Ax + b,\]

where \(A \in \mathbb{R}^{n \times m}, b \in \mathbb{R}^n\).

affine_composition(phi1, phi2)[source]

Compute the matrix and vector defining the composition of two affine maps.

\(\Phi_1(x) = A_1x + b_1, \Phi_2(x) = A_2x + b_2, \Phi(x) = (\Phi_2 \circ \Phi_1)(x) = Ax + b\). \(A = A_2 A_1, b = A_2 b_1 + b_2\).

Parameters:
  • phi1 – Tuple of A matrix and b vector for the first affine transformation.
  • phi2 – Tuple of A matrix and b vector for the second affine transformation.
Returns:

Tuple of A and b.

create_affine_map(a, b, multiple_arguments=False)[source]

Generate the affine map \(\Phi : \mathbb{R}^m \to \mathbb{R}^n, \Phi(x) = Ax + b\) from a matrix A and a vector b (or scalars a and b in the case m = n = 1).

Parameters:
  • a – Matrix or scalar defining the linear part of the affine map.
  • b – Vector or scalar defining the translation part of the affine map.
  • multiple_arguments (bool) – For a multivariate affine map, this argument determines if the generated map should take m scalar arguments or 1 m-dimensional vector as argument. For example with a 2-dimensional domain the generated map could have the signature \(\Phi([x, y])\) (if multiple_arguments is False) or \(\Phi(x, y)\) (if multiple_arguments is True).
Returns:

Map \(\Phi\) which takes an m-dimensional vector as input and returns an n-dimensional vector (or scalar input and output for m = n = 1).

Return type:

Callable \(\Phi(x)\).

inverse_affine_transformation(a, b)[source]

Generate the matrix and vector defining the inverse of a given affine map \(\Phi : \mathbb{R}^n \to \mathbb{R}^n\),

\[\Phi(x) = Ax + b.\]

The inverse of the affine map \(\Phi(x)\) is given by \(\Phi^{-1}(x) = A^{-1}x - A^{-1}b\). This function returns the matrix \(A^{-1}\) and vector \(-A^{-1}b\) defining the inverse map (or scalars 1 / A and -b / A for scalar input A, b).

Parameters:
  • a – Matrix or scalar defining the linear part of the affine map we want to invert.
  • b – Vector or scalar defining the translation part of the affine map we want to invert.
Returns:

Tuple of A and b.

pseudoinverse_affine_transformation(a, b)[source]

Generate the matrix and vector defining the pseudoinverse of a given affine map.

The inverse of an affine map \(\Phi(x) = Ax + b\) is given by \(\Phi^{-1}(x) = A^{-1}x - A^{-1}b\). Assuming the matrix A is not invertible, but \(A^T A\) is, so that it has pseudoinverse \(A^+ = (A^T A)^{-1} A^T\). Then the affine map \(\Phi^+(x) = A^+x - A^+b\) satisfies \(\Phi^+(\Phi(x)) = x\). This function returns the matrix \(A^+\) and vector \(-A^+b\) defining this pseudoinverse map.

Parameters:
  • a – Matrix or scalar defining the linear part of the affine map we want to invert.
  • b – Vector or scalar defining the translation part of the affine map we want to invert.
Returns:

Tuple of A and b.