Free Electron
Public Member Functions | Protected Attributes | Related Functions | List of all members
fe::Matrix< M, N, T > Class Template Reference

General template for fixed size numeric matrices. More...

#include <Matrix.h>

Inheritance diagram for fe::Matrix< M, N, T >:
Inheritance graph
[legend]

Public Member Functions

 Matrix (const Matrix< M, N, T > &other)
 
Matrix< M, N, T > & operator= (const Matrix< M, N, T > &other)
 
template<class U >
Matrix< M, N, T > & operator= (const Matrix< M, N, U > &other)
 
template<int I, int J, class U >
Matrix< M, N, T > & operator= (const Matrix< I, J, U > &other)
 
bool operator== (const Matrix< M, N, T > &other) const
 
operator() (unsigned int i, unsigned int j) const
 Column Major addressing. More...
 
T & operator() (unsigned int i, unsigned int j)
 Column Major addressing. More...
 
operator[] (unsigned int index) const
 
T & operator[] (unsigned int index)
 
Vector< M, T > column (unsigned int index) const
 
T * raw (void)
 
const T * raw (void) const
 

Protected Attributes

m_data [M *N]
 

Related Functions

(Note that these are not member functions.)

template<int M, int N, class T >
U32 width (const Matrix< M, N, T > &matrix)
 Return the horizonatal dimension. More...
 
template<int M, int N, class T >
U32 height (const Matrix< M, N, T > &matrix)
 Return the vertical dimension. More...
 
template<int M, int N, class T >
bool isSquare (const Matrix< M, N, T > &matrix)
 Return true is matrix is square, otherwise return false. More...
 
template<int M, int N, class T >
Matrix< M, N, T > & setIdentity (Matrix< M, N, T > &matrix)
 Set matrix to identity matrix. More...
 
template<int M, int N, class T >
Matrix< N, M, T > transpose (const Matrix< M, N, T > &matrix)
 Return transpose of matrix. More...
 
template<int M, int N, class T >
Matrix< M, N, T > & setTranspose (Matrix< M, N, T > &matrix)
 Transpose matrix in place. More...
 
template<int M, int N, class T , class U >
Matrix< M, N, T > & add (Matrix< M, N, T > &R, const Matrix< M, N, T > &A, const Matrix< M, N, U > &B)
 Matrix Matrix add. More...
 
template<int M, int N, class T , class U >
Matrix< M, N, T > & subtract (Matrix< M, N, T > &R, const Matrix< M, N, T > &A, const Matrix< M, N, U > &B)
 Matrix Matrix subtract. More...
 
template<int M, int N, int L, class T , class U >
Matrix< M, N, T > & multiply (Matrix< M, N, T > &R, const Matrix< M, L, T > &A, const Matrix< L, N, U > &B)
 Matrix Matrix multiply. More...
 
template<int M, int N, class T >
String print (const Matrix< M, N, T > &a_m)
 Matrix print. More...
 
template<int M, int N, class T >
String fprint (FILE *a_fp, const Matrix< M, N, T > &a_m)
 Matrix print. More...
 
template<int M, int N, class T , int I, int J, class U >
void copy (Matrix< M, N, T > &lhs, const Matrix< I, J, U > &rhs)
 Matrix copy. More...
 
template<int M, int N, int I, int J, class T >
void overlay (Matrix< M, N, T > &lhs, const Matrix< I, J, T > &rhs)
 Matrix overlay. More...
 
template<int M, int N, class T , class U >
Matrix< M, N, T > & multiply (Matrix< M, N, T > &A, const U &scale)
 Matrix scale in place. More...
 
template<int M, int N, class T , class U >
Matrix< M, N, T > multiply (const Matrix< M, N, T > &A, const U &scale)
 Matrix scale. More...
 
template<int M, int N, class T , class U >
Matrix< M, N, T > operator+ (const Matrix< M, N, T > &lhs, const Matrix< M, N, U > &rhs)
 Matrix Matrix add. More...
 
template<int M, int N, class T , class U >
Matrix< M, N, T > operator- (const Matrix< M, N, T > &lhs, const Matrix< M, N, U > &rhs)
 Matrix Matrix subtract. More...
 
template<int M, int N, int L, class T , class U >
Matrix< M, L, T > operator* (const Matrix< M, N, T > &lhs, const Matrix< N, L, U > &rhs)
 Matrix Matrix multiply. More...
 
