akreon-linalg
Fixed-size linear algebra and numerical methods in C++26.
Loading...
Searching...
No Matches
matrix_space.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 "coordinate_map.hpp"
9
10namespace linalg {
11
18template <Field T, std::size_t Rows, std::size_t Cols>
19struct MatrixSpace {};
20
22template <Field T, std::size_t Rows, std::size_t Cols>
23struct space_traits<MatrixSpace<T, Rows, Cols>> {
25 using scalar_type = T;
31 static constexpr std::size_t dim = Rows * Cols;
33 static constexpr std::size_t DIM = dim;
34};
35
41template <Field T, std::size_t Rows, std::size_t Cols>
42struct coordinate_map<MatrixSpace<T, Rows, Cols>> {
43 static constexpr auto to_coordinates(const Matrix<T, Rows, Cols>& element) {
45 for (std::size_t row = 0; row < Rows; ++row)
46 for (std::size_t col = 0; col < Cols; ++col)
47 coordinate(row * Cols + col) = element(row, col);
48 return coordinate;
49 }
50
51 static constexpr auto from_coordinates(
54 for (std::size_t row = 0; row < Rows; ++row)
55 for (std::size_t col = 0; col < Cols; ++col)
56 element(row, col) = coordinate(row * Cols + col);
57 return element;
58 }
59};
60
61} // namespace linalg
constexpr std::size_t mat_rows_v
Registered compile-time row count after cv/ref normalization.
Space of all Rows x Cols matrices over field T.
Owning, fixed-size, row-major matrix container over a scalar field.
Definition matrix.hpp:44
Owning, fixed-size vector container.
Definition vector.hpp:36
static constexpr auto to_coordinates(const Matrix< T, Rows, Cols > &element)
static constexpr auto from_coordinates(const Vector< T, Rows *Cols > &coordinate)
Customization point mapping space elements to finite coordinates.
Customization point for finite-dimensional space metadata.