20 typename T, std::size_t ROWS, std::size_t COLS,
21 typename =
typename std::enable_if<ROWS >= 1 && COLS >= 1>::type
27 template <typename = typename std::enable_if<std::is_arithmetic<T>::value && ROWS == COLS>::type>
30 for (std::size_t i = 0; i < ROWS; ++i) {
31 mat.
data[i][i] = T(1);
40 template<typename = typename std::enable_if<ROWS == COLS>::type>
43 for (std::size_t i = 0; i < ROWS; ++i)
44 mat.
data[i][i] = values[i];
50 const T&
operator()(std::size_t i, std::size_t j)
const {
return data[i][j]; }
53 template <typename = typename std::enable_if<std::is_arithmetic<T>::value && ROWS == COLS>::type>
56 for (std::size_t i = 0; i < ROWS; ++i)
57 for (std::size_t j = 0; j < COLS; ++j)
63 template <typename = typename std::enable_if<std::is_arithmetic<T>::value && ROWS == COLS>::type>
66 for (std::size_t i = 0; i < ROWS; ++i)
67 for (std::size_t j = 0; j < COLS; ++j)
72 template <typename = typename std::enable_if<std::is_arithmetic<T>::value && ROWS == COLS>::type>
75 for (std::size_t i = 0; i < ROWS; ++i)
76 for (std::size_t j = 0; j < COLS; ++j)
82 template <std::size_t OTHER_COLS, typename = typename std::enable_if<std::is_arithmetic<T>::value && ROWS == COLS>::type>
85 for (std::size_t i = 0; i < ROWS; ++i)
86 for (std::size_t j = 0; j < OTHER_COLS; ++j)
87 for (std::size_t k = 0; k < COLS; ++k)
93 template <typename = typename std::enable_if<std::is_arithmetic<T>::value && ROWS == COLS>::type>
95 for (std::size_t i = 0; i < ROWS; ++i)
96 for (std::size_t j = 0; j < COLS; ++j)
101 template <typename = typename std::enable_if<std::is_arithmetic<T>::value && ROWS == COLS>::type>
104 for (std::size_t i = 0; i < ROWS; ++i)
105 for (std::size_t j = 0; j < COLS; ++j)
106 result.
data[i][j] =
data[i][j] / scalar;
110 template <typename = typename std::enable_if<std::is_arithmetic<T>::value && ROWS == COLS>::type>
112 for (std::size_t i = 0; i < ROWS; ++i)
113 for (std::size_t j = 0; j < COLS; ++j)
114 data[i][j] *= scalar;
118 template <typename = typename std::enable_if<std::is_arithmetic<T>::value && ROWS == COLS>::type>
120 for (std::size_t i = 0; i < ROWS; ++i)
121 for (std::size_t j = 0; j < COLS; ++j)
122 data[i][j] /= scalar;
126 template <typename = typename std::enable_if<std::is_arithmetic<T>::value && ROWS == COLS>::type>
128 for (std::size_t i = 0; i < ROWS; ++i)
129 for (std::size_t j = 0; j < COLS; ++j)
134 template <typename = typename std::enable_if<std::is_arithmetic<T>::value && ROWS == COLS>::type>
137 for (std::size_t i = 0; i < ROWS; ++i)
138 for (std::size_t j = 0; j < COLS; ++j)
139 result.
data[i][j] =
data[i][j] * scalar;
145 for (std::size_t i = 0; i < ROWS; ++i)
146 for (std::size_t j = 0; j < COLS; ++j)
Matrix< double, 3, 3 > Matrix3x3
Definition Matrix.hpp:154
Matrix< double, 4, 4 > Matrix4x4
Definition Matrix.hpp:155
static Matrix diagonal(const T(&values)[ROWS])
Definition Matrix.hpp:41
Matrix & operator+=(const Matrix &other)
Definition Matrix.hpp:94
Matrix operator-() const
Definition Matrix.hpp:54
Matrix transpose() const
Definition Matrix.hpp:143
static Matrix identity()
Definition Matrix.hpp:28
Matrix operator-(const Matrix &other) const
Definition Matrix.hpp:73
Matrix operator/(T scalar) const
Definition Matrix.hpp:102
Matrix & operator/=(T scalar)
Definition Matrix.hpp:119
double data[ROWS][COLS]
Definition Matrix.hpp:24
const T & operator()(std::size_t i, std::size_t j) const
Definition Matrix.hpp:50
Matrix operator*(T scalar) const
Definition Matrix.hpp:135
Matrix operator+(const Matrix &other) const
Definition Matrix.hpp:64
Matrix & operator-=(const Matrix &other)
Definition Matrix.hpp:127
Matrix & operator*=(T scalar)
Definition Matrix.hpp:111
static Matrix zero()
Definition Matrix.hpp:36
T & operator()(std::size_t i, std::size_t j)
Definition Matrix.hpp:49
Matrix< T, ROWS, OTHER_COLS > operator*(const Matrix< T, COLS, OTHER_COLS > &other) const
Definition Matrix.hpp:83