akreon-linalg
Fixed-size linear algebra and numerical methods in C++26.
Loading...
Searching...
No Matches
linalg Namespace Reference

Classes

struct  Cholesky
 Factors a real positive-definite matrix as A = G G^T. More...
 
struct  coordinate_map
 Customization point mapping space elements to finite coordinates. More...
 
struct  coordinate_map< CoordinateSpace< T, Dim > >
 Identity coordinate map for CoordinateSpace. More...
 
struct  coordinate_map< Matrix< T, Rows, Cols > >
 Identity coordinate map for one-row or one-column matrices. More...
 
struct  coordinate_map< MatrixSpace< T, Rows, Cols > >
 Row-major coordinate isomorphism for MatrixSpace. More...
 
struct  coordinate_map< SymmetricMatrix< Mat > >
 
struct  coordinate_map< SymmetricMatrixSpace< T, Dim > >
 Symmetric half-vectorization coordinate isomorphism. More...
 
struct  CoordinateSpace
 Canonical Dim-dimensional coordinate space over field T. More...
 
struct  EigenDecomposition
 Computes eigenvalues and eigenvectors satisfying A V = V diag(lambda). More...
 
struct  Endomorphism
 Endomorphism operator CRTP base. More...
 
struct  Fro
 compute the frobenius norm of a matrix More...
 
struct  Hessenberg
 Reduces A to upper Hessenberg form H = U^* A U. More...
 
struct  Hessian
 Hessian as a linear operator. More...
 
struct  HouseholderVector
 Compact representation of a real or complex Householder reflector. More...
 
struct  inner_product_traits
 Customization point for inner-product associated types. More...
 
struct  inner_product_traits< StandardInnerProduct< Vec > >
 Associated-type registration for StandardInnerProduct. More...
 
struct  is_symmetric_matrix_space
 symmetric matrix space type trait More...
 
struct  is_symmetric_matrix_space< SymmetricMatrix< Mat > >
 symmetric matrix space type trait More...
 
struct  L1
 forward declaration for L1 norm More...
 
struct  L2
 forward declaration for L2 norm More...
 
struct  LDL
 Factors a real symmetric matrix as A = L D L^T without pivoting. More...
 
struct  Linf
 forward declaration for Linf norm More...
 
struct  mat_traits
 Customization point for compile-time matrix metadata. More...
 
struct  mat_traits< Cholesky< Mat > >
 mat type traits definition for Cholesky More...
 
struct  mat_traits< Endomorphism< Mat, Derived > >
 mat type traits definition for linear operator More...
 
struct  mat_traits< Hessenberg< Mat > >
 mat type traits definition for hessenberg matrices More...
 
struct  mat_traits< Hessian< Mat, Type > >
 mat type traits definition for hessian matrices More...
 
struct  mat_traits< LDL< Mat > >
 mat type traits definition for LDL More...
 
struct  mat_traits< Matrix< T, Rows, Cols > >
 Traits for the Akreon Linalg's owning Matrix container. More...
 
struct  mat_traits< QuadraticRep< Mat, Circ > >
 mat type traits definition for P(x) More...
 
struct  mat_traits< SymmetricMatrix< Mat > >
 mat type traits definition for symmetric matrices More...
 
struct  mat_traits< SymmetricOperator< Mat, Derived > >
 mat type traits definition for symmetric operator More...
 
struct  Matrix
 Owning, fixed-size, row-major matrix container over a scalar field. More...
 
struct  MatrixInverse
 Matrix inverse via QR. More...
 
struct  MatrixPencil
 
struct  MatrixSpace
 Space of all Rows x Cols matrices over field T. More...
 
struct  MatrixSqrt
 Matrix sqrt (X^{1/2}) More...
 
struct  norm_traits
 declaring norm traits More...
 
struct  norm_traits< Fro< Mat > >
 
struct  norm_traits< L1< Vec > >
 declaring norm type traits - L1 More...
 
struct  norm_traits< L2< Vec > >
 declaring norm type traits - L2 More...
 
struct  norm_traits< Linf< Vec > >
 declaring norm type traits - Linf More...
 
struct  operator_traits
 
struct  operator_traits< Matrix< T, Rows, Cols > >
 
struct  operator_traits< Operator >
 
struct  QR
 Factors A = Q R using Householder reflections. More...
 
struct  QuadraticRep
 forward declaration of P(x) / P(x^{-1}) More...
 
struct  scalar_traits
 Customization point for scalar metadata. More...
 
struct  scalar_traits< std::complex< T > >
 Register std::complex<T> over a floating-point real component. More...
 
struct  scalar_traits< T >
 Register a standard floating-point type as a real scalar. More...
 
struct  space_traits
 Customization point for finite-dimensional space metadata. More...
 
struct  space_traits< ColVector< T, Dim > >
 Space registration for a matrix-shaped column vector. More...
 
struct  space_traits< CoordinateSpace< T, Dim > >
 Space metadata for CoordinateSpace. More...
 
struct  space_traits< Matrix< T, 1, 1 > >
 Space registration for a scalar-shaped 1 x 1 matrix. More...
 
struct  space_traits< Matrix< T, Rows, Cols > >
 Space registration for a general rectangular matrix container. More...
 
struct  space_traits< MatrixSpace< T, Rows, Cols > >
 Space metadata for the full rectangular matrix space. More...
 
struct  space_traits< RowVector< T, Dim > >
 Space registration for a matrix-shaped row vector. More...
 
struct  space_traits< SymmetricMatrix< Mat > >
 type traits definition for symmetric matrices (subspace of R^n) More...
 
struct  space_traits< SymmetricMatrixSpace< T, Dim > >
 Space metadata for real symmetric matrices. More...
 
struct  StandardInnerProduct
 Canonical inner product on a fixed-size vector over a scalar field. More...
 
struct  SVD
 Computes A = U Sigma V^* from the eigendecomposition of A^* A. More...
 
struct  SymmetricMatrix
 forward declaration for a matrix More...
 
struct  SymmetricMatrixInverse
 Symmetric matrix inverse via LDL^T. More...
 
struct  SymmetricMatrixSpace
 Space of real symmetric Dim x Dim matrices. More...
 
struct  SymmetricOperator
 forward declaration for symmetric operator More...
 
struct  Vector
 Owning, fixed-size vector container. More...
 
struct  vector_scalar
 Recursively obtain the non-vector scalar underlying a type. More...
 
struct  vector_scalar< Vector< T, Dim > >
 Recursively unwrap one Vector layer. More...
 
struct  vector_traits
 Customization point for fixed-size vector metadata. More...
 
struct  vector_traits< Cholesky< Mat > >
 vec type traits for cholesky matrices More...
 
struct  vector_traits< Endomorphism< Mat, Derived > >
 vec type traits for linear operator More...
 
struct  vector_traits< Hessenberg< Mat > >
 vec type traits for hessenberg matrices More...
 
struct  vector_traits< Hessian< Mat, Type > >
 vec type traits for hessian matrices More...
 
struct  vector_traits< LDL< Mat > >
 vec type traits for LDL matrices More...
 
struct  vector_traits< QuadraticRep< Mat, Circ > >
 vec type traits for quadratic rep matrices More...
 
struct  vector_traits< SymmetricMatrix< Mat > >
 vec type traits for symmetric matrices More...
 
struct  vector_traits< SymmetricOperator< Mat, Derived > >
 vec type traits for symmetric operator More...
 
struct  vector_traits< Vector< T, Dim > >
 Traits and constexpr construction helpers for Vector<T, Dim>. More...
 

Concepts

concept  MatrixContainer
 Trait-registered, fixed-shape matrix over a supported scalar field.
 
concept  SquareMatrix
 Matrix container whose compile-time row and column counts are equal.
 
concept  RealMatrix
 Matrix container with a real scalar field.
 
concept  ComplexMatrix
 Matrix container with a complex scalar field.
 
concept  MatVecCompatible
 Compile-time compatibility contract for matrix-vector multiplication.
 
concept  MatMulCompatible
 Compile-time compatibility contract for matrix multiplication.
 
concept  NormFunction
 concept for norm like
 
concept  InnerProduct
 Callable contract for a trait-registered inner-product operation.
 
concept  LinearOperator
 
concept  EndomorphicOperator
 
concept  Scalar
 Type registered with the Akreon Linalg scalar trait system.
 
concept  Field
 Registered scalar supporting the Akreon Linalg's field arithmetic interface.
 
concept  Real
 Field classified by scalar_traits as real.
 
concept  Complex
 Field classified by scalar_traits as complex.
 
concept  Space
 Trait-registered finite-dimensional mathematical space.
 
concept  CoordinatizedSpace
 Finite-dimensional space with explicit element-coordinate conversion.
 
concept  VectorSpace
 Legacy vector-space expression contract for a registered space.
 
concept  RnSpace
 Real, coordinatized space satisfying the vector-space expressions.
 
concept  VectorContainer
 Trait-registered fixed-size vector container.
 
concept  FieldVector
 Registered vector whose element type satisfies Field.
 
concept  RealVector
 Field vector over a scalar classified as real.
 
concept  ComplexVector
 Field vector over a scalar classified as complex.
 
concept  CompatibleVectors
 Pair of vectors with exactly matching element types and dimensions.
 

Typedefs

template<typename T , std::size_t Dim>
using ColVector = Matrix< T, Dim, 1 >
 Matrix-shaped representation of a Dim-element column vector.
 
template<typename T , std::size_t Dim>
using RowVector = Matrix< T, 1, Dim >
 Matrix-shaped representation of a Dim-element row vector.
 
template<class Mat >
using matrix_scalar_t = typename mat_traits< remove_cvref_t< Mat > >::value_type
 Registered matrix scalar type after cv/ref normalization.
 
template<class Norm >
using norm_traits_t = norm_traits< remove_cvref_t< Norm > >
 normalized norm traits
 
template<class Norm >
using norm_domain_t = typename norm_traits_t< Norm >::domain_type
 
template<class Norm >
using norm_scalar_t = typename norm_traits_t< Norm >::scalar_type
 
template<class Norm >
using norm_codomain_t = typename norm_traits_t< Norm >::codomain_type
 
template<class Product >
using inner_product_traits_t = inner_product_traits< remove_cvref_t< Product > >
 Normalized trait specialization for an inner-product type.
 
template<class Product >
using inner_product_domain_t = typename inner_product_traits_t< Product >::domain_type
 Registered vector domain after product cv/ref normalization.
 
template<class Product >
using inner_product_scalar_t = typename inner_product_traits_t< Product >::scalar_type
 Registered scalar field associated with the product domain.
 
template<class Product >
using inner_product_codomain_t = typename inner_product_traits_t< Product >::codomain_type
 Registered result type of the inner product.
 
template<class Operator >
using operator_traits_t = operator_traits< remove_cvref_t< Operator > >
 
template<class Operator >
using operator_scalar_t = typename operator_traits_t< Operator >::scalar_type
 
template<class Operator >
using operator_domain_t = typename operator_traits_t< Operator >::domain_type
 
template<class Operator >
using operator_codomain_t = typename operator_traits_t< Operator >::codomain_type
 
template<class Operator >
using operator_matrix_t = typename operator_traits_t< Operator >::matrix_type
 
template<typename T >
using remove_cvref_t = std::remove_cvref_t< T >
 Remove top-level const, volatile, and reference qualification.
 
template<typename T >
using scalar_traits_t = scalar_traits< remove_cvref_t< T > >
 Scalar traits selected after cv/ref normalization.
 
template<typename T >
using scalar_type_t = typename scalar_traits_t< T >::scalar_type
 Normalized scalar representation registered for T.
 
template<typename T >
using real_type_t = typename scalar_traits_t< T >::real_type
 Associated real component type registered for T.
 
template<class Space >
using coordinate_map_t = coordinate_map< remove_cvref_t< Space > >
 Coordinate-map specialization selected after cv/ref normalization.
 
template<class Space >
using space_type_t = typename space_traits< remove_cvref_t< Space > >::value_type
 Legacy scalar-field alias after cv/ref normalization.
 
template<class Space >
using space_point_t = typename space_traits< remove_cvref_t< Space > >::Point
 Legacy point/domain alias after cv/ref normalization.
 
