24template <std::
size_t Start, std::
size_t End, VectorContainer Vec>
38template <Field T, std::
size_t N>
41 for (std::size_t
i = 0;
i < N; ++
i)
I(
i,
i) = T(1);
50template <Field T, std::
size_t Rows, std::
size_t Cols>
53 for (std::size_t
i = 0;
i < Rows; ++
i)
54 for (std::size_t
j = 0;
j < Cols; ++
j)
Z(
i,
j) = T(0);
65template <VectorContainer Vec>
70 for (std::size_t
i = 0;
i < N; ++
i)
A(
i, 0) =
X(
i);
81template <VectorContainer Vec>
86 for (std::size_t
i = 0;
i < N; ++
i)
A(0,
i) =
X(
i);
97template <MatrixContainer Mat>
104 for (std::size_t
i = 0;
i < Rows; ++
i)
105 for (std::size_t
j = 0;
j < Cols; ++
j)
120template <Field T, std::
size_t N>
123 for (std::size_t
i = 0;
i < N; ++
i)
res(
i) =
A(
i, 0);
134template <Field T, std::
size_t N>
137 for (std::size_t
i = 0;
i < N; ++
i)
res(
i) =
A(0,
i);
149template <MatrixContainer Mat>
155 for (std::size_t
i = 0;
i < Rows; ++
i)
X(
i) =
A(
i,
idx);
167template <MatrixContainer Mat>
180template <MatrixContainer Mat>
185 constexpr std::size_t
mn = std::min(Rows, Cols);
198template <Field T, std::
size_t N>
201 for (std::size_t
i = 0;
i < N; ++
i)
diag(
i,
i) =
X(
i);
212template <std::
size_t Start, std::
size_t End, MatrixContainer Mat>
230template <std::
size_t Start, std::
size_t End, MatrixContainer Mat>
237 for (std::size_t row = 0; row < Rows; ++row)
result(row,
idx) =
A(row,
col);
252 std::size_t
EndCol, MatrixContainer Mat>
276 std::size_t
EndCol, MatrixContainer Mat>
295template <MatrixContainer Mat>
300 for (std::size_t
i = 0;
i < Rows; ++
i)
301 for (std::size_t
j =
i;
j < Cols; ++
j) R(
i,
j) =
A(
i,
j);
312template <MatrixContainer Mat>
317 for (std::size_t
i = 0;
i < Cols; ++
i)
318 for (std::size_t
j =
i;
j < Rows; ++
j) L(
j,
i) =
A(
j,
i);
330template <VectorContainer Vec>
343template <VectorContainer Vec>
357template <FieldVector Vec>
372template <Field T, std::
size_t Rows, std::
size_t Cols>
377 for (std::size_t
i = 0;
i < Rows; ++
i)
391template <MatrixContainer MatA, MatrixContainer MatB>
398 for (std::size_t
i = 0;
i < Rows; ++
i)
410template <std::
size_t N, FieldVector Vec>
415 for (std::size_t
i = 0;
i < N; ++
i) {
416 for (std::size_t
j = 0;
j <=
i; ++
j) {
417 const auto idx =
i * (
i + 1) / 2 +
j;
424 for (std::size_t
i = 0;
i < N; ++
i) {
425 for (std::size_t
j = 0;
j < N; ++
j) {
445template <SquareMatrix Mat>
449 static constexpr std::size_t
K = N * (N + 1) / 2;
451 for (std::size_t
i = 0,
k = 0;
i < N; ++
i)
452 for (std::size_t
j = 0;
j <=
i; ++
j, ++
k)
vec(
k) =
A(
i,
j);
466template <SquareMatrix Mat>
470 static constexpr std::size_t
K = N * (N + 1) / 2;
472 for (std::size_t
i = 0,
k = 0;
i < N; ++
i) {
473 for (std::size_t
j = 0;
j <=
i; ++
j, ++
k) {
486template <SquareMatrix Mat>
500template <SquareMatrix Mat>
518template <SquareMatrix Mat>
522 static constexpr std::size_t
K = N * (N + 1) / 2 - N;
524 for (std::size_t
i = 0,
k = 0;
i < N; ++
i)
525 for (std::size_t
j = 0;
j <
i; ++
j, ++
k)
vec(
k) =
A(
i,
j);
539template <SquareMatrix Mat, VectorContainer Vec>
545 "Invalid vector size to make lower triangle of square matrix");
547 for (std::size_t
i = 0,
k = 0;
i < N; ++
i) {
549 for (;
j <
i; ++
j, ++
k) L(
i,
j) = x(
k);
550 if (
i ==
j) L(
i,
j) = T(1);
566template <SquareMatrix Mat, VectorContainer Vec>
571 "Invalid vector size to make lower triangle of square matrix");
574 for (std::size_t
i = 0,
k = 0;
i < N; ++
i)
575 for (std::size_t
j = 0;
j <
i + 1; ++
j, ++
k) L(
i,
j) = x(
k);
Field classified by scalar_traits as real.
constexpr auto get_svec(const Mat &A)
get svec encoding of a symmetric matrix
constexpr auto get_diag(const Mat &A)
get the diagonal of a matrix A
constexpr auto symmetric_part(const Mat &A)
symmetric part of a square matrix
constexpr auto make_unit_lower_triangle(const Vec &x)
Construct a unit lower-triangular matrix from strict-lower entries.
typename vector_traits_t< Vec >::element_type vector_element_t
Registered vector coordinate type.
typename scalar_traits_t< T >::real_type real_type_t
Associated real component type registered for T.
constexpr auto get_lower_triangle(const Mat &A)
get lower triangle
constexpr auto get_row(const Mat &A, std::size_t idx)
get the row of matrix A based on given index
constexpr auto as_row_vector(const Vec &X)
express the vector X as a row vector (1 x N)
constexpr auto as_complex_matrix(const Mat &A)
express matrix as complex one
constexpr auto as_vector(const ColVector< T, N > &A)
express col vector as vector
constexpr auto make_diag(const Vector< T, N > &X)
make a diagonal matrix from a vector
constexpr Matrix< T, N, N > make_identity()
create an identity matrix of size N type T
constexpr auto make_smat(const Vec &L)
make symmetric matrix
constexpr auto get_lower_left_triangular_matrix(const Mat &A)
get lower left triangular matrix from A
constexpr auto transpose(const Vec &x)
tranpose of a vector
constexpr auto get_lower_triangle_with_diag(const Mat &A)
get lower triangle with diag
constexpr auto get_n_rows(const Mat &A)
Copy the half-open matrix row range [Start, End).
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
constexpr auto make_svec(const Mat &A)
Compatibility spelling for get_svec(A).
constexpr Matrix< T, Rows, Cols > make_zeros()
create a matrix filled with zeros of size Rows x Cols of type T
constexpr auto get_block(const Mat &A)
Copy a compile-time rectangular matrix block.
constexpr std::size_t mat_rows_v
Registered compile-time row count after cv/ref normalization.
constexpr auto get_elements(const Vec &x)
Copy the half-open vector slice [Start, End).
constexpr auto manhattan_distance(const Vec &X, const Vec &Y)
Compute the manhattan distance between two vectors (L1 norm of delta)
constexpr auto make_lower_triangle(const Vec &x)
Construct a lower-triangular matrix including its diagonal.
constexpr auto get_col(const Mat &A, std::size_t idx)
get the column of matrix A based on given index
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...
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.
constexpr auto euclidean_distance(const Vec &X, const Vec &Y)
Compute the euclidean distance between two vectors (L2 norm of delta)
constexpr auto get_n_cols(const Mat &A)
Copy the half-open matrix column range [Start, End).
typename mat_traits< remove_cvref_t< Mat > >::value_type matrix_scalar_t
Registered matrix scalar type after cv/ref normalization.
constexpr auto as_col_vector(const Vec &X)
express the vector X as a column vector (N x 1)
constexpr auto get_upper_right_triangular_matrix(const Mat &A)
get upper right triangular matrix from A
Owning, fixed-size, row-major matrix container over a scalar field.
Owning, fixed-size vector container.