MatrixNxM
The MatrixNxM type provides a highly optimized and flexible container for arbitrary matrix mathematics. It supports efficient storage, manipulation, and composition of matrix operations, and is designed for performance-critical applications such as graphics, physics, and simulation.
MatrixNxM has the same alignment as its underlying type.
It is possible to specify a matrix size smaller than the underlying storage for optimization purposes.
SIMD types can be used as template parameters for structure of array (SOA) calculations.
#include <math/TellusimNumerical.h>
Variables
Type | Name | Description |
---|---|---|
VectorN<N> | rows[M] | Vector access. |
Constructors
MatrixNxM()
MatrixNxM(const MatrixNxM &matrix)
MatrixNxM(uint32_t columns, uint32_t rows)
explicit MatrixNxM(const Type &value, uint32_t columns = N, uint32_t rows = M)
explicit MatrixNxM(const Type *matrix, uint32_t columns = N, uint32_t rows = M)
explicit MatrixNxM(const VectorN<N * M> &vector, uint32_t columns = N, uint32_t rows = M)
explicit MatrixNxM(const InitializerList<Type> &list, uint32_t columns = N, uint32_t rows = M)
explicit MatrixNxM(const InitializerList<VectorN<N>> &list, uint32_t rows = M)
explicit MatrixNxM(const MatrixNxM<CType, N, M> &matrix)
Methods
Update matrix data.
void set(const Type &value, uint32_t columns = N, uint32_t rows = M)
void set(const Type *matrix, uint32_t columns = N, uint32_t rows = M)
void set(const MatrixNxM &matrix)
void set(const VectorN<N * M> &vector, uint32_t columns = N, uint32_t rows = M)
void set(const InitializerList<Type> &list, uint32_t columns = N, uint32_t rows = M)
void set(const InitializerList<VectorN<N>> &list, uint32_t rows = M)
void get(Type *matrix, uint32_t columns = N, uint32_t rows = M)
Zero matrix.
void setZero()
Identity matrix.
void setIdentity()
Matrix to scalar operators.
MatrixNxM &operator*=(const Type &value)
MatrixNxM &operator/=(const Type &value)
Matrix to matrix operators.
MatrixNxM &operator=(const MatrixNxM &matrix)
Matrix rows.
void setRow(uint32_t index, const VectorN<N> &r)
const VectorN<N> &getRow(uint32_t index) const
VectorN<N> &getRow(uint32_t index)
Matrix columns.
void setColumn(uint32_t index, const VectorN<M> &c)
VectorN<M> getColumn(uint32_t index) const
Matrix data.
const VectorN<N> &operator[](uint32_t index) const
VectorN<N> &operator[](uint32_t index)
Operators
Unary operators.
MatrixNxM operator-(const MatrixNxM &m)
Matrix to scalar operators.
MatrixNxM operator*(const MatrixNxM &m, const Type &v)
MatrixNxM operator/(const MatrixNxM &m, const Type &v)
Matrix to matrix operators.
MatrixNxM operator+(const MatrixNxM &m0, const MatrixNxM &m1)
MatrixNxM operator-(const MatrixNxM &m0, const MatrixNxM &m1)
Matrix to vector multiplications.
VectorN<M> operator*(const MatrixNxM<N, M> &m, const VectorN<N> &v) {
Vector to matrix multiplications.
VectorN<N> operator*(const VectorN<M> &v, const MatrixNxM<N, M> &m) {
Matrix to matrix multiplications.
MatrixNxM<N, M> operator*(const MatrixNxM<K, M> &m0, const MatrixNxM<N, K> &m1)
Comparison operators.
bool operator==(const MatrixNxM &m0, const MatrixNxM &m1)
bool operator!=(const MatrixNxM &m0, const MatrixNxM &m1)
bool compare(const MatrixNxM &m0, const MatrixNxM &m1, const Type &a)
bool compare(const MatrixNxM &m0, const MatrixNxM &m1, const Type &a, const Type &r)
Functions
Matrix functions.
MatrixNxM<N, N> diagonal(const VectorN<N> &v)
MatrixNxM<M, N> transpose(const MatrixNxM<N, M> &m)
MatrixNxM flipX(const MatrixNxM &m)
MatrixNxM flipY(const MatrixNxM &m)
Computes eigenvectors and eigenvalues of symmetric matrix.
MatrixNxM<N, N> jacobi(const MatrixNxM<N, N> &m, MatrixNxM<N, N> &v, Type threshold = 1e-6f)