Public Attributes

CS123Matrix< M, N, T > Struct Template Reference

A CS123Matrix is templated to store M rows and N columns of data of type T. If left off, T will default to a "REAL" data type. Also, if N is not specified, the template will default to a square MxM matrix. More...

#include <CS123Matrix.h>

List of all members.

Public Member Functions

Constructors

 CS123Matrix (const T *srcData)
 Expects arguments in row-major order.
 CS123Matrix ()
 Constructs a zero Matrix.
 CS123Matrix (const CS123Matrix< M, N, T > &m)
 Copy Constructor.
Accessor Operators

const CS123Vector< N, T > & operator[] (const unsigned rowIndex) const
CS123Vector< N, T > & operator[] (const unsigned rowIndex)
const T * operator* () const
T * operator* ()
Equality Operators

bool operator== (const CS123Matrix< M, N, T > &m) const
bool operator!= (const CS123Matrix< M, N, T > &m) const
Mutator Operators

CS123Matrix< M, N, T > & operator= (const CS123Matrix< M, N, T > &m)
CS123Matrix< M, N, T > & operator+= (const CS123Matrix< M, N, T > &rhs)
CS123Matrix< M, N, T > & operator-= (const CS123Matrix< M, N, T > &rhs)
CS123Matrix< M, N, T > & operator*= (const CS123Matrix< M, N, T > &rhs)
Scalar Mutator Operators

CS123Matrix< M, N, T > & operator*= (const T &scale)
CS123Matrix< M, N, T > & operator/= (const T &scale)
Arithmetic Operators

CS123Matrix< M, N, T > operator+ (const CS123Matrix< M, N, T > &rhs) const
CS123Matrix< M, N, T > operator- (const CS123Matrix< M, N, T > &rhs) const
CS123Matrix< M, N, T > operator* (const CS123Matrix< M, N, T > &rhs) const
 MxN (square) matrix * MxN (square) matrix yields an MxN (square) matrix.
CS123Vector< M, T > operator* (const CS123Vector< N, T > &rhs) const
Scalar Arithmetic Operators

CS123Matrix< M, N, T > operator* (const T &scale) const
CS123Matrix< M, N, T > operator/ (const T &scale) const
More Complex Functionality

bool isDiagonal () const
CS123Vector< N, T > & row (unsigned index)
CS123Vector< N, T > row (unsigned index) const
CS123Vector< M, T > col (unsigned index) const
CS123Matrix< M, N, T > & setCol (unsigned index, const CS123Vector< M, T > &vec)
 Sets the index'th column of this matrix to the given Vector.
