12template <
typename T, std::
size_t Rows, std::
size_t Cols>
16 using data_t = std::array<T, Rows * Cols>;
20 for (
size_t i = 0; i < Rows; ++i) {
28 Mat(
const std::array<std::array<T, Cols>, Rows>& rows) {
29 for (
auto row = 0; row < Rows; ++row) {
30 for (
auto col = 0; col < Cols; ++col) {
31 at(col, row) = rows.at(row).at(col);
44 for (
size_t row = 0; row < Cols; ++row) {
45 for (
size_t col = 0; col < Rows; ++col) {
46 result.
at(col, row) = 0;
47 for (
size_t k = 0; k < Cols; ++k) {
48 result.at(col, row) +=
at(k, row) * rhs.
at(col, k);
60 for (
auto r = 0; r < Rows; ++r) {
61 for (
auto c = 0; c < Cols; ++c) {
62 res.
at(r) += rhs.
at(c) *
at(c, r);
69 auto at(std::size_t col, std::size_t row) -> T& {
72 [[nodiscard]]
auto at(std::size_t col, std::size_t row)
const ->
const T& {
79 constexpr static auto get_index(std::size_t col, std::size_t row) {
80 return row + Rows * col;
83 std::array<T, Rows * Cols>
data_{};
91 for (
auto row = 0; row < 3; ++row) {
92 for (
auto col = 0; col < 3; ++col) {
93 at(col, row) = other.
at(col, row);
static constexpr auto get_index(std::size_t col, std::size_t row)
Definition matrix.hpp:79
auto data() const
Definition matrix.hpp:76
auto operator*(const Vec< T, Rows > &rhs)
Definition matrix.hpp:55
static constexpr auto identity()
Definition matrix.hpp:18
auto operator!=(const mat_t &rhs) const
Definition matrix.hpp:38
auto operator==(const mat_t &rhs) const
Definition matrix.hpp:37
Mat(const data_t &data)
Definition matrix.hpp:27
auto operator*(const mat_t &rhs)
Definition matrix.hpp:39
std::array< T, Rows *Cols > data_t
Definition matrix.hpp:16
auto at(std::size_t col, std::size_t row) const -> const T &
Definition matrix.hpp:72
std::array< T, Rows *Cols > data_
Definition matrix.hpp:83
auto at(std::size_t col, std::size_t row) -> T &
Definition matrix.hpp:69
Mat(const std::array< std::array< T, Cols >, Rows > &rows)
Definition matrix.hpp:28
Definition geometry.hpp:8
Mat4f(const Mat< float, 4, 4 > &other)
Definition matrix.hpp:88
Mat4f(const Mat< float, 3, 3 > &other)
Definition matrix.hpp:90
Mat4f(const data_t &data)
Definition matrix.hpp:89
auto at(std::size_t i) -> T &
Definition vector.hpp:28