akreon-linalg
Fixed-size linear algebra and numerical methods in C++26.
Loading...
Searching...
No Matches
linalg_util.hpp File Reference
Include dependency graph for linalg_util.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  linalg
 

Functions

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)
 Copy the half-open vector slice [Start, End).
 
template<Field T, std::size_t N>
constexpr Matrix< T, N, N > linalg::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 > linalg::make_zeros ()
 create a matrix filled with zeros of size Rows x Cols of type T
 
template<VectorContainer Vec>
constexpr auto linalg::as_col_vector (const Vec &X)
 express the vector X as a column vector (N x 1)
 
template<VectorContainer Vec>
constexpr auto linalg::as_row_vector (const Vec &X)
 express the vector X as a row vector (1 x N)
 
template<MatrixContainer Mat>
constexpr auto linalg::as_complex_matrix (const Mat &A)
 express matrix as complex one
 
template<Field T, std::size_t N>
constexpr auto linalg::as_vector (const ColVector< T, N > &A)
 express col vector as vector
 
template<Field T, std::size_t N>
constexpr auto linalg::as_vector (const RowVector< T, N > &A)
 express row vector as vector
 
template<MatrixContainer Mat>
constexpr auto linalg::get_col (const Mat &A, std::size_t idx)
 get the column of matrix A based on given index
 
template<MatrixContainer Mat>
constexpr auto linalg::get_row (const Mat &A, std::size_t idx)
 get the row of matrix A based on given index
 
template<MatrixContainer Mat>
constexpr auto linalg::get_diag (const Mat &A)
 get the diagonal of a matrix A
 
template<Field T, std::size_t N>
constexpr auto linalg::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 linalg::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 linalg::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 linalg::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 linalg::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 linalg::get_upper_right_triangular_matrix (const Mat &A)
 get upper right triangular matrix from A
 
template<MatrixContainer Mat>
constexpr auto linalg::get_lower_left_triangular_matrix (const Mat &A)
 get lower left triangular matrix from A
 
template<VectorContainer Vec>
constexpr auto linalg::euclidean_distance (const Vec &X, const Vec &Y)
 Compute the euclidean distance between two vectors (L2 norm of delta)
 
template<VectorContainer Vec>
constexpr auto linalg::manhattan_distance (const Vec &X, const Vec &Y)
 Compute the manhattan distance between two vectors (L1 norm of delta)
 
template<FieldVector Vec>
constexpr bool linalg::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 linalg::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 linalg::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 linalg::make_smat (const Vec &L)
 make symmetric matrix
 
template<SquareMatrix Mat>
constexpr auto linalg::get_lower_triangle_with_diag (const Mat &A)
 get lower triangle with diag
 
template<SquareMatrix Mat>
constexpr auto linalg::get_svec (const Mat &A)
 get svec encoding of a symmetric matrix
 
template<SquareMatrix Mat>
constexpr auto linalg::make_svec (const Mat &A)
 Compatibility spelling for get_svec(A).
 
template<SquareMatrix Mat>
constexpr auto linalg::symmetric_part (const Mat &A)
 symmetric part of a square matrix
 
template<SquareMatrix Mat>
constexpr auto linalg::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 linalg::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 linalg::make_lower_triangle (const Vec &x)
 Construct a lower-triangular matrix including its diagonal.