template<class Space >
using space_scalar_t = typename space_traits< remove_cvref_t< Space > >::scalar_type
 Scalar field registered for a space.
 
template<class Space >
using space_element_t = typename space_traits< remove_cvref_t< Space > >::element_type
 Canonical element representation registered for a space.
 
template<class Space >
using space_coordinate_t = typename space_traits< remove_cvref_t< Space > >::coordinate_type
 Finite coordinate representation registered for a space.
 
template<class Vec >
using vector_traits_t = vector_traits< remove_cvref_t< Vec > >
 Vector traits selected after cv/ref normalization.
 
template<class Vec >
using vector_element_t = typename vector_traits_t< Vec >::element_type
 Registered vector coordinate type.
 
template<class Vec >
using vector_scalar_t = typename vector_scalar< remove_cvref_t< Vec > >::type
 Fully unwrapped scalar type underlying a possibly nested vector.
 
Common scalar and matrix aliases

These aliases shorten frequently used real and complex fixed-size types.

ColVector* and RowVector* remain matrices; Vector* names the dedicated vector container.

template<std::size_t Dim>
using Vectord = Vector< double, Dim >
 
template<std::size_t Dim>
using Vectorf = Vector< float, Dim >
 
template<std::size_t Dim>
using Vectorcd = Vector< std::complex< double >, Dim >
 
template<std::size_t Dim>
using Vectorcf = Vector< std::complex< float >, Dim >
 
template<std::size_t Rows, std::size_t Cols>
using Matrixd = Matrix< double, Rows, Cols >
 
template<std::size_t Dim>
using ColVectord = ColVector< double, Dim >
 
template<std::size_t Dim>
using RowVectord = RowVector< double, Dim >
 
template<std::size_t Rows, std::size_t Cols>
using Matrixf = Matrix< float, Rows, Cols >
 
template<std::size_t Dim>
using ColVectorf = ColVector< float, Dim >
 
template<std::size_t Dim>
using RowVectorf = RowVector< float, Dim >
 
template<std::size_t Rows, std::size_t Cols>
using Matrixcd = Matrix< std::complex< double >, Rows, Cols >
 
template<std::size_t Dim>
using ColVectorcd = ColVector< std::complex< double >, Dim >
 
template<std::size_t Dim>
using RowVectorcd = RowVector< std::complex< double >, Dim >
 
template<std::size_t Rows, std::size_t Cols>
using Matrixcf = Matrix< std::complex< float >, Rows, Cols >
 
template<std::size_t Dim>
using ColVectorcf = ColVector< std::complex< float >, Dim >
 
template<std::size_t Dim>
using RowVectorcf = RowVector< std::complex< float >, Dim >
 

Enumerations

enum struct  NumericalEvent : uint8_t {
  NONE = 0 , RANK_DEFICIENCY , INDEFINITE_FACTORIZATION , NEAR_SINGULAR_TRIANGULAR_SOLVE ,
  NUMERICAL_SAFEGUARD , DB_MAX_ITERS_REACHED , FACTORIZATION_FAILED , EVD_FAILED
}
 NumericalEvent. More...
 
enum struct  SymmetricOperatorType {
  INV = 0 , IND , PSD , PD ,
  NSD , ND
}
 simple enum to define symmetric matrix types INV = Invalid IND = Indefinite PSD = Positive Semidefinite PD = Positive Definite NSD = Negative Semidefinite ND = Negative Definite More...
 
enum struct  DifferentialType { PUSHFORWARD , PULLBACK }
 differential type More...
 

Functions

template<VectorContainer Vec>
constexpr auto add (const Vec &A, const Vec &B)
 add two vectors together to get a third
 
template<VectorContainer Vec>
constexpr auto operator+ (const Vec &A, const Vec &B)
 operator overload for add
 
template<MatrixContainer Mat>
constexpr auto add (const Mat &A, const Mat &B)
 Add two shape-compatible matrices element by element.
 
template<MatrixContainer Mat>
constexpr auto operator+ (const Mat &A, const Mat &B)
 Matrix addition operator delegating to add.
 
template<VectorContainer Vec, Field Alpha>
constexpr auto scalar_multiplication (const Alpha &alpha, const Vec &A)
 multiply a vector A with a scalar alpha
 
template<VectorContainer Vec, Field Alpha>
constexpr auto operator* (const Alpha &alpha, const Vec &A)
 operator overload for scalar multiplication
 
template<MatrixContainer Mat, Field Alpha>
constexpr auto scalar_multiplication (const Alpha &alpha, const Mat &A)
 Multiply every matrix entry by a field scalar.
 
template<MatrixContainer Mat, Field Alpha>
constexpr auto operator* (const Alpha &alpha, const Mat &A)
 Left scalar-matrix multiplication operator.
 
template<VectorContainer Vec>
constexpr auto operator- (const Vec &A, const Vec &B)
 operator overload for subtraction
 
template<MatrixContainer Mat>
constexpr auto operator- (const Mat &A, const Mat &B)
 Subtract two matrices as A + (-1) * B.
 
template<FieldVector Vec>
constexpr auto transpose (const Vec &x)
 tranpose of a vector
 
template<ComplexVector Vec>
constexpr auto conjugate (const Vec &x)
 conjugate a vector
 
template<FieldVector Vec>
requires (vector_dim_v<Vec> == 3)
constexpr auto cross (const Vec &x, const Vec &y)
 cross product between x x y = Z
 
template<FieldVector Vec>
requires (vector_dim_v<Vec> > 0)
constexpr bool all_zero (const Vec &x)
 simple function that checks if a vector contains only zeros (hence spans nullspace)
 
template<std::size_t idx, FieldVector Vec>
requires (vector_dim_v<Vec> > 0 && idx < vector_dim_v<Vec>)
constexpr auto splice (const Vec &x)
 splice operator
 
template<MatrixContainer MatA, MatrixContainer MatB>
requires (MatMulCompatible<MatA, MatB>)
constexpr auto outer_product (const MatA &A, const MatB &B)
 Multiply matrix-shaped column and row operands as an outer product.
 
template<MatrixContainer Mat>
constexpr auto transpose (const Mat &A)
 transpose of a matrix
 
template<SquareMatrix Mat>
requires (mat_rows_v<Mat> > 0)
constexpr auto trace (const Mat &A)
 trace of a matrix
 
template<MatrixContainer Mat>
requires (Complex<matrix_scalar_t<Mat>>)
constexpr auto conjugate_transpose (const Mat &A)
 conjugate transpose of a matrix
 
template<MatrixContainer MatA, MatrixContainer MatB>
requires (MatMulCompatible<MatA, MatB>)
constexpr auto operator* (const MatA &A, const MatB &B)
 Multiply compatible matrices with the standard row-column product.
 
template<MatrixContainer Mat, VectorContainer Vec>
requires (MatVecCompatible<Mat, Vec>)
constexpr auto operator* (const Mat &A, const Vec &X)
 Apply a compatible matrix to a vector.
 
template<VectorContainer Vec>
requires (vector_dim_v<Vec> > 0)
constexpr auto min (const Vec &x)
 min element
 
template<VectorContainer Vec>
requires (vector_dim_v<Vec> > 0)
constexpr auto max (const Vec &x)
 max element
 
template<VectorContainer Vec>
requires (vector_dim_v<Vec> > 0)
constexpr std::size_t arg_min (const Vec &x)
 min element
 
template<VectorContainer Vec>
requires (vector_dim_v<Vec> > 0)
constexpr std::size_t arg_max (const Vec &x)
 max element
 
template<std::size_t Start, std::size_t End, VectorContainer Vec>
requires (End - Start < vector_dim_v<Vec> && Start < vector_dim_v<Vec>)
constexpr auto get_elements (const Vec &x)
 Copy the half-open vector slice [Start, End).
 
template<Field T, std::size_t N>
constexpr Matrix< T, N, N > make_identity ()
 create an identity matrix of size N type T
 
template<Field T, std::size_t Rows, std::size_t Cols>
constexpr Matrix< T, Rows, Cols > make_zeros ()
 create a matrix filled with zeros of size Rows x Cols of type T
 
template<VectorContainer Vec>
constexpr auto as_col_vector (const Vec &X)
 express the vector X as a column vector (N x 1)
 
template<VectorContainer Vec>
constexpr auto as_row_vector (const Vec &X)
 express the vector X as a row vector (1 x N)
 
template<MatrixContainer Mat>
constexpr auto as_complex_matrix (const Mat &A)
 express matrix as complex one
 
template<Field T, std::size_t N>
constexpr auto as_vector (const ColVector< T, N > &A)
 express col vector as vector
 
template<Field T, std::size_t N>
constexpr auto as_vector (const RowVector< T, N > &A)
 express row vector as vector
 
template<MatrixContainer Mat>
constexpr auto get_col (const Mat &A, std::size_t idx)
 get the column of matrix A based on given index
 
template<MatrixContainer Mat>
constexpr auto get_row (const Mat &A, std::size_t idx)
 get the row of matrix A based on given index
 
template<MatrixContainer Mat>
constexpr auto get_diag (const Mat &A)
 get the diagonal of a matrix A
 
template<Field T, std::size_t N>
constexpr auto make_diag (const Vector< T, N > &X)
 make a diagonal matrix from a vector
 
template<std::size_t Start, std::size_t End, MatrixContainer Mat>
requires (End - Start <= mat_rows_v<Mat> && Start < mat_rows_v<Mat>)
constexpr auto get_n_rows (const Mat &A)
 Copy the half-open matrix row range [Start, End).
 
template<std::size_t Start, std::size_t End, MatrixContainer Mat>
requires (End - Start <= mat_cols_v<Mat> && Start < mat_cols_v<Mat>)
constexpr auto get_n_cols (const Mat &A)
 Copy the half-open matrix column range [Start, End).
 
template<std::size_t StartRow, std::size_t EndRow, std::size_t StartCol, std::size_t EndCol, MatrixContainer Mat>
requires (EndRow - StartRow <= mat_rows_v<Mat> && StartRow < mat_rows_v<Mat> && EndCol - StartCol <= mat_cols_v<Mat> && StartCol < mat_cols_v<Mat>)
constexpr auto get_block (const Mat &A)
 Copy a compile-time rectangular matrix block.
 
template<std::size_t StartRow, std::size_t EndRow, std::size_t StartCol, std::size_t EndCol, MatrixContainer Mat>
requires (EndRow - StartRow <= mat_rows_v<Mat> && StartRow < mat_rows_v<Mat> && EndCol - StartCol <= mat_cols_v<Mat> && StartCol < mat_cols_v<Mat>)
constexpr auto set_block (Mat A, const Matrix< matrix_scalar_t< Mat >, EndRow - StartRow, EndCol - StartCol > &B)
 Return a matrix copy with one compile-time block replaced.
 
template<MatrixContainer Mat>
constexpr auto get_upper_right_triangular_matrix (const Mat &A)
 get upper right triangular matrix from A
 
template<MatrixContainer Mat>
constexpr auto get_lower_left_triangular_matrix (const Mat &A)
 get lower left triangular matrix from A
 
template<VectorContainer Vec>
constexpr auto euclidean_distance (const Vec &X, const Vec &Y)
 Compute the euclidean distance between two vectors (L2 norm of delta)
 
template<VectorContainer Vec>
constexpr auto manhattan_distance (const Vec &X, const Vec &Y)
 Compute the manhattan distance between two vectors (L1 norm of delta)
 
