akreon-linalg
Fixed-size linear algebra and numerical methods in C++26.
Loading...
Searching...
No Matches
quadratic_rep.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
8#include <functional>
9
11
12namespace linalg {
13
26template <SquareMatrix JxJ, typename Circ>
30 static constexpr std::size_t N = mat_rows_v<JxJ>;
31 using J = Vector<T, N>;
32
38 constexpr explicit QuadraticRep(const J& x_in) : x(x_in) {}
39
51 constexpr auto apply(const J& y) const {
52 const Circ circ;
53 return T(2) * circ(x, circ(x, y)) - circ(circ(x, x), y);
54 }
55
65 template <MatrixContainer MatX>
66 requires(N == mat_rows_v<MatX>)
67 constexpr auto apply(const MatX& Y) const {
68 constexpr std::size_t Cols = mat_cols_v<MatX>;
70 for (std::size_t j = 0; j < Cols; ++j) {
71 const auto y_col = get_col(Y, j);
72 const auto p_y_col = apply(y_col);
73 for (std::size_t i = 0; i < N; ++i) result(i, j) = p_y_col(i);
74 }
75 return result;
76 }
77
79 J x;
80};
81
82} // namespace linalg
constexpr std::size_t mat_rows_v
Registered compile-time row count after cv/ref normalization.
constexpr auto get_col(const Mat &A, std::size_t idx)
get the column of matrix A based on given index
typename mat_traits< remove_cvref_t< Mat > >::value_type matrix_scalar_t
Registered matrix scalar type after cv/ref normalization.
Owning, fixed-size, row-major matrix container over a scalar field.
Definition matrix.hpp:44
forward declaration of P(x) / P(x^{-1})
constexpr QuadraticRep(const J &x_in)
CTOR.
constexpr auto apply(const J &y) const
apply
constexpr auto apply(const MatX &Y) const
apply column-wise to a matrix
matrix_scalar_t< JxJ > T
extract type & sizes
static constexpr std::size_t N
Owning, fixed-size vector container.
Definition vector.hpp:36