akreon-linalg
Fixed-size linear algebra and numerical methods in C++26.
Loading...
Searching...
No Matches
matrix_pencil.hpp
Go to the documentation of this file.
1/*
2 * Copyright © 2025-2026 Akreon LLC
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#pragma once
7
9
10namespace linalg {
11
12template <SquareMatrix Mat, std::size_t Dim>
17
27 template <MatrixContainer FullMat, typename Fn>
28 constexpr auto apply_full(const Fn& op) const {
29 static constexpr std::size_t Rows = mat_rows_v<FullMat>;
30 static constexpr std::size_t Cols = mat_cols_v<FullMat>;
31 Fs F_blks{};
32 for (std::size_t i = 0, idx = 0; i < Rows; ++i) {
33 for (std::size_t j = 0; j < Cols; ++j, ++idx) {
34 FullMat E{};
35 E(i, j) = T(1);
36 F_blks(idx) = op(E);
37 }
38 }
39 return F_blks;
40 }
41
51 template <SquareMatrix SymMat, typename Fn>
52 constexpr auto apply_sym_mat(const Fn& op) const {
53 static constexpr std::size_t N = mat_rows_v<SymMat>;
54
55 Fs F_blks{};
56 for (std::size_t i = 0, idx = 0; i < N; ++i) {
57 for (std::size_t j = 0; j <= i; ++j) {
58 SymMat E{};
59 if (i == j) E(i, j) = T(1);
60 else E(i, j) = E(j, i) = linalg::inv_sqrt2_v<T>;
61
62 F_blks(idx++) = op(E);
63 }
64 }
65 return F_blks;
66 }
67};
68
69} // namespace linalg
constexpr std::size_t mat_rows_v
Registered compile-time row count after cv/ref normalization.
typename mat_traits< remove_cvref_t< Mat > >::value_type matrix_scalar_t
Registered matrix scalar type after cv/ref normalization.
constexpr auto apply_full(const Fn &op) const
apply_full
constexpr auto apply_sym_mat(const Fn &op) const
apply symmetric matrix basis
matrix_scalar_t< Mat > T
extracting alias and types
Owning, fixed-size vector container.
Definition vector.hpp:36