template<int M, int N, class T >
Matrix< M, N, T > operator* (const Matrix< M, N, T > &lhs, const Real rhs)
 Matrix Scale. More...
 
template<int M, int N, class T , class U >
Matrix< M, N, T > operator* (const U lhs, const Matrix< M, N, T > &rhs)
 Matrix Scale. More...
 
template<int M, int N, class T , class U >
Matrix< M, N, T > & operator*= (Matrix< M, N, T > &lhs, const U rhs)
 Matrix Scale. More...
 
template<int N, typename T >
void premultiplyInverseDiagonal (Vector< N, T > &result, const Matrix< N, N, T > &diagonal, const Vector< N, T > &vector)
 Compute the per-element product of the vector and the inverse diagonal entries. More...
 
template<int N, class T >
Matrix< N, N, T > & premultiplyInverseDiagonal (Matrix< N, N, T > &result, const Matrix< N, N, T > &lhs, const Matrix< N, N, T > &rhs)
 Matrix-Matrix multiply where first matrix is presumed diagonal. More...
 
template<int N, class T >
Matrix< N, N, T > & postmultiplyInverseDiagonal (Matrix< N, N, T > &result, const Matrix< N, N, T > &lhs, const Matrix< N, N, T > &rhs)
 Matrix-Matrix multiply where first matrix is presumed diagonal. More...
 
template<typename T , typename U >
Matrix< 3, 3, T > & rotateMatrix (Matrix< 3, 3, T > &lhs, U radians, Axis axis)
 3D Matrix rotation More...
 

Detailed Description

template<int M, int N, class T>
class fe::Matrix< M, N, T >

General template for fixed size numeric matrices.

Dimensions specified as MxN:

     N
    ____
   |    |
M  |    |
   |____|

With storage for a 4x4 as:
    0   4   8   12
    1   5   9   13
    2   6   10  14
    3   7   11  15

The operator(i,j) addressing for a 4x4 matrix is:
    00  01  02  03
    10  11  12  13
    20  21  22  23
    30  31  32  33

This is sometimes called column-major.

Member Function Documentation

◆ operator()() [1/2]

template<int M, int N, class T >
T fe::Matrix< M, N, T >::operator() ( unsigned int  i,
unsigned int  j 
) const
inline

Column Major addressing.

◆ operator()() [2/2]

template<int M, int N, class T >
T & fe::Matrix< M, N, T >::operator() ( unsigned int  i,
unsigned int  j 
)
inline

Column Major addressing.

Friends And Related Function Documentation

◆ add()

template<int M, int N, class T , class U >
Matrix< M, N, T > & add ( Matrix< M, N, T > &  R,
const Matrix< M, N, T > &  A,
const Matrix< M, N, U > &  B 
)
related

◆ copy()

template<int M, int N, class T , int I, int J, class U >
void copy ( Matrix< M, N, T > &  lhs,
const Matrix< I, J, U > &  rhs 
)
related

◆ fprint()

template<int M, int N, class T >
String fprint ( FILE *  a_fp,
const Matrix< M, N, T > &  a_m 
)
related

Matrix print.

◆ height()

template<int M, int N, class T >
U32 height ( const Matrix< M, N, T > &  matrix)
related

Return the vertical dimension.

Referenced by fe::Matrix< 3, 4, T >::copyTranslation().

◆ isSquare()

template<int M, int N, class T >
bool isSquare ( const Matrix< M, N, T > &  matrix)
related

Return true is matrix is square, otherwise return false.

Referenced by fe::Matrix< 3, 4, Real >::setTranspose().

◆ multiply() [1/3]

template<int M, int N, int L, class T , class U >
Matrix< M, N, T > & multiply ( Matrix< M, N, T > &  R,
const Matrix< M, L, T > &  A,
const Matrix< L, N, U > &  B 
)
related

◆ multiply() [2/3]

template<int M, int N, class T , class U >
Matrix< M, N, T > & multiply ( Matrix< M, N, T > &  A,
const U &  scale 
)
related

Matrix scale in place.

◆ multiply() [3/3]

template<int M, int N, class T , class U >
Matrix< M, N, T > multiply ( const Matrix< M, N, T > &  A,
const U &  scale 
)
related

Matrix scale.

◆ operator*() [1/3]

template<int M, int N, int L, class T , class U >
Matrix< M, L, T > operator* ( const Matrix< M, N, T > &  lhs,
const Matrix< N, L, U > &  rhs 
)
related

