12#include "../detail/utils.hpp"
21template<
typename _Scalar, std::
size_t _Rows, std::
size_t _Cols>
22struct StaticMatrix :
public std::array<std::array<_Scalar, _Cols>, _Rows>
25 static constexpr std::size_t
Rows = _Rows;
27 static constexpr std::size_t
Cols = _Cols;
29 using std::array<std::array<_Scalar, _Cols>, _Rows>::operator[];
34 constexpr StaticMatrix() : std::array<std::array<_Scalar, _Cols>, _Rows>{}
36 for (
auto i = 0u; i != _Rows; ++i) { operator[](i).fill(_Scalar(0)); }
42 template<std::
size_t _NRows, std::
size_t _NCols>
46 for (
auto i = 0u; i < _NRows; ++i) {
47 for (
auto j = 0u; j < _NCols; ++j) { ret[i][j] = operator[](row0 + i)[col0 + j]; }
58 for (
auto i = 0u; i < _Rows; ++i) {
59 for (
auto j = 0u; j < _Cols; ++j) { ret[i][j] = operator[](i)[j] + o[i][j]; }
70 for (
auto i = 0u; i < _Rows; ++i) {
71 for (
auto j = 0u; j < _Cols; ++j) { ret[j][i] = operator[](i)[j]; }
79 template<std::
size_t _NCols>
83 for (
auto i = 0u; i < _Rows; ++i) {
84 for (
auto j = 0u; j < _NCols; ++j) {
85 for (
auto k = 0u; k < _Cols; ++k) { ret[i][j] += operator[](i)[k] * o[k][j]; }
Elementary structure for compile-time matrix algebra.
constexpr StaticMatrix< _Scalar, _NRows, _NCols > block(std::size_t row0, std::size_t col0) const
Extract sub-block of size _NRows x _NCols anchored at (row0, col0)
constexpr StaticMatrix()
Construct matrix filled with zeros.
constexpr StaticMatrix< _Scalar, _Rows, _Cols > operator+(const StaticMatrix< _Scalar, _Rows, _Cols > &o) const
Matrix addition.
constexpr StaticMatrix< _Scalar, _Rows, _Cols > transpose() const
Matrix transpose.
static constexpr std::size_t Cols
Number of columns in matrix.
constexpr StaticMatrix< _Scalar, _Rows, _NCols > operator*(const StaticMatrix< _Scalar, _Cols, _NCols > &o) const
Matrix multiplication.
static constexpr std::size_t Rows
Number of rows in matrix.