21template <
int _rows,
int _cols,
typename T =
float>
22 requires(std::is_arithmetic_v<T> &&
_rows > 0 &&
_cols > 0)
56 this->data =
mat.data;
61 this->data = std::move(
mat.data);
64 template <
typename Ty>
65 requires(std::is_arithmetic_v<Ty>)
70 data[
i][
j] =
static_cast<T
>(
mat.data[
i][
j]);
105 constexpr const std::array<T, _cols> &operator[](
int row)
const
123 data = std::move(
mat.data);
163 template <
typename Ty>
164 requires(std::is_arithmetic_v<Ty>)
181 template <
typename Ty>
182 requires(std::is_arithmetic_v<Ty>)
230 template <
typename Ty>
231 requires(std::is_arithmetic_v<Ty>)
249 template <
typename Ty>
250 requires(std::is_arithmetic_v<Ty>)
263 template <
typename Ty>
264 requires(std::is_arithmetic_v<Ty>)
301 return data ==
mat.data;
308 for (
int i = 0;
i < rows;
i++)
310 res.data[
i].begin());
381 static_assert(
_cols ==
_rows,
"Matrix must be square");
431 return Matrix(
static_cast<T
>(0));
442 return Matrix(
static_cast<T
>(1));
479 std::array<std::array<T, _cols>,
_rows> data;
constexpr Matrix(const T *data)
Constructor with input data
constexpr uint32_t cols() const
return the column size of the matrix
constexpr Matrix operator+(const Matrix &mat) const
Additonal operator
constexpr std::array< T, _cols > & operator[](int row)
Return the element of the matrix
constexpr uint32_t rows() const
returns the row size of the matrix
constexpr Matrix inv() const
Get the inverse of the matrix
static constexpr Matrix eye()
Returns a _rows * columns matrix
~Matrix()=default
Destructor
static constexpr Matrix zeros()
Returns a _rows x _cols zero matrix
constexpr Matrix< _rows, 1, T > col(int col) const
Return the specific row of the matrix
constexpr Matrix & operator=(const Matrix &mat)
Copy assignment of the matrix(row * size) instance
constexpr Matrix clone() const
constexpr Matrix(const Matrix &mat)
Copy Constructor
constexpr Matrix & operator-=(const Matrix &mat)
Substraction operator of two matrices(row * size)
constexpr Matrix< _cols, _rows > trans() const
Get the transpose of the matrix
constexpr T trace() const
Get the trace of the matrix
constexpr bool operator==(const Matrix &mat) const
Compare whether two matrices are identical
static constexpr Matrix ones()
Returns a _rows x _cols one matrix
constexpr Matrix< 1, _cols, T > row(int row) const
Return the specific row of the matrix
constexpr Matrix & operator+=(const Matrix &mat)
Additional operator of two matrices(row * size)
constexpr friend Matrix< _rows, cols2, T > operator*(const Matrix< _rows, _cols, T > &mat1, const Matrix< _cols, cols2, T > &mat2)
The matrix multiplication
constexpr Matrix()=default
Constructor without input data
constexpr Matrix operator-(const Matrix &mat) const
Substraction matrix
static constexpr Matrix diag(Matrix< _rows, 1 > vec)
Returns a _rows x _cols diagonal matrix
asio::awaitable< T > awaitable
协程任务类型。