template<FieldVector Vec>
constexpr bool all_equal (const Vec &X, const Vec &Y, real_type_t< vector_element_t< Vec > > tol=1e-10)
 checks if two vectors are equivalent to a given tolerance (different than == operator on vector which must be exactly equal
 
template<Field T, std::size_t Rows, std::size_t Cols>
constexpr bool all_equal (const Matrix< T, Rows, Cols > &A, const Matrix< T, Rows, Cols > &B, real_type_t< T > tol=1e-10)
 checks if two given matrix are equivalent
 
template<MatrixContainer MatA, MatrixContainer MatB>
requires (std::same_as<matrix_scalar_t<MatA>, matrix_scalar_t<MatB>> && mat_rows_v<MatA> == mat_cols_v<MatB> && mat_cols_v<MatA> == mat_rows_v<MatB>)
constexpr bool rows_equal_cols (const MatA &A, const MatB &B)
 checks if the row space of one matrix is equivalent to the column space of another matrix
 
template<std::size_t N, FieldVector Vec>
requires (vector_dim_v<Vec> == N * (N + 1) / 2)
constexpr auto make_smat (const Vec &L)
 make symmetric matrix
 
template<SquareMatrix Mat>
constexpr auto get_lower_triangle_with_diag (const Mat &A)
 get lower triangle with diag
 
template<SquareMatrix Mat>
constexpr auto get_svec (const Mat &A)
 get svec encoding of a symmetric matrix
 
template<SquareMatrix Mat>
constexpr auto make_svec (const Mat &A)
 Compatibility spelling for get_svec(A).
 
template<SquareMatrix Mat>
constexpr auto symmetric_part (const Mat &A)
 symmetric part of a square matrix
 
template<SquareMatrix Mat>
constexpr auto get_lower_triangle (const Mat &A)
 get lower triangle
 
template<SquareMatrix Mat, VectorContainer Vec>
requires (std::same_as<matrix_scalar_t<Mat>, vector_element_t<Vec>>)
constexpr auto make_unit_lower_triangle (const Vec &x)
 Construct a unit lower-triangular matrix from strict-lower entries.
 
template<SquareMatrix Mat, VectorContainer Vec>
requires (std::same_as<matrix_scalar_t<Mat>, vector_element_t<Vec>>)
constexpr auto make_lower_triangle (const Vec &x)
 Construct a lower-triangular matrix including its diagonal.
 
template<Field T, std::size_t Cols, typename... Rows>
 Matrix (Vector< T, Cols >, Rows...) -> Matrix< T, 1+sizeof...(Rows), Cols >
 Deduce matrix scalar type and shape from one or more row vectors.
 
template<Field T, std::size_t Dim>
constexpr auto as_row_matrix (const Vector< T, Dim > &vector)
 Represent a vector as a 1 x Dim matrix.
 
template<Field T, std::size_t Dim>
constexpr auto as_col_matrix (const Vector< T, Dim > &vector)
 Represent a vector as a Dim x 1 matrix.
 
template<Field T, std::size_t Rows, std::size_t Cols>
requires (Rows == 1 || Cols == 1)
constexpr auto as_vector (const Matrix< T, Rows, Cols > &matrix)
 Convert a one-row or one-column matrix to a vector.
 
constexpr bool is_fatal_event (NumericalEvent event)
 is_fatal_event
 
template<FieldVector Vec>
constexpr auto inner_product (const Vec &lhs, const Vec &rhs)
 Evaluate the canonical inner product for two field vectors.
 
template<MatrixContainer Mat>
constexpr auto apply (const Mat &matrix, const operator_domain_t< Mat > &vector) -> operator_codomain_t< Mat >
 
template<class Space >
constexpr auto coordinates (const space_element_t< Space > &element)
 Convert a registered space element to its coordinate representation.
 
template<class Space >
constexpr auto from_coordinates (const space_coordinate_t< Space > &coordinate)
 Reconstruct a registered space element from its coordinates.
 
template<VectorContainer Vec>
requires (Complex<vector_element_t<Vec>>)
constexpr auto make_group_permutation (const Vec &D, real_type_t< vector_element_t< Vec > > tol=1e-10)
 Group approximately equal eigenvalues into contiguous index runs.
 
template<std::size_t N>
constexpr auto invert_permutation (const Vector< std::size_t, N > &p)
 Invert an index permutation.
 
template<MatrixContainer Mat>
constexpr auto permute_ptjp (const Mat &J, const Vector< std::size_t, mat_rows_v< Mat > > &p)
 Reorder matrix rows and columns by the same permutation.
 
template<MatrixContainer Mat>
constexpr auto unpermute_papt (const Mat &A, const Vector< std::size_t, mat_rows_v< Mat > > &p)
 Scatter matrix entries through a row-and-column permutation.
 
template<SquareMatrix Mat>
constexpr auto matrix_exp (const Mat &A)
 Compute exp(A) using its eigenvector and generalized-eigenvector basis.
 
template<typename T , std::size_t N>
constexpr auto array_to_tuple (const std::array< T, N > &x)
 Copy a fixed-size array into a tuple of the same length.
 
template<Field T>
constexpr bool is_real (const std::complex< T > &z, real_type_t< T > tol=1e-10)
 Check whether a complex value's imaginary component is below a bound.
 
template<Real T>
constexpr std::optional< T > constexpr_div (T num, T den)
 Divide two real scalars with an explicit zero-denominator result.
 
template<Real T>
constexpr T constexpr_div_safe (T num, T den, T fallback=T(0))
 Divide two real scalars, returning a fallback for a zero denominator.
 
template<Real T>
constexpr T constexpr_pow (T x, std::size_t power)
 Raise a real scalar to a nonnegative integral power.
 
template<Real T>
constexpr std::optional< T > constexpr_sqrt (T x, T g=1e-10, T tol=1e-10)
 Approximate a nonnegative square root with Newton iteration.
 
template<Real T>
constexpr T constexpr_sqrt_safe (T x, T floor=T(0), T g=1e-10, T tol=1e-10)
 Return a scalar square root with a sanitized fallback radicand.
 
template<Real T>
constexpr T constexpr_abs (T x)
 Compute real absolute value or complex magnitude.
 
template<Complex T>
constexpr auto constexpr_abs (const T &x)
 
template<Real T>
constexpr std::optional< T > constexpr_nrt (T x, std::size_t root, T g=1e-10, T tol=1e-10)
 Approximate a real nth root with Newton iteration.
 
template<Real T>
constexpr T constexpr_nrt_safe (T x, std::size_t root, T floor=T(0), T g=1e-10, T tol=1e-10)
 Return a scalar nth root with a sanitized fallback radicand.
 
template<Real T>
constexpr auto constexpr_sin (T x, int terms=16)
 Approximate sine with a truncated Taylor recurrence.
 
template<Real T>
constexpr auto constexpr_cos (T x, int terms=16)
 Approximate cosine with a truncated Taylor recurrence.
 
template<Real T>
constexpr std::optional< T > constexpr_atanh (T x, int terms=16)
 atanh (inverse hyperbolic tangent function)
 
template<Real T>
constexpr T constexpr_atanh_safe (T x, T fallback=T(0), int terms=16)
 constexpr-safe atanh with fallback
 
template<Real T>
constexpr auto constexpr_expi (T theta, int terms=16)
 Approximate exp(i * theta) on the complex unit circle.
 
template<Real T>
constexpr auto constexpr_exp (T x, int terms=16)
 Approximate the real exponential with a truncated power series.
 
template<Complex T>
constexpr auto constexpr_exp_lambda (const T &lambda, int terms=16)
 Approximate the exponential of a complex scalar.
 
template<Real T>
constexpr std::optional< T > constexpr_ln (T x_in, int terms=16)
 natural log
 
template<Real T>
constexpr T constexpr_ln_safe (T x, T floor=std::numeric_limits< T >::min(), int terms=16)
 natural log with domain sanitization and fallback
 
template<std::size_t Start, std::size_t End, typename Func >
requires (End - Start >= 0)
constexpr void constexpr_for (Func &&f)
 constexpr for loop which recursively unrolls a dynamic for loop into compile time recursive loop
 
template<Complex T>
constexpr bool is_same (const T &a, const T &b, real_type_t< T > tol=1e-10)
 Compare complex scalars by magnitude of their difference.
 
template<VectorContainer Vec>
requires (Real<vector_element_t<Vec>>)
constexpr auto argsort_desc (const Vec &x)
 Return coordinate indices sorted by descending real value.
 
template<typename T , typename... Ts>
 Vector (T, Ts...) -> Vector< std::common_type_t< T, Ts... >, 1+sizeof...(Ts)>
 Deduce coordinate type and dimension from constructor arguments.
 

Variables

template<Field T>
constexpr T sqrt2_v {T(1.414213562373095048801688724209698079L)}
 
template<Field T>
constexpr T inv_sqrt2_v {T(1) / sqrt2_v<T>}
 
template<Field T>
constexpr T ln2_v {T(0.693147180559945309417232121458176568L)}
 
template<class Mat >
constexpr std::size_t mat_rows_v = mat_traits<remove_cvref_t<Mat>>::ROWS
 Registered compile-time row count after cv/ref normalization.
 
template<class Mat >
constexpr std::size_t mat_cols_v = mat_traits<remove_cvref_t<Mat>>::COLS
 Registered compile-time column count after cv/ref normalization.
 
template<class Norm >
constexpr std::size_t norm_dim_v = norm_traits_t<Norm>::dim
 
template<class Norm >
constexpr bool is_norm_v = norm_traits<remove_cvref_t<Norm>>{}
 helper for is norm type
 
template<typename Space >
constexpr bool is_symmetric_matrix_space_v
 symmetric matrix space type trait var
 
template<typename T >
constexpr bool is_real_v = scalar_traits_t<T>::is_real
 Whether normalized T is registered as a real scalar.
 
template<typename T >
constexpr bool is_complex_v = scalar_traits_t<T>::is_complex
 Whether normalized T is registered as a complex scalar.
 
template<class Space >
constexpr std::size_t space_dim_v
 Finite coordinate dimension after cv/ref normalization.
 
template<class Vec >
constexpr std::size_t vector_dim_v = vector_traits_t<Vec>::dim
 Registered compile-time vector dimension.
 

Typedef Documentation

◆ ColVector

template<typename T , std::size_t Dim>
using linalg::ColVector = typedef Matrix<T, Dim, 1>

Matrix-shaped representation of a Dim-element column vector.

Definition at line 18 of file matrix_traits.hpp.

◆ ColVectorcd

template<std::size_t Dim>
using linalg::ColVectorcd = typedef ColVector<std::complex<double>, Dim>

Definition at line 138 of file matrix_traits.hpp.

◆ ColVectorcf

template<std::size_t Dim>
using linalg::ColVectorcf = typedef ColVector<std::complex<float>, Dim>

Definition at line 147 of file matrix_traits.hpp.

◆ ColVectord

template<std::size_t Dim>
using linalg::ColVectord = typedef ColVector<double, Dim>

Definition at line 120 of file matrix_traits.hpp.

◆ ColVectorf

template<std::size_t Dim>
using linalg::ColVectorf = typedef ColVector<float, Dim>

Definition at line 129 of file matrix_traits.hpp.

◆ coordinate_map_t

Coordinate-map specialization selected after cv/ref normalization.

Definition at line 73 of file coordinate_map.hpp.

◆ inner_product_codomain_t

Registered result type of the inner product.

Definition at line 93 of file inner_product.hpp.

◆ inner_product_domain_t

Registered vector domain after product cv/ref normalization.

Definition at line 83 of file inner_product.hpp.

◆ inner_product_scalar_t

Registered scalar field associated with the product domain.

Definition at line 88 of file inner_product.hpp.

◆ inner_product_traits_t

Normalized trait specialization for an inner-product type.

Definition at line 79 of file inner_product.hpp.

◆ matrix_scalar_t

Registered matrix scalar type after cv/ref normalization.

Definition at line 87 of file matrix_traits.hpp.

◆ Matrixcd

template<std::size_t Rows, std::size_t Cols>
using linalg::Matrixcd = typedef Matrix<std::complex<double>, Rows, Cols>

Definition at line 135 of file matrix_traits.hpp.

◆ Matrixcf

template<std::size_t Rows, std::size_t Cols>
using linalg::Matrixcf = typedef Matrix<std::complex<float>, Rows, Cols>

Definition at line 144 of file matrix_traits.hpp.

◆ Matrixd

template<std::size_t Rows, std::size_t Cols>
using linalg::Matrixd = typedef Matrix<double, Rows, Cols>

Definition at line 117 of file matrix_traits.hpp.

◆ Matrixf

template<std::size_t Rows, std::size_t Cols>
using linalg::Matrixf = typedef Matrix<float, Rows, Cols>

Definition at line 126 of file matrix_traits.hpp.

◆ norm_codomain_t

Definition at line 64 of file norm_traits.hpp.

◆ norm_domain_t

Definition at line 58 of file norm_traits.hpp.

◆ norm_scalar_t

Definition at line 61 of file norm_traits.hpp.

◆ norm_traits_t

normalized norm traits

Definition at line 55 of file norm_traits.hpp.

◆ operator_codomain_t

◆ operator_domain_t

◆ operator_matrix_t

◆ operator_scalar_t

◆ operator_traits_t

◆ real_type_t

Associated real component type registered for T.

For example, both double and std::complex<double> have double as their real_type_t.

Definition at line 82 of file scalar_traits.hpp.

◆ remove_cvref_t

template<typename T >
using linalg::remove_cvref_t = typedef std::remove_cvref_t<T>

Remove top-level const, volatile, and reference qualification.

Public linalg traits normalize their lookup keys through this alias so a scalar and cv/ref-qualified views of that scalar share one specialization.

Definition at line 20 of file scalar_traits.hpp.

◆ RowVector

template<typename T , std::size_t Dim>
using linalg::RowVector = typedef Matrix<T, 1, Dim>

Matrix-shaped representation of a Dim-element row vector.

Definition at line 22 of file matrix_traits.hpp.

◆ RowVectorcd

template<std::size_t Dim>
using linalg::RowVectorcd = typedef RowVector<std::complex<double>, Dim>

Definition at line 141 of file matrix_traits.hpp.

◆ RowVectorcf

template<std::size_t Dim>
using linalg::RowVectorcf = typedef RowVector<std::complex<float>, Dim>

Definition at line 150 of file matrix_traits.hpp.

◆ RowVectord

template<std::size_t Dim>
using linalg::RowVectord = typedef RowVector<double, Dim>

Definition at line 123 of file matrix_traits.hpp.

◆ RowVectorf

template<std::size_t Dim>
using linalg::RowVectorf = typedef RowVector<float, Dim>

Definition at line 132 of file matrix_traits.hpp.

◆ scalar_traits_t

Scalar traits selected after cv/ref normalization.

Definition at line 69 of file scalar_traits.hpp.

◆ scalar_type_t

Normalized scalar representation registered for T.

Definition at line 73 of file scalar_traits.hpp.

◆ space_coordinate_t

template<class Space >
using linalg::space_coordinate_t = typedef typename space_traits<remove_cvref_t<Space> >::coordinate_type

Finite coordinate representation registered for a space.

Definition at line 106 of file space_traits.hpp.

◆ space_element_t

template<class Space >
using linalg::space_element_t = typedef typename space_traits<remove_cvref_t<Space> >::element_type

Canonical element representation registered for a space.

Definition at line 101 of file space_traits.hpp.

◆ space_point_t

Legacy point/domain alias after cv/ref normalization.

Definition at line 87 of file space_traits.hpp.

◆ space_scalar_t

template<class Space >
using linalg::space_scalar_t = typedef typename space_traits<remove_cvref_t<Space> >::scalar_type

Scalar field registered for a space.

Definition at line 96 of file space_traits.hpp.

◆ space_type_t

template<class Space >
using linalg::space_type_t = typedef typename space_traits<remove_cvref_t<Space> >::value_type

Legacy scalar-field alias after cv/ref normalization.

Definition at line 83 of file space_traits.hpp.

◆ vector_element_t

template<class Vec >
using linalg::vector_element_t = typedef typename vector_traits_t<Vec>::element_type

Registered vector coordinate type.

Definition at line 66 of file vector_traits.hpp.

◆ vector_scalar_t

Fully unwrapped scalar type underlying a possibly nested vector.

Definition at line 90 of file vector_traits.hpp.

◆ vector_traits_t

Vector traits selected after cv/ref normalization.

Definition at line 62 of file vector_traits.hpp.

◆ Vectorcd

template<std::size_t Dim>
using linalg::Vectorcd = typedef Vector<std::complex<double>, Dim>

Definition at line 111 of file matrix_traits.hpp.

◆ Vectorcf

template<std::size_t Dim>
using linalg::Vectorcf = typedef Vector<std::complex<float>, Dim>

Definition at line 114 of file matrix_traits.hpp.

◆ Vectord

template<std::size_t Dim>
using linalg::Vectord = typedef Vector<double, Dim>

Definition at line 105 of file matrix_traits.hpp.

◆ Vectorf

template<std::size_t Dim>
using linalg::Vectorf = typedef Vector<float, Dim>

Definition at line 108 of file matrix_traits.hpp.

Enumeration Type Documentation

◆ DifferentialType

differential type

Enumerator
PUSHFORWARD 
PULLBACK 

Definition at line 24 of file operator_traits.hpp.

◆ NumericalEvent

NumericalEvent.

Enumerator
NONE 
RANK_DEFICIENCY 
INDEFINITE_FACTORIZATION 
NEAR_SINGULAR_TRIANGULAR_SOLVE 
NUMERICAL_SAFEGUARD 
DB_MAX_ITERS_REACHED 
FACTORIZATION_FAILED 
EVD_FAILED 

Definition at line 26 of file numerical_config.hpp.

◆ SymmetricOperatorType

simple enum to define symmetric matrix types INV = Invalid IND = Indefinite PSD = Positive Semidefinite PD = Positive Definite NSD = Negative Semidefinite ND = Negative Definite

Enumerator
INV 
IND 
PSD 
PD 
NSD 
ND 

Definition at line 21 of file operator_traits.hpp.

Function Documentation

◆ add() [1/2]

template<MatrixContainer Mat>
constexpr auto linalg::add ( const Mat &  A,
const Mat &  B 
)
constexpr

Add two shape-compatible matrices element by element.

Parameters
ALeft matrix.
BRight matrix of the same registered type and shape.
Returns
Owning Matrix containing A(row,col) + B(row,col).

Definition at line 52 of file linalg_ops.hpp.

References mat_rows_v.

◆ add() [2/2]

template<VectorContainer Vec>
constexpr auto linalg::add ( const Vec &  A,
const Vec &  B 
)
constexpr

add two vectors together to get a third

A + B = C

Parameters
vectorA of type T with N elements
vectorB of type T with N elements
Returns
vector

Definition at line 25 of file linalg_ops.hpp.

References mat_rows_v.

Referenced by operator+(), and operator+().

◆ all_equal() [1/2]

template<Field T, std::size_t Rows, std::size_t Cols>
constexpr bool linalg::all_equal ( const Matrix< T, Rows, Cols > &  A,
const Matrix< T, Rows, Cols > &  B,
real_type_t< T >  tol = 1e-10 
)
constexpr

checks if two given matrix are equivalent

Parameters
matrixA of type T with Rows x Cols elements
vectorB of type T with Rows x Cols elements
toleranceset to 1e-10 by default
Returns
T/F

Definition at line 373 of file linalg_util.hpp.

References all_equal(), and mat_rows_v.

◆ all_equal() [2/2]

template<FieldVector Vec>
constexpr bool linalg::all_equal ( const Vec &  X,
const Vec &  Y,
real_type_t< vector_element_t< Vec > >  tol = 1e-10 
)
constexpr

checks if two vectors are equivalent to a given tolerance (different than == operator on vector which must be exactly equal

Parameters
vectorX of type T N elements
vectorY of type T N elements
Returns
T/F

Definition at line 358 of file linalg_util.hpp.

References euclidean_distance(), and mat_rows_v.

Referenced by all_equal(), and linalg::MatrixSqrt< MatIn >::apply().

◆ all_zero()

template<FieldVector Vec>
requires (vector_dim_v<Vec> > 0)
constexpr bool linalg::all_zero ( const Vec &  x)
constexpr

simple function that checks if a vector contains only zeros (hence spans nullspace)

Parameters
vectorof type T with N elements
Returns
T/F

Definition at line 199 of file linalg_ops.hpp.

References mat_rows_v.

◆ apply()

template<MatrixContainer Mat>
constexpr auto linalg::apply ( const Mat &  matrix,
const operator_domain_t< Mat > &  vector 
) -> operator_codomain_t<Mat>
constexpr

Definition at line 298 of file operator_traits.hpp.

References mat_rows_v.

◆ arg_max()

template<VectorContainer Vec>
requires (vector_dim_v<Vec> > 0)
constexpr std::size_t linalg::arg_max ( const Vec &  x)
constexpr

max element

Parameters
vectorx
Returns
max element

Definition at line 422 of file linalg_ops.hpp.

References mat_rows_v.

◆ arg_min()

template<VectorContainer Vec>
requires (vector_dim_v<Vec> > 0)
constexpr std::size_t linalg::arg_min ( const Vec &  x)
constexpr

min element

Parameters
vectorx
Returns
min element

Definition at line 403 of file linalg_ops.hpp.

References mat_rows_v.

◆ argsort_desc()

template<VectorContainer Vec>
requires (Real<vector_element_t<Vec>>)
constexpr auto linalg::argsort_desc ( const Vec &  x)
constexpr

Return coordinate indices sorted by descending real value.

Parameters
xFixed-size real vector.
Returns
std::array<std::size_t, N> containing a descending permutation.

Definition at line 540 of file algebra_util.hpp.

References mat_rows_v.

◆ array_to_tuple()

template<typename T , std::size_t N>
constexpr auto linalg::array_to_tuple ( const std::array< T, N > &  x)
constexpr

Copy a fixed-size array into a tuple of the same length.

Parameters
xSource array in index order.
Returns
Tuple containing x[0] through x[N - 1].

Definition at line 47 of file algebra_util.hpp.

References mat_rows_v.

◆ as_col_matrix()

template<Field T, std::size_t Dim>
constexpr auto linalg::as_col_matrix ( const Vector< T, Dim > &  vector)
constexpr

Represent a vector as a Dim x 1 matrix.

Definition at line 144 of file matrix.hpp.

References mat_rows_v.

◆ as_col_vector()

template<VectorContainer Vec>
constexpr auto linalg::as_col_vector ( const Vec &  X)
constexpr

express the vector X as a column vector (N x 1)

Parameters
vectorX of type T and N elements
Returns
(N x 1) matrix

Definition at line 66 of file linalg_util.hpp.

References mat_rows_v.

Referenced by linalg::Hessenberg< Mat >::Hessenberg(), and linalg::Hessenberg< Mat >::U().

◆ as_complex_matrix()

template<MatrixContainer Mat>
constexpr auto linalg::as_complex_matrix ( const Mat &  A)
constexpr

express matrix as complex one

Parameters
MatrixA type T with Rows x Cols elements
Returns
A in C

Definition at line 98 of file linalg_util.hpp.

References mat_rows_v.

Referenced by matrix_exp().

◆ as_row_matrix()

template<Field T, std::size_t Dim>
constexpr auto linalg::as_row_matrix ( const Vector< T, Dim > &  vector)
constexpr

Represent a vector as a 1 x Dim matrix.

Definition at line 138 of file matrix.hpp.

References mat_rows_v.

◆ as_row_vector()

template<VectorContainer Vec>
constexpr auto linalg::as_row_vector ( const Vec &  X)
constexpr

express the vector X as a row vector (1 x N)

Parameters
vectorX of type T and N elements
Returns
(1 x N) matrix

Definition at line 82 of file linalg_util.hpp.

References mat_rows_v.

◆ as_vector() [1/3]

template<Field T, std::size_t N>
constexpr auto linalg::as_vector ( const ColVector< T, N > &  A)
constexpr

express col vector as vector

Parameters
MatrixA type T with N x 1 elements
Returns
vector

Definition at line 121 of file linalg_util.hpp.

References mat_rows_v.

◆ as_vector() [2/3]

template<Field T, std::size_t Rows, std::size_t Cols>
requires (Rows == 1 || Cols == 1)
constexpr auto linalg::as_vector ( const Matrix< T, Rows, Cols > &  matrix)
constexpr

Convert a one-row or one-column matrix to a vector.

The element order follows the non-unit dimension. General rectangular matrices do not implicitly flatten to vectors.

Definition at line 158 of file matrix.hpp.

References mat_rows_v.

◆ as_vector() [3/3]

template<Field T, std::size_t N>
constexpr auto linalg::as_vector ( const RowVector< T, N > &  A)
constexpr

express row vector as vector

Parameters
MatrixA type T with 1 x N elements
Returns
vector

Definition at line 135 of file linalg_util.hpp.

References mat_rows_v.

◆ conjugate()

template<ComplexVector Vec>
constexpr auto linalg::conjugate ( const Vec &  x)
constexpr

conjugate a vector

Parameters
vectorof type T with N elements
Returns
conjugated vector

Definition at line 166 of file linalg_ops.hpp.

References mat_rows_v.

◆ conjugate_transpose()

template<MatrixContainer Mat>
requires (Complex<matrix_scalar_t<Mat>>)
constexpr auto linalg::conjugate_transpose ( const Mat &  A)
constexpr

conjugate transpose of a matrix

Like A^T, however the field is complex and the elements get conjugated

Parameters
matrixA of type T Rows x Cols elements
Returns
A^*

Definition at line 300 of file linalg_ops.hpp.

References mat_rows_v, and transpose().

Referenced by linalg::Hessenberg< Mat >::Hessenberg(), linalg::QR< Mat >::solve(), and linalg::Hessenberg< Mat >::U().

◆ constexpr_abs() [1/2]

template<Complex T>
constexpr auto linalg::constexpr_abs ( const T &  x)
constexpr

Definition at line 190 of file algebra_util.hpp.

References constexpr_sqrt_safe().

◆ constexpr_abs() [2/2]

template<Real T>
constexpr T linalg::constexpr_abs ( T  x)
constexpr

Compute real absolute value or complex magnitude.

Parameters
xReal or complex field scalar.
Returns
|x| in the associated real type.

Definition at line 181 of file algebra_util.hpp.

Referenced by linalg::SymmetricMatrixInverse< MatIn >::apply(), constexpr_atanh(), constexpr_nrt(), is_same(), linalg::L1< Vec >::operator()(), and linalg::Linf< Vec >::operator()().

◆ constexpr_atanh()

template<Real T>
constexpr std::optional< T > linalg::constexpr_atanh ( T  x,
int  terms = 16 
)
constexpr

atanh (inverse hyperbolic tangent function)

atanh(x) = x + x^3 / 3 + x^5 / 5 + ... = sum_{n=0}^{infinity} frac{x^{2n+1}}{2n+1}

Parameters
xin (-1, 1)
termsNumber of odd-power series terms.
Returns
y in R

Definition at line 333 of file algebra_util.hpp.

References constexpr_abs(), and mat_rows_v.

Referenced by constexpr_atanh_safe(), and constexpr_ln().

◆ constexpr_atanh_safe()

template<Real T>
constexpr T linalg::constexpr_atanh_safe ( T  x,
T  fallback = T(0),
int  terms = 16 
)
constexpr

constexpr-safe atanh with fallback

Parameters
xinput scalar
fallbackfallback value when |x| >= 1
termsseries terms
Returns
scalar atanh result or fallback

Definition at line 359 of file algebra_util.hpp.

References constexpr_atanh(), and mat_rows_v.

◆ constexpr_cos()

template<Real T>
constexpr auto linalg::constexpr_cos ( T  x,
int  terms = 16 
)
constexpr

Approximate cosine with a truncated Taylor recurrence.

sum_{k=0}^{infinity}frac{(-1)^{k}x^{2k}}{(2k)!} = cos x

Parameters
xAngle in radians.
termsNumber of series terms.
Returns
Cosine approximation.

Definition at line 308 of file algebra_util.hpp.

References mat_rows_v.

Referenced by constexpr_expi(), affine::Rotation2d< T >::operator()(), affine::Rotation3d< T >::x(), affine::Rotation3d< T >::y(), and affine::Rotation3d< T >::z().

◆ constexpr_div()

template<Real T>
constexpr std::optional< T > linalg::constexpr_div ( T  num,
T  den 
)
constexpr

Divide two real scalars with an explicit zero-denominator result.

Parameters
numnumerator
dendenominator
Returns
num / den when denominator is nonzero, else nullopt

Definition at line 79 of file algebra_util.hpp.

References mat_rows_v.

Referenced by constexpr_div_safe().

◆ constexpr_div_safe()

template<Real T>
constexpr T linalg::constexpr_div_safe ( T  num,
T  den,
T  fallback = T(0) 
)
constexpr

Divide two real scalars, returning a fallback for a zero denominator.

Parameters
numnumerator
dendenominator
fallbackfallback value when denominator is zero
Returns
scalar division result or fallback

Definition at line 94 of file algebra_util.hpp.

References constexpr_div(), and mat_rows_v.

Referenced by constexpr_ln(), constexpr_nrt(), and constexpr_sqrt().

◆ constexpr_exp()

template<Real T>
constexpr auto linalg::constexpr_exp ( T  x,
int  terms = 16 
)
constexpr

Approximate the real exponential with a truncated power series.

exp(x) = 1 + x + x^2/2! + x^3/3!... = sum_{n=0}^infinity frac{x^n}{n!}

Parameters
xReal exponent.
termsNumber of series terms.
Returns
Real exponential approximation.

Definition at line 393 of file algebra_util.hpp.

References mat_rows_v.

Referenced by constexpr_exp_lambda().

◆ constexpr_exp_lambda()

template<Complex T>
constexpr auto linalg::constexpr_exp_lambda ( const T &  lambda,
int  terms = 16 
)
constexpr

Approximate the exponential of a complex scalar.

Parameters
lambdaComplex exponent alpha + i * omega.
termsNumber of series terms used by each component approximation.
Returns
Complex exponential approximation.

Definition at line 415 of file algebra_util.hpp.

References constexpr_exp(), constexpr_expi(), and mat_rows_v.

Referenced by matrix_exp().

◆ constexpr_expi()

template<Real T>
constexpr auto linalg::constexpr_expi ( T  theta,
int  terms = 16 
)
constexpr

Approximate exp(i * theta) on the complex unit circle.

Parameters
thetaAngle in radians.
termsNumber of sine and cosine series terms.
Returns
Complex unit-circle approximation.

Definition at line 372 of file algebra_util.hpp.

References constexpr_cos(), constexpr_sin(), and mat_rows_v.

Referenced by constexpr_exp_lambda().

◆ constexpr_for()

template<std::size_t Start, std::size_t End, typename Func >
requires (End - Start >= 0)
constexpr void linalg::constexpr_for ( Func &&  f)
constexpr

constexpr for loop which recursively unrolls a dynamic for loop into compile time recursive loop

Template Parameters
StartInclusive compile-time start index.
EndExclusive compile-time end index.
Parameters
fCallable receiving each index as std::integral_constant.

Definition at line 513 of file algebra_util.hpp.

References mat_rows_v.

Referenced by linalg::Hessenberg< Mat >::Hessenberg(), and linalg::Hessenberg< Mat >::U().

◆ constexpr_ln()

template<Real T>
constexpr std::optional< T > linalg::constexpr_ln ( T  x_in,
int  terms = 16 
)
constexpr

natural log

[old 1] less numerically friendly Taylor series expansion for 1 + t, t = 0 log(1 + t) = t - t^2 / 2 + t^3 / 3 - ... = sum_{k=1}^{infinity}(-1)^{k+1}frac{t^k}{k}

Restricting x in R_++, and let t = x - 1... log(1 + x - 1) = log(x) log(x) approximately (x - 1) - (x - 1)^2 / 2 + (x - 1)^3 - ...

[old 2] use atanh log(x) approximately 2 * atan(y) where y = (x - 1) / (x + 1)

[new] range reduce x = m * 2^e where m in [0.5, 2] for all x > 0 we have x = m 2^e, m in [0.5, 1] and e in Z ln(x) = ln(m) + e ln(2) ** the above makes this much more numerically stable

  • perform atan(y) as before
  • sum 2a with e*ln(2)
Parameters
x_inPositive real argument.
termsNumber of inverse-hyperbolic-tangent series terms.
Returns
Logarithm approximation, or std::nullopt outside the positive domain.

Definition at line 452 of file algebra_util.hpp.

References constexpr_atanh(), constexpr_div_safe(), and mat_rows_v.

Referenced by constexpr_ln_safe().

◆ constexpr_ln_safe()

template<Real T>
constexpr T linalg::constexpr_ln_safe ( T  x,
T  floor = std::numeric_limits<T>::min(),
int  terms = 16 
)
constexpr

natural log with domain sanitization and fallback

Ensures no optional access is required at call sites that need a scalar. Handles NaN/invalid by clamping to a positive floor.

Parameters
xinput scalar
floorpositive floor value used when x is invalid/non-positive
termsseries terms
Returns
ln(max(x, floor)) with NaN-safe clamping semantics

Definition at line 492 of file algebra_util.hpp.

References constexpr_ln(), and mat_rows_v.

◆ constexpr_nrt()

template<Real T>
constexpr std::optional< T > linalg::constexpr_nrt ( T  x,
std::size_t  root,
T  g = 1e-10,
T  tol = 1e-10 
)
constexpr

Approximate a real nth root with Newton iteration.

f(g) = g^n - x to df/dg = n g^{n-1} Newton formula : g_{k+1} = g_k - frac{g_k^n - x}{n g^{n-1}} equivalent to g_{k+1} = 1/n ((n - 1) g_k + x / g_k^{n-1})

Parameters
xReal radicand. Negative values require an odd root degree.
rootRoot degree; zero returns std::nullopt.
gPositive initial guess.
tolAbsolute reconstruction tolerance.
Returns
Approximation or std::nullopt for an invalid real-domain request.

Definition at line 212 of file algebra_util.hpp.

References constexpr_abs(), constexpr_div_safe(), mat_rows_v, and MAX_STEP_EVAL.

Referenced by constexpr_nrt_safe().

◆ constexpr_nrt_safe()

template<Real T>
constexpr T linalg::constexpr_nrt_safe ( T  x,
std::size_t  root,
T  floor = T(0),
T  g = 1e-10,
T  tol = 1e-10 
)
constexpr

Return a scalar nth root with a sanitized fallback radicand.

Parameters
xinput scalar
rootroot degree
floorfallback scalar
ginitial guess
tolconvergence tolerance
Returns
scalar nth-root with optional fallback handling

Definition at line 263 of file algebra_util.hpp.

References constexpr_nrt(), and mat_rows_v.

◆ constexpr_pow()

template<Real T>
constexpr T linalg::constexpr_pow ( T  x,
std::size_t  power 
)
constexpr

Raise a real scalar to a nonnegative integral power.

Parameters
xReal base.
powerNonnegative integral exponent; conventionally positive here.

Definition at line 106 of file algebra_util.hpp.

References mat_rows_v.

◆ constexpr_sin()

template<Real T>
constexpr auto linalg::constexpr_sin ( T  x,
int  terms = 16 
)
constexpr

Approximate sine with a truncated Taylor recurrence.

sum_{k=0}^{infinity}frac{(-1)^{k}x^{2k+1}}{(2k+1)!}

Parameters
xAngle in radians.
termsNumber of series terms.
Returns
Sine approximation.

Definition at line 284 of file algebra_util.hpp.

References mat_rows_v.

Referenced by constexpr_expi(), affine::Rotation2d< T >::operator()(), affine::Rotation3d< T >::x(), affine::Rotation3d< T >::y(), and affine::Rotation3d< T >::z().

◆ constexpr_sqrt()

template<Real T>
constexpr std::optional< T > linalg::constexpr_sqrt ( T  x,
T  g = 1e-10,
T  tol = 1e-10 
)
constexpr

Approximate a nonnegative square root with Newton iteration.

f(g) = g^2 - x to df/dg = 2 g Newton formula : g_{k+1} = g_k - frac{g^2 - x} / {2 g_k} equivalent to 0.5 * (g_n + x / g_n)

Parameters
xNonnegative radicand; a negative value returns std::nullopt.
gPositive initial guess; nonpositive guesses are replaced with one.
tolAbsolute squared-residual tolerance.
Returns
Approximation, or std::nullopt outside the real domain. The current zero-input convention returns zero.

Definition at line 130 of file algebra_util.hpp.

References constexpr_div_safe(), mat_rows_v, and MAX_STEP_EVAL.

Referenced by constexpr_sqrt_safe().

◆ constexpr_sqrt_safe()

template<Real T>
constexpr T linalg::constexpr_sqrt_safe ( T  x,
T  floor = T(0),
T  g = 1e-10,
T  tol = 1e-10 
)
constexpr

Return a scalar square root with a sanitized fallback radicand.

Parameters
xinput scalar
floorminimum scalar for fallback
ginitial guess
tolconvergence tolerance
Returns
scalar sqrt with optional fallback handling

Definition at line 163 of file algebra_util.hpp.

References constexpr_sqrt(), and mat_rows_v.

Referenced by constexpr_abs(), linalg::Fro< Mat >::operator()(), linalg::L2< Vec >::operator()(), and linalg::EigenDecomposition< Mat >::spectral_radius().

◆ coordinates()

template<class Space >
constexpr auto linalg::coordinates ( const space_element_t< Space > &  element)
constexpr

Convert a registered space element to its coordinate representation.

Parameters
elementElement in the canonical representation of Space.
Returns
Coordinate vector registered by space_traits<Space>.

Definition at line 81 of file coordinate_map.hpp.

References mat_rows_v.

◆ cross()

template<FieldVector Vec>
requires (vector_dim_v<Vec> == 3)
constexpr auto linalg::cross ( const Vec &  x,
const Vec &  y 
)
constexpr

cross product between x x y = Z

Parameters
vectorof type T with 3 elements
vectorof type T with 3 elements
Returns
(3x1) vector

Definition at line 184 of file linalg_ops.hpp.

◆ euclidean_distance()

template<VectorContainer Vec>
constexpr auto linalg::euclidean_distance ( const Vec &  X,
const Vec &  Y 
)
constexpr

Compute the euclidean distance between two vectors (L2 norm of delta)

Parameters
vectorX of type T with N elements
vectorY of type T with N elements
Returns
distance between two vectors as a scalar

Definition at line 331 of file linalg_util.hpp.

References mat_rows_v.

Referenced by all_equal(), and rows_equal_cols().

◆ from_coordinates()

template<class Space >
constexpr auto linalg::from_coordinates ( const space_coordinate_t< Space > &  coordinate)
constexpr

Reconstruct a registered space element from its coordinates.

Parameters
coordinateCoordinate representation registered for Space.
Returns
Element in the canonical representation of Space.

Definition at line 91 of file coordinate_map.hpp.

References mat_rows_v.

◆ get_block()

template<std::size_t StartRow, std::size_t EndRow, std::size_t StartCol, std::size_t EndCol, MatrixContainer Mat>
requires (EndRow - StartRow <= mat_rows_v<Mat> && StartRow < mat_rows_v<Mat> && EndCol - StartCol <= mat_cols_v<Mat> && StartCol < mat_cols_v<Mat>)
constexpr auto linalg::get_block ( const Mat &  A)
constexpr

Copy a compile-time rectangular matrix block.

Parameters
matrixA of type T Rows x Cols elements

Row and column bounds are half-open: [StartRow, EndRow) x [StartCol, EndCol).

Returns
Owning matrix with the selected block shape.

Definition at line 255 of file linalg_util.hpp.

References mat_rows_v.

◆ get_col()

template<MatrixContainer Mat>
constexpr auto linalg::get_col ( const Mat &  A,
std::size_t  idx 
)
constexpr

get the column of matrix A based on given index

Parameters
matrixA of size Rows x Cols of type T
index
Returns
vector X

Definition at line 150 of file linalg_util.hpp.

References AK_ASSERT, and mat_rows_v.

Referenced by linalg::LDL< Mat >::apply(), linalg::QuadraticRep< JxJ, Circ >::apply(), linalg::Hessenberg< Mat >::Hessenberg(), and rows_equal_cols().

◆ get_diag()

template<MatrixContainer Mat>
constexpr auto linalg::get_diag ( const Mat &  A)
constexpr

get the diagonal of a matrix A

Parameters
matrixA of size Rows x Cols of type T
Returns
diagonal vector

Definition at line 181 of file linalg_util.hpp.

References mat_rows_v.

◆ get_elements()

template<std::size_t Start, std::size_t End, VectorContainer Vec>
requires (End - Start < vector_dim_v<Vec> && Start < vector_dim_v<Vec>)
constexpr auto linalg::get_elements ( const Vec &  x)
constexpr

Copy the half-open vector slice [Start, End).

Parameters
vectorof type T with N elements
Returns
Vector of type T with End - Start elements.

Definition at line 26 of file linalg_util.hpp.

References mat_rows_v.

◆ get_lower_left_triangular_matrix()

template<MatrixContainer Mat>
constexpr auto linalg::get_lower_left_triangular_matrix ( const Mat &  A)
constexpr

get lower left triangular matrix from A

Parameters
matrixA of type T Rows x Cols elements
Returns
matrix

Definition at line 313 of file linalg_util.hpp.

References mat_rows_v.

◆ get_lower_triangle()

template<SquareMatrix Mat>
constexpr auto linalg::get_lower_triangle ( const Mat &  A)
constexpr

get lower triangle

[ 0 0 0 0 ] [ * 0 0 0 ] [ * * 0 0 ] [ * * * 0 ]

Parameters
matrixA
Returns
vec

Definition at line 519 of file linalg_util.hpp.

References mat_rows_v.

◆ get_lower_triangle_with_diag()

template<SquareMatrix Mat>
constexpr auto linalg::get_lower_triangle_with_diag ( const Mat &  A)
constexpr

get lower triangle with diag

[ * 0 0 0 ] [ * * 0 0 ] [ * * * 0 ] [ * * * * ]

Parameters
matrixA
Returns
vec

Definition at line 446 of file linalg_util.hpp.

References mat_rows_v.

◆ get_n_cols()

template<std::size_t Start, std::size_t End, MatrixContainer Mat>
requires (End - Start <= mat_cols_v<Mat> && Start < mat_cols_v<Mat>)
constexpr auto linalg::get_n_cols ( const Mat &  A)
constexpr

Copy the half-open matrix column range [Start, End).

Parameters
matrixA of type T Rows x Cols elements
Returns
matrix

Definition at line 232 of file linalg_util.hpp.

References mat_rows_v.

◆ get_n_rows()

template<std::size_t Start, std::size_t End, MatrixContainer Mat>
requires (End - Start <= mat_rows_v<Mat> && Start < mat_rows_v<Mat>)
constexpr auto linalg::get_n_rows ( const Mat &  A)
constexpr

Copy the half-open matrix row range [Start, End).

Parameters
matrixA of type T Rows x Cols elements
Returns
matrix

Definition at line 214 of file linalg_util.hpp.

References mat_rows_v.

◆ get_row()

template<MatrixContainer Mat>
constexpr auto linalg::get_row ( const Mat &  A,
std::size_t  idx 
)
constexpr

get the row of matrix A based on given index

Parameters
matrixA of size Rows x Cols of type T
index
Returns
vector X

Definition at line 168 of file linalg_util.hpp.

References AK_ASSERT, and mat_rows_v.

◆ get_svec()

template<SquareMatrix Mat>
constexpr auto linalg::get_svec ( const Mat &  A)
constexpr

get svec encoding of a symmetric matrix

Off-diagonal entries are scaled by sqrt(2) to preserve the Frobenius inner product under vectorization.

Parameters
matrixA
Returns
svec(A)

Definition at line 467 of file linalg_util.hpp.

References mat_rows_v.

Referenced by make_svec().

◆ get_upper_right_triangular_matrix()

template<MatrixContainer Mat>
constexpr auto linalg::get_upper_right_triangular_matrix ( const Mat &  A)
constexpr

get upper right triangular matrix from A

Parameters
matrixA of type T Rows x Cols elements
Returns
matrix

Definition at line 296 of file linalg_util.hpp.

References mat_rows_v.

Referenced by linalg::QR< Mat >::R().

◆ inner_product()

template<FieldVector Vec>
constexpr auto linalg::inner_product ( const Vec &  lhs,
const Vec &  rhs 
)
constexpr

Evaluate the canonical inner product for two field vectors.

This is the standard call-site API and delegates to StandardInnerProduct<remove_cvref_t<Vec>>. There is deliberately no separate dot operation with different complex-number semantics.

Parameters
lhsFirst vector; conjugated for a complex field.
rhsSecond vector.
Returns
Real or complex field scalar associated with Vec.

Definition at line 123 of file inner_product.hpp.

References mat_rows_v.

Referenced by linalg::L2< Vec >::operator()().

◆ invert_permutation()

template<std::size_t N>
constexpr auto linalg::invert_permutation ( const Vector< std::size_t, N > &  p)
constexpr

Invert an index permutation.

Template Parameters
NNumber of permuted indices.
Parameters
[in]pPermutation of indices 0 through N-1.
Returns
Vector<std::size_t, N> satisfying p_inv(p(i)) = i.

Definition at line 53 of file matrix_exp.hpp.

References mat_rows_v.

Referenced by matrix_exp().

◆ is_fatal_event()

constexpr bool linalg::is_fatal_event ( NumericalEvent  event)
inlineconstexpr

is_fatal_event

Parameters
event(NumericalEvent)
Returns
T/F

Definition at line 48 of file numerical_config.hpp.

References EVD_FAILED, and FACTORIZATION_FAILED.

Referenced by linalg::SymmetricMatrixInverse< MatIn >::apply(), linalg::LDL< Mat >::apply(), and linalg::LDL< Mat >::solve().

◆ is_real()

template<Field T>
constexpr bool linalg::is_real ( const std::complex< T > &  z,
real_type_t< T >  tol = 1e-10 
)
constexpr

Check whether a complex value's imaginary component is below a bound.

This function evaluates z.imag() <= tol exactly; it is primarily used where the expected imaginary residual is nonnegative. It does not take the absolute value of the imaginary component.

Parameters
zComplex value to inspect.
tolUpper bound for its imaginary component.

Definition at line 66 of file algebra_util.hpp.

Referenced by linalg::L2< Vec >::operator()().

◆ is_same()

template<Complex T>
constexpr bool linalg::is_same ( const T &  a,
const T &  b,
real_type_t< T >  tol = 1e-10 
)
constexpr

Compare complex scalars by magnitude of their difference.

Parameters
aFirst complex scalar.
bSecond complex scalar.
tolStrict magnitude tolerance.

Definition at line 528 of file algebra_util.hpp.

References constexpr_abs(), and mat_rows_v.

Referenced by make_group_permutation(), and matrix_exp().

◆ make_diag()

template<Field T, std::size_t N>
constexpr auto linalg::make_diag ( const Vector< T, N > &  X)
constexpr

make a diagonal matrix from a vector

Parameters
vectorX of size N and type T
Returns
diagonal matrix

Definition at line 199 of file linalg_util.hpp.

References mat_rows_v.

Referenced by linalg::LDL< Mat >::D().

◆ make_group_permutation()

template<VectorContainer Vec>
requires (Complex<vector_element_t<Vec>>)
constexpr auto linalg::make_group_permutation ( const Vec &  D,
real_type_t< vector_element_t< Vec > >  tol = 1e-10 
)
constexpr

Group approximately equal eigenvalues into contiguous index runs.

Template Parameters
VecVector type with complex scalar entries.
Parameters
[in]DComplex eigenvalue vector.
[in]tolAbsolute tolerance for comparing eigenvalues.
Returns
Vector<std::size_t, N> mapping grouped positions to original indices.

Definition at line 23 of file matrix_exp.hpp.

References is_same(), and mat_rows_v.

Referenced by matrix_exp().

◆ make_identity()

template<Field T, std::size_t N>
constexpr Matrix< T, N, N > linalg::make_identity ( )
constexpr

create an identity matrix of size N type T

Returns
I

Definition at line 39 of file linalg_util.hpp.

References mat_rows_v.

◆ make_lower_triangle()

template<SquareMatrix Mat, VectorContainer Vec>
requires (std::same_as<matrix_scalar_t<Mat>, vector_element_t<Vec>>)
constexpr auto linalg::make_lower_triangle ( const Vec &  x)
constexpr

Construct a lower-triangular matrix including its diagonal.

Parameters
x(vector)

Coordinates are consumed row by row through the diagonal; entries above the diagonal remain value-initialized zero.

Returns
Lower-triangular matrix L.

Definition at line 568 of file linalg_util.hpp.

References mat_rows_v.

◆ make_smat()

template<std::size_t N, FieldVector Vec>
requires (vector_dim_v<Vec> == N * (N + 1) / 2)
constexpr auto linalg::make_smat ( const Vec &  L)
constexpr

make symmetric matrix

Parameters
symmetricvector (flattened)
Returns
matrix

Definition at line 412 of file linalg_util.hpp.

References mat_rows_v, and transpose().

◆ make_svec()

template<SquareMatrix Mat>
constexpr auto linalg::make_svec ( const Mat &  A)
constexpr

Compatibility spelling for get_svec(A).

Parameters
ASquare matrix to encode in lower-triangular svec order.
Returns
Square-root-of-two-scaled symmetric coordinates.

Definition at line 487 of file linalg_util.hpp.

References get_svec(), and mat_rows_v.

◆ make_unit_lower_triangle()

template<SquareMatrix Mat, VectorContainer Vec>
requires (std::same_as<matrix_scalar_t<Mat>, vector_element_t<Vec>>)
constexpr auto linalg::make_unit_lower_triangle ( const Vec &  x)
constexpr

Construct a unit lower-triangular matrix from strict-lower entries.

Parameters
vectorx

Coordinates are consumed row by row below the diagonal. Diagonal entries are set to one and upper-triangular entries remain value-initialized zero.

Returns
Unit lower-triangular matrix L.

Definition at line 541 of file linalg_util.hpp.

References mat_rows_v.

◆ make_zeros()

template<Field T, std::size_t Rows, std::size_t Cols>
constexpr Matrix< T, Rows, Cols > linalg::make_zeros ( )
constexpr

create a matrix filled with zeros of size Rows x Cols of type T

Returns
Zeros

Definition at line 51 of file linalg_util.hpp.

References mat_rows_v.

◆ manhattan_distance()

template<VectorContainer Vec>
constexpr auto linalg::manhattan_distance ( const Vec &  X,
const Vec &  Y 
)
constexpr

Compute the manhattan distance between two vectors (L1 norm of delta)

Parameters
vectorX of type T with N elements
vectorY of type T with N elements
Returns
distance between two vectors as a scalar

Definition at line 344 of file linalg_util.hpp.

References mat_rows_v.

◆ Matrix()

template<Field T, std::size_t Cols, typename... Rows>
linalg::Matrix ( Vector< T, Cols >  ,
Rows...   
) -> Matrix< T, 1+sizeof...(Rows), Cols >

Deduce matrix scalar type and shape from one or more row vectors.

For example, two Vector<double, 3> arguments deduce Matrix<double, 2, 3>.

◆ matrix_exp()

template<SquareMatrix Mat>
constexpr auto linalg::matrix_exp ( const Mat &  A)
constexpr

Compute exp(A) using its eigenvector and generalized-eigenvector basis.

Algorithm flow:

  1. Recover a basis V and form J = V^-1 A V. Ordinary eigenvectors give diagonal blocks; generalized eigenvectors retain Jordan-chain couplings.
  2. Permute equal-eigenvalue coordinates together so each block can be evaluated independently.
  3. For a block B = lambda*I + K, separate the scalar exponential from the nilpotent part: exp(B) = exp(lambda) * exp(K). For a block of size k, K^k = 0, so exp(K) = I + K + ... + K^(k-1)/(k-1)! is a finite sum.
  4. Undo the coordinate grouping and return V * exp(J) * V^-1.

This path relies on the decomposition producing an invertible generalized eigenvector basis and approximately upper-triangular repeated-root blocks. Eigenvalues are grouped by the helpers' absolute comparison tolerance. Complex arithmetic is retained even for real A, whose eigenvalues may occur in complex-conjugate pairs.

Template Parameters
MatSquare matrix type.
Parameters
[in]ASquare input matrix.
Returns
Complex N-by-N matrix exp(A), or a zero matrix if decomposition or inversion fails.

Definition at line 121 of file matrix_exp.hpp.

References as_complex_matrix(), constexpr_exp_lambda(), invert_permutation(), is_same(), make_group_permutation(), mat_rows_v, NONE, permute_ptjp(), and unpermute_papt().

◆ max()

template<VectorContainer Vec>
requires (vector_dim_v<Vec> > 0)
constexpr auto linalg::max ( const Vec &  x)
constexpr

max element

Parameters
vectorx
Returns
max element

Definition at line 386 of file linalg_ops.hpp.

References mat_rows_v.

◆ min()

template<VectorContainer Vec>
requires (vector_dim_v<Vec> > 0)
constexpr auto linalg::min ( const Vec &  x)
constexpr

min element

Parameters
vectorx
Returns
min element

Definition at line 369 of file linalg_ops.hpp.

References mat_rows_v.

◆ operator*() [1/4]

template<MatrixContainer Mat, Field Alpha>
constexpr auto linalg::operator* ( const Alpha &  alpha,
const Mat &  A 
)
constexpr

Left scalar-matrix multiplication operator.

Definition at line 118 of file linalg_ops.hpp.

References mat_rows_v, and scalar_multiplication().

◆ operator*() [2/4]

template<VectorContainer Vec, Field Alpha>
constexpr auto linalg::operator* ( const Alpha &  alpha,
const Vec &  A 
)
constexpr

operator overload for scalar multiplication

See also
scalar_multiplication

Definition at line 94 of file linalg_ops.hpp.

References mat_rows_v, and scalar_multiplication().

◆ operator*() [3/4]

template<MatrixContainer Mat, VectorContainer Vec>
requires (MatVecCompatible<Mat, Vec>)
constexpr auto linalg::operator* ( const Mat &  A,
const Vec &  X 
)
constexpr

Apply a compatible matrix to a vector.

Parameters
matrixA of type T Rows x Cols elements
vectorX of type T Cols elements
Returns
Vector over the same field with dimension mat_rows_v<Mat>.

Definition at line 347 of file linalg_ops.hpp.

References mat_rows_v.

◆ operator*() [4/4]

template<MatrixContainer MatA, MatrixContainer MatB>
requires (MatMulCompatible<MatA, MatB>)
constexpr auto linalg::operator* ( const MatA &  A,
const MatB &  B 
)
constexpr

Multiply compatible matrices with the standard row-column product.

Parameters
matrixA of type T Rows x Cols elements
matrixB of type T Cols x Rows elements
Returns
Matrix<T, rows(A), cols(B)>.

Definition at line 321 of file linalg_ops.hpp.

References mat_rows_v.

◆ operator+() [1/2]

template<MatrixContainer Mat>
constexpr auto linalg::operator+ ( const Mat &  A,
const Mat &  B 
)
constexpr

Matrix addition operator delegating to add.

Definition at line 65 of file linalg_ops.hpp.

References add(), and mat_rows_v.

◆ operator+() [2/2]

template<VectorContainer Vec>
constexpr auto linalg::operator+ ( const Vec &  A,
const Vec &  B 
)
constexpr

operator overload for add

See also
add

Definition at line 41 of file linalg_ops.hpp.

References add(), and mat_rows_v.

◆ operator-() [1/2]

template<MatrixContainer Mat>
constexpr auto linalg::operator- ( const Mat &  A,
const Mat &  B 
)
constexpr

Subtract two matrices as A + (-1) * B.

Definition at line 135 of file linalg_ops.hpp.

References mat_rows_v.

◆ operator-() [2/2]

template<VectorContainer Vec>
constexpr auto linalg::operator- ( const Vec &  A,
const Vec &  B 
)
constexpr

operator overload for subtraction

See also
add
scalar_multiplication

Definition at line 129 of file linalg_ops.hpp.

References mat_rows_v.

◆ outer_product()

template<MatrixContainer MatA, MatrixContainer MatB>
requires (MatMulCompatible<MatA, MatB>)
constexpr auto linalg::outer_product ( const MatA &  A,
const MatB &  B 
)
constexpr

Multiply matrix-shaped column and row operands as an outer product.

A * B = C where C is a new matrix of Rows_of_A x Cols_of_B

Parameters
matrixA of type T Rows1 x Cols1 elements
matrixB of type T Cols1 x Cols2 elements
Returns
Matrix with mat_rows_v<MatA> rows and mat_cols_v<MatB> columns. The implementation uses A(i, 0) * B(0, j); callers should supply a one-column left operand and one-row right operand.

Definition at line 241 of file linalg_ops.hpp.

References mat_rows_v.

◆ permute_ptjp()

template<MatrixContainer Mat>
constexpr auto linalg::permute_ptjp ( const Mat &  J,
const Vector< std::size_t, mat_rows_v< Mat > > &  p 
)
constexpr

Reorder matrix rows and columns by the same permutation.

Template Parameters
MatSquare matrix type.
Parameters
[in]JSquare matrix to reorder.
[in]pPermutation mapping new indices to original indices.
Returns
Matrix of type Mat with entry (i,j) = J(p(i),p(j)).

Definition at line 68 of file matrix_exp.hpp.

References mat_rows_v.

Referenced by matrix_exp().

◆ rows_equal_cols()

template<MatrixContainer MatA, MatrixContainer MatB>
requires (std::same_as<matrix_scalar_t<MatA>, matrix_scalar_t<MatB>> && mat_rows_v<MatA> == mat_cols_v<MatB> && mat_cols_v<MatA> == mat_rows_v<MatB>)
constexpr bool linalg::rows_equal_cols ( const MatA &  A,
const MatB &  B 
)
constexpr

checks if the row space of one matrix is equivalent to the column space of another matrix

Parameters
matrixA of type T with Rows x Cols elements
vectorB of type T with Cols x Rows elements
Returns
T/F

Definition at line 395 of file linalg_util.hpp.

References euclidean_distance(), get_col(), and mat_rows_v.

◆ scalar_multiplication() [1/2]

template<MatrixContainer Mat, Field Alpha>
constexpr auto linalg::scalar_multiplication ( const Alpha &  alpha,
const Mat &  A 
)
constexpr

Multiply every matrix entry by a field scalar.

Parameters
alphaScalar multiplier.
AMatrix operand.
Returns
Owning matrix with the same shape and registered matrix scalar type.

Definition at line 105 of file linalg_ops.hpp.

References mat_rows_v.

◆ scalar_multiplication() [2/2]

template<VectorContainer Vec, Field Alpha>
constexpr auto linalg::scalar_multiplication ( const Alpha &  alpha,
const Vec &  A 
)
constexpr

multiply a vector A with a scalar alpha

alpha * A = alpha A

Parameters
alphaof scalar type T
vectorx of type T with N elements
Returns
vector

Definition at line 80 of file linalg_ops.hpp.

References mat_rows_v.

Referenced by operator*(), and operator*().

◆ set_block()

template<std::size_t StartRow, std::size_t EndRow, std::size_t StartCol, std::size_t EndCol, MatrixContainer Mat>
requires (EndRow - StartRow <= mat_rows_v<Mat> && StartRow < mat_rows_v<Mat> && EndCol - StartCol <= mat_cols_v<Mat> && StartCol < mat_cols_v<Mat>)
constexpr auto linalg::set_block ( Mat  A,
const Matrix< matrix_scalar_t< Mat >, EndRow - StartRow, EndCol - StartCol > &  B 
)
constexpr

Return a matrix copy with one compile-time block replaced.

Parameters
matrixA of type T Rows x Cols elements
matrixB of type T (EndRow - StartRow) x (EndCol - StartCol)

Bounds are half-open. A is accepted by value, so this operation does not mutate the caller's original matrix.

Returns
Updated matrix copy.

Definition at line 279 of file linalg_util.hpp.

References mat_rows_v.

◆ splice()

template<std::size_t idx, FieldVector Vec>
requires (vector_dim_v<Vec> > 0 && idx < vector_dim_v<Vec>)
constexpr auto linalg::splice ( const Vec &  x)
constexpr

splice operator

Parameters
vectortype T with N elements
Returns
tuple

Definition at line 216 of file linalg_ops.hpp.

References mat_rows_v.

◆ symmetric_part()

template<SquareMatrix Mat>
constexpr auto linalg::symmetric_part ( const Mat &  A)
constexpr

symmetric part of a square matrix

sym(A) = 0.5 * (A + A^T)

Parameters
matrixA
Returns
symmetric matrix

Definition at line 501 of file linalg_util.hpp.

References mat_rows_v, and transpose().

◆ trace()

template<SquareMatrix Mat>
requires (mat_rows_v<Mat> > 0)
constexpr auto linalg::trace ( const Mat &  A)
constexpr

trace of a matrix

Sum of the diagonal elements of a matrix

Parameters
matrixA of type T Rows x Cols elements
Returns
sum

Definition at line 282 of file linalg_ops.hpp.

References mat_rows_v.

◆ transpose() [1/2]

template<MatrixContainer Mat>
constexpr auto linalg::transpose ( const Mat &  A)
constexpr

transpose of a matrix

A^T (rows and cols flipped from A)

Parameters
matrixA of type T Rows x Cols elements
Returns
A^T

Definition at line 261 of file linalg_ops.hpp.

References mat_rows_v.

◆ transpose() [2/2]

template<FieldVector Vec>
constexpr auto linalg::transpose ( const Vec &  x)
constexpr

tranpose of a vector

Vector is naturally row vector in how it's stored so the transpose flips it from a row to column based matrix

Parameters
vectorof type T with N elements
Returns
(N x 1) matrix

Definition at line 150 of file linalg_ops.hpp.

References mat_rows_v.

Referenced by conjugate_transpose(), linalg::Hessenberg< Mat >::Hessenberg(), make_smat(), linalg::LDL< Mat >::solve(), linalg::QR< Mat >::solve(), symmetric_part(), and linalg::Hessenberg< Mat >::U().

◆ unpermute_papt()

template<MatrixContainer Mat>
constexpr auto linalg::unpermute_papt ( const Mat &  A,
const Vector< std::size_t, mat_rows_v< Mat > > &  p 
)
constexpr

Scatter matrix entries through a row-and-column permutation.

Template Parameters
MatSquare matrix type.
Parameters
[in]ASquare matrix whose entries are scattered.
[in]pPermutation mapping source indices to destination indices.
Returns
Matrix R of type Mat satisfying R(p(i),p(j)) = A(i,j).

Definition at line 86 of file matrix_exp.hpp.

References mat_rows_v.

Referenced by matrix_exp().

◆ Vector()

template<typename T , typename... Ts>
linalg::Vector ( T  ,
Ts...   
) -> Vector< std::common_type_t< T, Ts... >, 1+sizeof...(Ts)>

Deduce coordinate type and dimension from constructor arguments.

The coordinate type is their std::common_type_t; the dimension is the number of arguments. For example, Vector{1.0, 2.0} deduces Vector<double, 2>.

Variable Documentation

◆ inv_sqrt2_v

template<Field T>
constexpr T linalg::inv_sqrt2_v {T(1) / sqrt2_v<T>}
inlineconstexpr

Definition at line 16 of file constants.hpp.

◆ is_complex_v

template<typename T >
constexpr bool linalg::is_complex_v = scalar_traits_t<T>::is_complex
inlineconstexpr

Whether normalized T is registered as a complex scalar.

Definition at line 90 of file scalar_traits.hpp.

◆ is_norm_v

template<class Norm >
constexpr bool linalg::is_norm_v = norm_traits<remove_cvref_t<Norm>>{}
inlineconstexpr

helper for is norm type

Definition at line 71 of file norm_traits.hpp.

◆ is_real_v

template<typename T >
constexpr bool linalg::is_real_v = scalar_traits_t<T>::is_real
inlineconstexpr

Whether normalized T is registered as a real scalar.

Definition at line 86 of file scalar_traits.hpp.

◆ is_symmetric_matrix_space_v

template<typename Space >
constexpr bool linalg::is_symmetric_matrix_space_v
inlineconstexpr
Initial value:
=
is_symmetric_matrix_space<remove_cvref_t<Space>>::value

symmetric matrix space type trait var

Definition at line 256 of file operator_traits.hpp.

◆ ln2_v

template<Field T>
constexpr T linalg::ln2_v {T(0.693147180559945309417232121458176568L)}
inlineconstexpr

Definition at line 19 of file constants.hpp.

◆ mat_cols_v

template<class Mat >
constexpr std::size_t linalg::mat_cols_v = mat_traits<remove_cvref_t<Mat>>::COLS
inlineconstexpr

Registered compile-time column count after cv/ref normalization.

Definition at line 95 of file matrix_traits.hpp.

◆ mat_rows_v

template<class Mat >
constexpr std::size_t linalg::mat_rows_v = mat_traits<remove_cvref_t<Mat>>::ROWS
inlineconstexpr

Registered compile-time row count after cv/ref normalization.

Definition at line 91 of file matrix_traits.hpp.

Referenced by add(), add(), all_equal(), all_equal(), all_zero(), linalg::QuadraticRep< JxJ, Circ >::apply(), linalg::MatrixInverse< MatIn >::apply(), linalg::SymmetricMatrixInverse< MatIn >::apply(), linalg::MatrixSqrt< MatIn >::apply(), apply(), linalg::LDL< Mat >::apply(), linalg::Hessian< Mat, Type >::apply(), linalg::QuadraticRep< JxJ, Circ >::apply(), linalg::Hessian< Mat, Type >::apply(), linalg::MatrixPencil< Mat, Dim >::apply_full(), linalg::MatrixPencil< Mat, Dim >::apply_sym_mat(), arg_max(), arg_min(), argsort_desc(), array_to_tuple(), as_col_matrix(), as_col_vector(), as_complex_matrix(), as_row_matrix(), as_row_vector(), as_vector(), as_vector(), as_vector(), linalg::Cholesky< Mat >::Cholesky(), linalg::Cholesky< Mat >::Cholesky(), affine::AffineMap< Mat >::compose(), linalg::SymmetricOperator< Mat, Derived >::compute_definiteness(), conjugate(), conjugate_transpose(), constexpr_atanh(), constexpr_atanh_safe(), constexpr_cos(), constexpr_div(), constexpr_div_safe(), constexpr_exp(), constexpr_exp_lambda(), constexpr_expi(), constexpr_for(), constexpr_ln(), constexpr_ln_safe(), constexpr_nrt(), constexpr_nrt_safe(), constexpr_pow(), constexpr_sin(), constexpr_sqrt(), constexpr_sqrt_safe(), coordinates(), linalg::LDL< Mat >::det(), linalg::EigenDecomposition< Mat >::EigenDecomposition(), linalg::EigenDecomposition< Mat >::EigenDecomposition(), euclidean_distance(), linalg::mat_traits< Matrix< T, Rows, Cols > >::fill(), linalg::vector_traits< Vector< T, Dim > >::fill(), linalg::coordinate_map< SymmetricMatrix< Mat > >::from_coordinates(), from_coordinates(), linalg::coordinate_map< SymmetricMatrixSpace< T, Dim > >::from_coordinates(), linalg::coordinate_map< CoordinateSpace< T, Dim > >::from_coordinates(), linalg::coordinate_map< Matrix< T, Rows, Cols > >::from_coordinates(), linalg::coordinate_map< MatrixSpace< T, Rows, Cols > >::from_coordinates(), linalg::Cholesky< Mat >::G(), get_block(), get_col(), get_diag(), get_elements(), get_lower_left_triangular_matrix(), get_lower_triangle(), get_lower_triangle_with_diag(), get_n_cols(), get_n_rows(), get_row(), get_svec(), get_upper_right_triangular_matrix(), linalg::Hessenberg< Mat >::H(), linalg::Hessenberg< Mat >::Hessenberg(), linalg::SymmetricOperator< Mat, Derived >::index(), inner_product(), affine::AffineMap< Mat >::inverse(), invert_permutation(), linalg::Hessian< Mat, Type >::is_pullback(), is_same(), linalg::LDL< Mat >::L(), linalg::LDL< Mat >::LDL(), linalg::LDL< Mat >::LDL(), make_diag(), make_group_permutation(), make_identity(), make_lower_triangle(), affine::make_map_id(), affine::make_selector_map(), make_smat(), make_svec(), make_unit_lower_triangle(), make_zeros(), manhattan_distance(), linalg::Matrix< T, Rows, Cols >::Matrix(), matrix_exp(), max(), min(), linalg::Vector< T, N >::operator!=(), linalg::StandardInnerProduct< Vec >::operator()(), linalg::Fro< Mat >::operator()(), linalg::L2< Vec >::operator()(), linalg::L1< Vec >::operator()(), linalg::Linf< Vec >::operator()(), linalg::MatrixInverse< MatIn >::operator()(), linalg::SymmetricMatrixInverse< MatIn >::operator()(), linalg::MatrixSqrt< MatIn >::operator()(), affine::Scale< T, N >::operator()(), linalg::Endomorphism< Mat, Derived >::operator()(), linalg::Endomorphism< Mat, Derived >::operator()(), linalg::Hessenberg< Mat >::operator()(), linalg::Hessian< Mat, Type >::operator()(), linalg::SymmetricOperator< Mat, Derived >::operator()(), affine::Shear< T, N >::operator()(), linalg::Vector< T, N >::operator()(), linalg::Vector< T, N >::operator()(), linalg::Matrix< T, Rows, Cols >::operator()(), linalg::Matrix< T, Rows, Cols >::operator()(), linalg::mat_traits< Matrix< T, Rows, Cols > >::operator()(), linalg::vector_traits< Vector< T, Dim > >::operator()(), operator*(), operator*(), operator*(), operator*(), operator+(), operator+(), operator-(), operator-(), linalg::Vector< T, N >::operator==(), outer_product(), permute_ptjp(), linalg::QR< Mat >::QR(), linalg::QR< Mat >::QR(), linalg::QR< Mat >::rank(), linalg::Matrix< T, Rows, Cols >::row(), rows_equal_cols(), scalar_multiplication(), scalar_multiplication(), linalg::Endomorphism< Mat, Derived >::self(), linalg::Endomorphism< Mat, Derived >::self(), linalg::SymmetricOperator< Mat, Derived >::self(), set_block(), linalg::LDL< Mat >::solve(), linalg::QR< Mat >::solve(), linalg::EigenDecomposition< Mat >::spectral_radius(), splice(), linalg::SVD< Mat >::SVD(), symmetric_part(), linalg::SymmetricMatrix< Mat >::SymmetricMatrix(), linalg::coordinate_map< SymmetricMatrix< Mat > >::to_coordinates(), linalg::coordinate_map< Matrix< T, Rows, Cols > >::to_coordinates(), linalg::coordinate_map< MatrixSpace< T, Rows, Cols > >::to_coordinates(), linalg::coordinate_map< SymmetricMatrixSpace< T, Dim > >::to_coordinates(), linalg::coordinate_map< CoordinateSpace< T, Dim > >::to_coordinates(), linalg::coordinate_map< Matrix< T, Rows, Cols > >::to_coordinates(), trace(), transpose(), transpose(), linalg::Hessenberg< Mat >::U(), unpermute_papt(), and linalg::Vector< T, N >::Vector().

◆ norm_dim_v

template<class Norm >
constexpr std::size_t linalg::norm_dim_v = norm_traits_t<Norm>::dim
inlineconstexpr

Definition at line 67 of file norm_traits.hpp.

◆ space_dim_v

template<class Space >
constexpr std::size_t linalg::space_dim_v
inlineconstexpr
Initial value:
=
space_traits<remove_cvref_t<Space>>::DIM

Finite coordinate dimension after cv/ref normalization.

Definition at line 91 of file space_traits.hpp.

◆ sqrt2_v

template<Field T>
constexpr T linalg::sqrt2_v {T(1.414213562373095048801688724209698079L)}
inlineconstexpr

Definition at line 13 of file constants.hpp.

◆ vector_dim_v

template<class Vec >
constexpr std::size_t linalg::vector_dim_v = vector_traits_t<Vec>::dim
inlineconstexpr

Registered compile-time vector dimension.

Definition at line 70 of file vector_traits.hpp.