12 template <u
int8_t Rows, u
int8_t Columns,
typename T =
float>
19 constexpr
Matrix() =
default;
23 Matrix(std::initializer_list<T> list);
32 constexpr uint8_t
getRows()
const;
39 constexpr
const T&
operator()(uint8_t row, uint8_t col = 0)
const;
51 #if defined(LUG_COMPILER_MSVC) 53 template <typename = typename std::enable_if<(Rows == Columns)>::type>
56 template <typename = typename std::enable_if<(Rows == Columns)>::type>
61 template <
bool EnableBool = true>
64 template <
bool EnableBool = true>
69 #if defined(LUG_COMPILER_MSVC) 71 template <typename = typename std::enable_if<(Rows == 1)>::type>
74 template <typename = typename std::enable_if<(Rows == 2)>::type,
typename =
void>
77 template <typename = typename std::enable_if<(Rows == 3)>::type,
typename = void,
typename =
void>
80 template <typename = typename std::enable_if<(Rows == 4)>::type,
typename = void,
typename = void,
typename =
void>
85 template <
bool EnableBool = true>
86 typename std::enable_if<(Rows == 1) && EnableBool, Matrix<Rows, Columns, T>>::type
inverse()
const;
88 template <
bool EnableBool = true>
89 typename std::enable_if<(Rows == 2) && EnableBool, Matrix<Rows, Columns, T>>::type
inverse()
const;
91 template <
bool EnableBool = true>
92 typename std::enable_if<(Rows == 3) && EnableBool, Matrix<Rows, Columns, T>>::type
inverse()
const;
94 template <
bool EnableBool = true>
95 typename std::enable_if<(Rows == 4) && EnableBool, Matrix<Rows, Columns, T>>::type
inverse()
const;
101 #if defined(LUG_COMPILER_MSVC) 103 template <typename = typename std::enable_if<(Rows == 1)>::type>
106 template <typename = typename std::enable_if<(Rows == 2)>::type,
typename =
void>
109 template <typename = typename std::enable_if<(Rows == 3)>::type,
typename = void,
typename =
void>
112 template <typename = typename std::enable_if<(Rows == 4)>::type,
typename = void,
typename = void,
typename =
void>
115 template <
typename =
typename std::enable_if<(Rows > 4)>::type,
typename = void,
typename = void,
typename = void,
typename =
void>
120 template <
bool EnableBool = true>
121 typename std::enable_if<(Rows == 1) && EnableBool, T>::type
det()
const;
123 template <
bool EnableBool = true>
124 typename std::enable_if<(Rows == 2) && EnableBool, T>::type
det()
const;
126 template <
bool EnableBool = true>
127 typename std::enable_if<(Rows == 3) && EnableBool, T>::type
det()
const;
129 template <
bool EnableBool = true>
130 typename std::enable_if<(Rows == 4) && EnableBool, T>::type
det()
const;
132 template <
bool EnableBool = true>
133 typename std::enable_if<(Rows > 4) && EnableBool, T>::type
det()
const;
137 #if defined(LUG_COMPILER_MSVC) 139 template <typename = typename std::enable_if<(Rows == Columns)>::type>
144 template <
bool EnableBool = true>
145 static typename std::enable_if<(Rows == Columns) && EnableBool, Matrix<Rows, Columns, T>>::type
identity();
153 #define DEFINE_LENGTH_MATRIX(rows, columns) \ 154 template <typename T = float> \ 155 using Mat##rows##x##columns= Matrix<rows, columns, T>; \ 157 template class LUG_MATH_API Matrix<rows, columns, float>; \ 158 using Mat##rows##x##columns##f = Mat##rows##x##columns<float>; \ 160 template class LUG_MATH_API Matrix<rows, columns, double>; \ 161 using Mat##rows##x##columns##d = Mat##rows##x##columns<double>; \ 163 template class LUG_MATH_API Matrix<rows, columns, int32_t>; \ 164 using Mat##rows##x##columns##i = Mat##rows##x##columns<int32_t>; \ 166 template class LUG_MATH_API Matrix<rows, columns, uint32_t>; \ 167 using Mat##rows##x##columns##u = Mat##rows##x##columns<uint32_t>; 179 #undef DEFINE_LENGTH_MATRIX 182 template <u
int8_t Rows, u
int8_t Columns,
typename T>
183 Matrix<Rows, Columns, T>
operator-(
const Matrix<Rows, Columns, T>& lhs);
186 template <u
int8_t Rows, u
int8_t Columns,
typename T>
187 Matrix<Rows, Columns, T>
operator+(
const Matrix<Rows, Columns, T>& lhs, T rhs);
189 template <u
int8_t Rows, u
int8_t Columns,
typename T>
190 Matrix<Rows, Columns, T>
operator-(
const Matrix<Rows, Columns, T>& lhs, T rhs);
192 template <u
int8_t Rows, u
int8_t Columns,
typename T>
193 Matrix<Rows, Columns, T>
operator*(
const Matrix<Rows, Columns, T>& lhs, T rhs);
195 template <u
int8_t Rows, u
int8_t Columns,
typename T>
196 Matrix<Rows, Columns, T>
operator/(
const Matrix<Rows, Columns, T>& lhs, T rhs);
198 template <u
int8_t Rows, u
int8_t Columns,
typename T>
199 Matrix<Rows, Columns, T>
operator+(T lhs,
const Matrix<Rows, Columns, T>& rhs);
201 template <u
int8_t Rows, u
int8_t Columns,
typename T>
202 Matrix<Rows, Columns, T>
operator-(T lhs,
const Matrix<Rows, Columns, T>& rhs);
204 template <u
int8_t Rows, u
int8_t Columns,
typename T>
205 Matrix<Rows, Columns, T>
operator*(T lhs,
const Matrix<Rows, Columns, T>& rhs);
207 template <u
int8_t Rows, u
int8_t Columns,
typename T>
208 Matrix<Rows, Columns, T>
operator/(T lhs,
const Matrix<Rows, Columns, T>& rhs);
211 template <u
int8_t Rows, u
int8_t Columns,
typename T>
212 Matrix<Rows, Columns, T>
operator+(
const Matrix<Rows, Columns, T>& lhs,
const Matrix<Rows, Columns, T>& rhs);
214 template <u
int8_t Rows, u
int8_t Columns,
typename T>
215 Matrix<Rows, Columns, T>
operator-(
const Matrix<Rows, Columns, T>& lhs,
const Matrix<Rows, Columns, T>& rhs);
217 template <u
int8_t RowsLeft, u
int8_t ColumnsLeft, u
int8_t RowsRight, u
int8_t ColumnsRight,
typename T>
218 Matrix<RowsLeft, ColumnsRight, T>
operator*(
const Matrix<RowsLeft, ColumnsLeft, T>& lhs,
const Matrix<RowsRight, ColumnsRight, T>& rhs);
220 template <u
int8_t RowsLeft, u
int8_t ColumnsLeft, u
int8_t RowsRight, u
int8_t ColumnsRight,
typename T>
221 Matrix<RowsLeft, ColumnsRight, T>
operator/(
const Matrix<RowsLeft, ColumnsLeft, T>& lhs,
const Matrix<RowsRight, ColumnsRight, T>& rhs);
224 template <u
int8_t Rows, u
int8_t Columns,
typename T>
225 bool operator==(
const Matrix<Rows, Columns, T>& lhs,
const Matrix<Rows, Columns, T>& rhs);
227 template <u
int8_t Rows, u
int8_t Columns,
typename T>
228 bool operator!=(
const Matrix<Rows, Columns, T>& lhs,
const Matrix<Rows, Columns, T>& rhs);
230 template <u
int8_t Rows, u
int8_t Columns,
typename T>
231 std::ostream& operator<<(std::ostream& os, const Matrix<Rows, Columns, T>& matrix);
bool operator!=(const Matrix< Rows, Columns, T > &lhs, const Matrix< Rows, Columns, T > &rhs)
bool operator==(const Matrix< Rows, Columns, T > &lhs, const Matrix< Rows, Columns, T > &rhs)
#define DEFINE_LENGTH_MATRIX(rows, columns)
Matrix< Columns, Rows, T > transpose() const
Matrix< Rows, Columns, T > & operator+=(T rhs)
Matrix< Rows, Columns, T > operator-(const Matrix< Rows, Columns, T > &lhs)
constexpr uint8_t getRows() const
static std::enable_if<(Rows==Columns) &&EnableBool, Matrix< Rows, Columns, T > >::type identity()
constexpr Matrix()=default
Matrix< Rows, Columns, T > operator+(const Matrix< Rows, Columns, T > &lhs, T rhs)
Matrix< Rows, Columns, T > & operator=(const Matrix< Rows, Columns, T > &rhs)=default
std::enable_if<(Rows==1) &&EnableBool, Matrix< Rows, Columns, T > >::type inverse() const
T & operator()(uint8_t row, uint8_t col=0)
constexpr uint8_t getColumns() const
Matrix< Rows, Columns, T > operator/(const Matrix< Rows, Columns, T > &lhs, T rhs)
Matrix< Rows, Columns, T > & operator*=(T rhs)
Matrix< Rows, Columns, T > & operator/=(T rhs)
std::enable_if<(Rows==1) &&EnableBool, T >::type det() const
Matrix< Rows, Columns, T > operator*(const Matrix< Rows, Columns, T > &lhs, T rhs)
Matrix< Rows, Columns, T > & operator-=(T rhs)