◆ operator*() [2/3]

template<int M, int N, class T >
Matrix< M, N, T > operator* ( const Matrix< M, N, T > &  lhs,
const Real  rhs 
)
related

Matrix Scale.

◆ operator*() [3/3]

template<int M, int N, class T , class U >
Matrix< M, N, T > operator* ( const U  lhs,
const Matrix< M, N, T > &  rhs 
)
related

Matrix Scale.

◆ operator*=()

template<int M, int N, class T , class U >
Matrix< M, N, T > & operator*= ( Matrix< M, N, T > &  lhs,
const U  rhs 
)
related

◆ operator+()

template<int M, int N, class T , class U >
Matrix< M, N, T > operator+ ( const Matrix< M, N, T > &  lhs,
const Matrix< M, N, U > &  rhs 
)
related

◆ operator-()

template<int M, int N, class T , class U >
Matrix< M, N, T > operator- ( const Matrix< M, N, T > &  lhs,
const Matrix< M, N, U > &  rhs 
)
related

◆ overlay()

template<int M, int N, int I, int J, class T >
void overlay ( Matrix< M, N, T > &  lhs,
const Matrix< I, J, T > &  rhs 
)
related

Matrix overlay.

◆ postmultiplyInverseDiagonal()

template<int N, class T >
Matrix< N, N, T > & postmultiplyInverseDiagonal ( Matrix< N, N, T > &  result,
const Matrix< N, N, T > &  lhs,
const Matrix< N, N, T > &  rhs 
)
related

Matrix-Matrix multiply where first matrix is presumed diagonal.

This amounts to a scale of each column by the reciprical of the corresponding diagonal element.

Diagonal elements of the second matrix are inverted during the multiply. Non-diagonal elements of the second matrix are ignored and treated as zero.

◆ premultiplyInverseDiagonal() [1/2]

template<int N, typename T >
void premultiplyInverseDiagonal ( Vector< N, T > &  result,
const Matrix< N, N, T > &  diagonal,
const Vector< N, T > &  vector 
)
related

Compute the per-element product of the vector and the inverse diagonal entries.

Only the diagonal elements are used. The non-diagonal values are not read and treated as zero.

◆ premultiplyInverseDiagonal() [2/2]

template<int N, class T >
Matrix< N, N, T > & premultiplyInverseDiagonal ( Matrix< N, N, T > &  result,
const Matrix< N, N, T > &  lhs,
const Matrix< N, N, T > &  rhs 
)
related

Matrix-Matrix multiply where first matrix is presumed diagonal.

This amounts to a scale of each row by the reciprical of the corresponding diagonal element.

Diagonal elements of the first matrix are inverted during the multiply. Non-diagonal elements of the first matrix are ignored and treated as zero.

◆ print()

template<int M, int N, class T >
String print ( const Matrix< M, N, T > &  a_m)
related

◆ rotateMatrix()

template<typename T , typename U >
Matrix< 3, 3, T > & rotateMatrix ( Matrix< 3, 3, T > &  lhs,
radians,
Axis  axis 
)
related

3D Matrix rotation

Rotate a 3x3 matrix counterclockwise about the specified axis

◆ setIdentity()

template<int M, int N, class T >
Matrix< M, N, T > & setIdentity ( Matrix< M, N, T > &  matrix)
related

Set matrix to identity matrix.

Referenced by fe::Matrix< 3, 4, T >::copy16(), and fe::Matrix< 3, 4, T >::copyTranslation().

◆ setTranspose()

template<int M, int N, class T >
Matrix< M, N, T > & setTranspose ( Matrix< M, N, T > &  matrix)
related

Transpose matrix in place.

◆ subtract()

template<int M, int N, class T , class U >
Matrix< M, N, T > & subtract ( Matrix< M, N, T > &  R,
const Matrix< M, N, T > &  A,
const Matrix< M, N, U > &  B 
)
related

◆ transpose()

template<int M, int N, class T >
Matrix< N, M, T > transpose ( const Matrix< M, N, T > &  matrix)
related

Return transpose of matrix.

◆ width()

template<int M, int N, class T >
U32 width ( const Matrix< M, N, T > &  matrix)
related

Return the horizonatal dimension.

Referenced by fe::Matrix< 3, 4, T >::copyTranslation().


The documentation for this class was generated from the following file: