Easy3D 2.6.1
|
Base class for matrix types. More...
#include <easy3d/core/mat.h>
Public Member Functions | |
Mat ()=default | |
Default constructor. | |
Mat (T s) | |
Constructs a matrix with diagonal elements set to s and other elements set to zero. | |
template<size_t rN, size_t rM> | |
Mat (const Mat< rN, rM, T > &rhs) | |
Copy constructor for matrices with different dimensions (rN >= N, rM >= M). | |
Mat (const T *m) | |
Constructs a matrix from an array of elements. | |
Vec< M, T > | row (size_t row) const |
Returns the specified row as a vector. | |
Vec< N, T > | col (size_t col) const |
Returns the specified column as a vector. | |
const T & | operator() (size_t row, size_t col) const |
Returns a constant reference to the element at the specified row and column. | |
T & | operator() (size_t row, size_t col) |
Returns a reference to the element at the specified row and column. | |
operator const T * () const | |
Returns a constant pointer to the matrix elements. | |
operator T* () | |
Returns a pointer to the matrix elements. | |
void | load_zero () |
Sets all elements to zero. | |
void | load_identity (T s=T(1)) |
Sets the diagonal elements to s and other elements to zero. | |
template<size_t vN> | |
void | set_row (size_t row, const Vec< vN, T > &v) |
Sets the specified row from a vector. | |
template<size_t vN> | |
void | set_col (size_t col, const Vec< vN, T > &v) |
Sets the specified column from a vector. | |
void | swap_rows (size_t a, size_t b) |
Swaps the specified rows. | |
void | swap_cols (size_t a, size_t b) |
Swaps the specified columns. | |
bool | operator== (const Mat< N, M, T > &rhs) const |
Checks if the matrix is equal to another matrix. | |
bool | operator!= (const Mat< N, M, T > &rhs) const |
Checks if the matrix is not equal to another matrix. | |
template<size_t rM> | |
Mat< N, rM, T > | operator* (const Mat< M, rM, T > &rhs) const |
Multiplies the matrix by another matrix. | |
Mat< N, M, T > | operator+ (const Mat< N, M, T > &rhs) const |
Adds the matrix to another matrix. Component-wise matrix-matrix addition. | |
Mat< N, M, T > | operator- (const Mat< N, M, T > &rhs) const |
Subtracts another matrix from the matrix. Component-wise matrix-matrix subtraction. | |
Mat< N, M, T > | operator- () const |
Negates the matrix. Component-wise matrix negation. | |
Vec< N, T > | operator* (const Vec< M, T > &rhs) const |
Multiplies the matrix by a vector. | |
Mat< N, M, T > | operator* (T rhs) const |
Multiplies the matrix by a scalar. | |
Mat< N, M, T > | operator/ (T rhs) const |
Divides the matrix by a scalar. | |
Mat< N, M, T > & | operator*= (const Mat< N, M, T > &rhs) |
Multiplies the matrix by another matrix and assigns the result to the matrix. | |
Mat< N, M, T > & | operator+= (const Mat< N, M, T > &rhs) |
Adds another matrix to the matrix and assigns the result to the matrix. | |
Mat< N, M, T > & | operator-= (const Mat< N, M, T > &rhs) |
Subtracts another matrix from the matrix and assigns the result to the matrix. | |
Mat< N, M, T > & | operator*= (T rhs) |
Multiplies the matrix by a scalar and assigns the result to the matrix. | |
Mat< N, M, T > & | operator/= (T rhs) |
Divides the matrix by a scalar and assigns the result to the matrix. | |
Mat< N, M, T > & | operator+= (T rhs) |
Adds a scalar to the matrix and assigns the result to the matrix. | |
Mat< N, M, T > & | operator-= (T rhs) |
Subtracts a scalar from the matrix and assigns the result to the matrix. | |
Static Public Member Functions | |
static Mat< N, M, T > | identity () |
Returns an identity matrix. | |
static size_t | num_rows () |
Returns the number of rows in the matrix. | |
static size_t | num_columns () |
Returns the number of columns in the matrix. | |
Base class for matrix types.
Mat is a base matrix class that provides generic functionality for N by M matrices.
N | The number of rows in this matrix. |
M | The number of columns in this matrix. |
T | The scalar type for matrix elements. |
|
default |
Default constructor.
|
explicit |
Constructs a matrix with diagonal elements set to s
and other elements set to zero.
s | The value to set the diagonal elements to. |
|
explicit |
Copy constructor for matrices with different dimensions (rN >= N, rM >= M).
rN | The number of rows in the source matrix. |
rM | The number of columns in the source matrix. |
rhs | The source matrix to copy from. |
|
explicit |
Constructs a matrix from an array of elements.
m | The array of elements. |
Vec< N, T > col | ( | size_t | col | ) | const |
Returns the specified column as a vector.
col | The column index. |
|
static |
void load_identity | ( | T | s = T(1) | ) |
Sets the diagonal elements to s
and other elements to zero.
s | The value to set the diagonal elements to. |
|
inlinestatic |
Returns the number of columns in the matrix.
|
inlinestatic |
Returns the number of rows in the matrix.
operator const T * | ( | ) | const |
Returns a constant pointer to the matrix elements.
operator T* | ( | ) |
Returns a pointer to the matrix elements.
bool operator!= | ( | const Mat< N, M, T > & | rhs | ) | const |
Checks if the matrix is not equal to another matrix.
rhs | The matrix to compare with. |
T & operator() | ( | size_t | row, |
size_t | col ) |
Returns a reference to the element at the specified row and column.
row | The row index. |
col | The column index. |
const T & operator() | ( | size_t | row, |
size_t | col ) const |
Returns a constant reference to the element at the specified row and column.
row | The row index. |
col | The column index. |
Mat< N, rM, T > operator* | ( | const Mat< M, rM, T > & | rhs | ) | const |
Multiplies the matrix by another matrix.
rM | The number of columns in the right-hand side matrix. |
rhs | The right-hand side matrix. It must have the same number of rows as this matrix has columns. |
Multiplies the matrix by a vector.
rhs | The right-hand side vector. It must have the same number of elements as this matrix has columns. |
Mat< N, M, T > operator* | ( | T | rhs | ) | const |
Multiplies the matrix by a scalar.
rhs | The scalar value. |
Multiplies the matrix by another matrix and assigns the result to the matrix.
rhs | The right-hand side matrix. |
Mat< N, M, T > & operator*= | ( | T | rhs | ) |
Multiplies the matrix by a scalar and assigns the result to the matrix.
rhs | The scalar value. |
Mat< N, M, T > operator+ | ( | const Mat< N, M, T > & | rhs | ) | const |
Adds the matrix to another matrix. Component-wise matrix-matrix addition.
rhs | The right-hand side matrix. |
Adds another matrix to the matrix and assigns the result to the matrix.
rhs | The right-hand side matrix. |
Mat< N, M, T > & operator+= | ( | T | rhs | ) |
Adds a scalar to the matrix and assigns the result to the matrix.
rhs | The scalar value. |
Mat< N, M, T > operator- | ( | ) | const |
Negates the matrix. Component-wise matrix negation.
Mat< N, M, T > operator- | ( | const Mat< N, M, T > & | rhs | ) | const |
Subtracts another matrix from the matrix. Component-wise matrix-matrix subtraction.
rhs | The right-hand side matrix. |
Subtracts another matrix from the matrix and assigns the result to the matrix.
rhs | The right-hand side matrix. |
Mat< N, M, T > & operator-= | ( | T | rhs | ) |
Subtracts a scalar from the matrix and assigns the result to the matrix.
rhs | The scalar value. |
Mat< N, M, T > operator/ | ( | T | rhs | ) | const |
Divides the matrix by a scalar.
rhs | The scalar value. |
Mat< N, M, T > & operator/= | ( | T | rhs | ) |
Divides the matrix by a scalar and assigns the result to the matrix.
rhs | The scalar value. |
bool operator== | ( | const Mat< N, M, T > & | rhs | ) | const |
Checks if the matrix is equal to another matrix.
rhs | The matrix to compare with. |
Vec< M, T > row | ( | size_t | row | ) | const |
Returns the specified row as a vector.
row | The row index. |
void set_col | ( | size_t | col, |
const Vec< vN, T > & | v ) |
Sets the specified column from a vector.
This function copies the first N components from v, so vN must be >= N.
vN | The dimension of the vector. |
col | The column index. |
v | The vector to set the column from. |
void set_row | ( | size_t | row, |
const Vec< vN, T > & | v ) |
Sets the specified row from a vector.
This function copies the first M components from v, so vN must be >= M.
vN | The dimension of the vector. |
row | The row index. |
v | The vector to set the row from. |
void swap_cols | ( | size_t | a, |
size_t | b ) |
Swaps the specified columns.
a | The first column index. |
b | The second column index. |
void swap_rows | ( | size_t | a, |
size_t | b ) |
Swaps the specified rows.
a | The first row index. |
b | The second row index. |