polynomials_on_simplices.linalg.basis module¶
Functionality for dealing with bases.
-
basis_matrix
(basis_vectors_array)[source]¶ Construct the matrix representation of a basis from a list of basis vectors.
Parameters: basis_vectors_array – List of basis vectors. Returns: Matrix representation of basis (square matrix with basis vectors as columns).
-
basis_vectors
(basis)[source]¶ Get a list of basis vectors from the matrix representation of a basis.
Parameters: basis – Matrix representation of basis (square matrix with basis vectors as columns). Returns: List of basis vectors.
-
cartesian_basis
(dimension=3)[source]¶ Get the standard Cartesian basis in the specified dimension.
Parameters: dimension (int) – Dimension of Euclidean space. Returns: The identity matrix in \(\mathbb{R}^n\), where n is the desired dimension. Return type: Numpy array
Examples
>>> cartesian_basis(2) array([[1., 0.], [0., 1.]])
-
cartesian_basis_vector
(i, dimension=3)[source]¶ Get the i:th standard Cartesian basis vector in the specified dimension (3 by default).
Parameters: Returns: The i:th Cartesian basis vector.
Return type: Examples
>>> cartesian_basis_vector(1) array([0., 1., 0.])
-
dual_basis
(basis)[source]¶ Compute the dual basis of a given basis, i.e., the basis \(e^i\) such that \(\langle e_i, e^j \rangle = \delta_i^j\).
Parameters: basis – Basis (square matrix with basis vectors as columns). Returns: Dual basis (square matrix with dual basis vectors as columns).
-
gram_schmidt_orthonormalization
(basis, inner_product=<function dot>)[source]¶ Create an orthonormal basis for an inner product space V from a general basis using the Gram-Schmidt process.
Parameters: - basis – Input array of basis vectors.
- inner_product – Inner product for the inner product space (a map \(V \times V \to \mathbb{R}\) satisfying the inner product properties).
Returns: Orthonormal basis (matrix with the basis vectors as columns), where the basis vectors is obtained by Gram-Schmidt orthonormalization of the input basis vectors.
-
gram_schmidt_orthonormalization_rn
(basis)[source]¶ Create an orthonormal basis from a general basis of \(\mathbb{R}^n\) or an n dimensional subspace of \(\mathbb{R}^m\) using the Gram-Schmidt process.
Parameters: basis ( Numpy array
) – Input basis (m by n matrix with the basis vectors as columns).Returns: Orthonormal basis (m by n matrix with the basis vectors as columns), where the basis vectors is obtained by Gram-Schmidt orthonormalization of the input basis vectors. Return type: Numpy array
-
inverse_metric_tensor
(basis)[source]¶ Compute the inverse metric tensor for a basis.
Parameters: basis – Basis (square matrix with basis vectors as columns). Returns: Inverse metric tensor.
-
metric_tensor
(basis)[source]¶ Compute the metric tensor for a basis.
Parameters: basis – Basis (square matrix with basis vectors as columns). Returns: Metric tensor.
-
transform
(v, basis0, basis1)[source]¶ Transform a vector or set of vectors from one basis to another.
Parameters: - v – Representation of the vector(s) in the initial basis (vector or matrix with vectors as columns).
- basis0 – Initial basis to transform from (matrix with basis vectors as columns).
- basis1 – Final basis to transform to (matrix with basis vectors as columns).
Returns: Representation of the vector(s) in the final basis.
-
transform_bilinear_form
(b, basis0, basis1)[source]¶ Transform a bilinear form (matrix) from one basis to another.
Parameters: - b – Representation of the bilinear form in the initial basis (n by n matrix).
- basis0 – Initial basis to transform from (matrix with basis vectors as columns).
- basis1 – Final basis to transform to (matrix with basis vectors as columns).
Returns: Representation of the bilinear form in the final basis (n by n matrix).
-
transform_from_basis
(v, basis)[source]¶ Transform a vector or set of vectors in a given coordinate system to Cartesian coordinates.
Parameters: - v – Vector(s) expressed in the supplied basis (vector or matrix with vectors as columns).
- basis – Basis the vector is expressed in (matrix with basis vectors as columns).
Returns: Vector(s) in Cartesian coordinates.
-
transform_to_basis
(v, basis)[source]¶ Transform a vector or set of vectors from Cartesian coordinates to the supplied coordinate system.
Parameters: - v – Vector(s) expressed in Cartesian coordinates (vector or matrix with vectors as columns).
- basis – Basis to express the vector in (matrix with basis vectors as columns).
Returns: Vector representation(s) in the supplied basis.