const CS123Matrix< M, N, T > getTranspose () const
void fillGLMatrix (T *bufferToFill) const
bool isUpperTriangular () const
bool isLowerTriangular () const
CS123Matrix< M, N, T > getInverse () const
getDeterminant () const
void cleanup ()
 Cleans up a matrix (0's out entries that are less than epsilon).
 CS123Matrix (const T &v0, const T &v1=0, const T &v2=0, const T &v3=0, const T &v4=0, const T &v5=0, const T &v6=0, const T &v7=0, const T &v8=0, const T &v9=0, const T &v10=0, const T &v11=0, const T &v12=0, const T &v13=0, const T &v14=0, const T &v15=0)
 Convenience Constructor.

Static Public Member Functions

Static convenience constructors to generate common matrices

static CS123Matrix zero ()
 Generates a matrix full of zeroes.
static CS123Matrix identity ()
 Generates an identity matrix.
static CS123Matrix diagonal (T diagonalValue)
 Generates a diagonal matrix with the value specified.

Public Attributes

CS123Vector< N, T > rows [M]
 Underlying data, where each row is stored in a separate CS123Vector.

Detailed Description

template<unsigned M, unsigned N = M, typename T = REAL>
struct CS123Matrix< M, N, T >

A CS123Matrix is templated to store M rows and N columns of data of type T. If left off, T will default to a "REAL" data type. Also, if N is not specified, the template will default to a square MxM matrix.

Included in this definition are typedefs for the most commonly used matrices (4x4, 3x3, etc), and these can be thought of as shortcuts to reference their associated CS123Matrix templates. For example, Matrix4x4 can be used to refer to CS123Matrix<4, 4, REAL>.

A CS123Matrix stores each of its M rows internally as an N-length CS123Vector.


Member Function Documentation

template<unsigned M, unsigned N, typename T >
CS123Vector< M, T > CS123Matrix< M, N, T >::col ( unsigned  index  )  const [inline]
Returns:
a Vector containing the index'th column of this matrix
Note:
Modifying the Vector returned will Not affect this Matrix's data
template<unsigned M, unsigned N, typename T>
void CS123Matrix< M, N, T >::fillGLMatrix ( T *  bufferToFill  )  const

Fills the data provided with the transpose of this matrix (since OpenGL matrices are stored in column-major format).

template<unsigned M, unsigned N, typename T >
T CS123Matrix< M, N, T >::getDeterminant (  )  const
Returns:
the determinant of this matrix
template<unsigned M, unsigned N, typename T >
CS123Matrix< M, N, T > CS123Matrix< M, N, T >::getInverse (  )  const
Returns:
the inverse of this matrix, assuming it exists
template<unsigned M, unsigned N, typename T >
const CS123Matrix< M, N, T > CS123Matrix< M, N, T >::getTranspose (  )  const
Returns:
the transpose of this matrix
template<unsigned M, unsigned N, typename T >
bool CS123Matrix< M, N, T >::isDiagonal (  )  const [inline]
Returns:
whether or not this Matrix is diagonal
template<unsigned M, unsigned N, typename T >
bool CS123Matrix< M, N, T >::isLowerTriangular (  )  const
Returns:
true if this matrix is strictly lower-triangular. An lower- triangular matrix contains only zeros above its diagonal (but may contain non-zero values on and below its diagonal).

Example 4x4 triangular matrix: [ 1 0 0 0 ] [ 2 3 0 0 ] [ 4 5 0 0 ] [ 6 7 8 9 ]

Example 4x4 non upper triangular matrix: [ 1 0 0 2 ] [ 3 4 0 5 ] [ 6 7 8 0 ] [ 0 0 0 0 ]

template<unsigned M, unsigned N, typename T >
bool CS123Matrix< M, N, T >::isUpperTriangular (  )  const
Returns:
true if this matrix is strictly upper-triangular. An upper- triangular matrix contains only zeros below its diagonal (but may contain non-zero values on and above its diagonal).

Example 4x4 upper triangular matrix: [ 1 2 3 4 ] [ 0 5 6 7 ] [ 0 0 0 8 ] [ 0 0 0 9 ]

Example 4x4 non upper triangular matrix: [ 1 2 3 4 ] [ 0 5 6 7 ] [ 8 0 0 9 ] [ 0 0 0 0 ]

template<unsigned M, unsigned N, typename T>
CS123Vector< M, T > CS123Matrix< M, N, T >::operator* ( const CS123Vector< N, T > &  rhs  )  const [inline]

MxN matrix * N-length column vector yields an M-length vector

Note:
this method returns an M-length CS123Vector. Make sure you understand why.
template<unsigned M, unsigned N, typename T >
const T * CS123Matrix< M, N, T >::operator* (  )  const [inline]
Returns:
a const pointer to the raw, underlying data (row-major, M*N-length array of type T)
template<unsigned M, unsigned N, typename T >
T * CS123Matrix< M, N, T >::operator* (  )  [inline]
Returns:
a pointer to the raw, underlying data (row-major, M*N-length array of type T)
template<unsigned M, unsigned N, typename T >
CS123Vector< N, T > & CS123Matrix< M, N, T >::operator[] ( const unsigned  rowIndex  )  [inline]
Returns:
a reference to the row at the given index
Note:
changes to the returned vector will affect this matrix
template<unsigned M, unsigned N, typename T >
const CS123Vector< N, T > & CS123Matrix< M, N, T >::operator[] ( const unsigned  rowIndex  )  const [inline]
Returns:
a const reference to the row at the given index
template<unsigned M, unsigned N, typename T >
CS123Vector< N, T > CS123Matrix< M, N, T >::row ( unsigned  index  )  const [inline]
Returns:
a Vector containing the index'th row of this matrix
Note:
Modifying the Vector returned will Not affect this Matrix's data
template<unsigned M, unsigned N, typename T >
CS123Vector< N, T > & CS123Matrix< M, N, T >::row ( unsigned  index  )  [inline]
Returns:
a Vector containing the index'th row of this matrix
Note:
Modifying the Vector returned will directly affect this Matrix's data

The documentation for this struct was generated from the following files: