compile-time (static) matrix More...
Public Member Functions | |
Matrix () | |
default constructor | |
Matrix (unsigned m, unsigned n) | |
construct with m by n elements | |
unsigned | rows () const |
get the number of rows | |
unsigned | cols () const |
get the number of columns | |
T & | operator() (unsigned i, unsigned j) |
mutable index operator | |
T const & | operator() (unsigned i, unsigned j) const |
immutable index operator | |
Matrix< T, M, N > | operator+ (Matrix< T, M, N > const &b) const |
add two matrices | |
Matrix< T, M, N > | operator- (Matrix< T, M, N > const &b) const |
subtract two matrices | |
Matrix< T, M, N > | operator* (T const &s) const |
multiply by a scalar | |
Matrix< T, M, N > | operator/ (T const &s) const |
divide by a scalar | |
Vector< T, M > | operator* (Vector< T, N > const &b) const |
multiply a matrix by a vector | |
template<unsigned O> | |
Matrix< T, M, O > | operator* (Matrix< T, N, O > const &b) const |
multiply two matrices | |
void | zero () |
zero a matrix |
compile-time (static) matrix
Definition at line 23 of file mthMatrix.h.
mth::Matrix< T, M, N >::Matrix | ( | unsigned | m, | |
unsigned | n | |||
) | [inline] |
construct with m by n elements
A dummy constructor Matrix(m,n) is provided so that dynamic and static matrices can be used interchangebly
Definition at line 31 of file mthMatrix.h.
{ (void) m; (void) n; }
T const& mth::Matrix< T, M, N >::operator() | ( | unsigned | i, | |
unsigned | j | |||
) | const [inline] |
immutable index operator
see the mutable index operator details
Definition at line 43 of file mthMatrix.h.
{return (*this)[i][j];}
T& mth::Matrix< T, M, N >::operator() | ( | unsigned | i, | |
unsigned | j | |||
) | [inline] |
mutable index operator
An index operator (i,j) is provided so that compile time matrices and runtime-sized matrices can be used interchangebly, without worrying about changing index syntax
Definition at line 40 of file mthMatrix.h.
{return (*this)[i][j];}
Matrix<T,M,O> mth::Matrix< T, M, N >::operator* | ( | Matrix< T, N, O > const & | b | ) | const [inline] |
multiply two matrices
the extra template parameter generates code for all possible combinations of matrix sizes
Definition at line 88 of file mthMatrix.h.
{ Matrix<T,M,O> r; for (unsigned i=0; i < M; ++i) for (unsigned j=0; j < O; ++j) { r[i][j] = this->elems[i][0]*b[0][j]; for (unsigned k=1; k < N; ++k) r[i][j] += this->elems[i][k]*b[k][j]; } return r; }