43template <Field T, std::
size_t Rows, std::
size_t Cols>
58 requires(
sizeof...(RowVectors) == Rows && Rows > 0 &&
63 for (std::size_t
col = 0;
col < Cols; ++
col)
76 "Matrix const access index out of bounds");
77 return elements[
row * Cols +
col];
86 "Matrix mutable access index out of bounds");
87 return elements[
row * Cols +
col];
96 constexpr auto row(std::size_t index)
const {
97 AK_ASSERT(index < Rows &&
"Matrix row index out of bounds");
99 for (std::size_t
col = 0;
col < Cols; ++
col)
105 constexpr auto begin() {
return elements.begin(); }
107 constexpr auto begin()
const {
return elements.begin(); }
109 constexpr auto end() {
return elements.end(); }
111 constexpr auto end()
const {
return elements.end(); }
113 constexpr auto view() {
return std::span<T, Rows * Cols>{elements}; }
116 return std::span<const T, Rows * Cols>{elements};
119 constexpr auto size()
const {
return Rows * Cols; }
125 std::array<T, Rows * Cols> elements{};
133template <Field T, std::size_t Cols,
typename... Rows>
137template <Field T, std::
size_t Dim>
143template <Field T, std::
size_t Dim>
156template <Field T, std::
size_t Rows, std::
size_t Cols>
157 requires(Rows == 1 || Cols == 1)
159 constexpr auto Dim = Rows == 1 ? Cols : Rows;
161 for (std::size_t
i = 0;
i <
Dim; ++
i)
std::remove_cvref_t< T > remove_cvref_t
Remove top-level const, volatile, and reference qualification.
constexpr auto as_vector(const ColVector< T, N > &A)
express col vector as vector
constexpr std::size_t mat_rows_v
Registered compile-time row count after cv/ref normalization.
constexpr auto as_row_matrix(const Vector< T, Dim > &vector)
Represent a vector as a 1 x Dim matrix.
constexpr auto as_col_matrix(const Vector< T, Dim > &vector)
Represent a vector as a Dim x 1 matrix.
Owning, fixed-size, row-major matrix container over a scalar field.
constexpr auto end() const
Const iterator one past the final flattened element.
constexpr auto end()
Iterator one past the final flattened element.
constexpr bool operator==(const Matrix &) const =default
Compare shape-compatible matrices element by element.
constexpr Matrix()=default
Construct a value-initialized matrix.
constexpr auto size() const
Number of stored scalar elements (Rows * Cols).
constexpr auto begin()
Iterator to the first element in flattened row-major order.
constexpr const T & operator()(std::size_t row, std::size_t col) const
Read an element at a zero-based row and column.
constexpr auto begin() const
Const iterator to the first element in row-major order.
constexpr auto view()
Mutable, fixed-extent view of contiguous row-major storage.
constexpr T & operator()(std::size_t row, std::size_t col)
Read or modify an element at a zero-based row and column.
constexpr Matrix(RowVectors &&... rows)
Construct by copying one fixed-size vector per matrix row.
constexpr auto row(std::size_t index) const
Copy one matrix row into a fixed-size vector.
constexpr auto view() const
Const, fixed-extent view of contiguous row-major storage.
Owning, fixed-size vector container.