KrisLibrary  1.0.0
Public Types | Public Member Functions | Public Attributes | List of all members
Math::MatrixTemplate< T > Class Template Reference

A matrix over the field T. More...

#include <MatrixTemplate.h>

Public Types

typedef class MatrixTemplate< T > MyT
 
typedef class MatrixIterator< T > ItT
 
typedef class VectorTemplate< T > VectorT
 

Public Member Functions

 MatrixTemplate (const MyT &)
 
 MatrixTemplate (MyT &&)
 
 MatrixTemplate (int m, int n)
 
 MatrixTemplate (int m, int n, T initval)
 
 MatrixTemplate (int m, int n, const T *vals)
 
 MatrixTemplate (int m, int n, const VectorT *rows)
 
T * getPointer () const
 
int getCapacity () const
 
T * getStart () const
 
T * getRowPtr (int i) const
 
T * getColPtr (int j) const
 
ItT begin () const
 
ItT end () const
 
int numRows () const
 
int numCols () const
 
void resize (int m, int n)
 
void resize (int m, int n, T initval)
 
void resizePersist (int m, int n)
 
void resizePersist (int m, int n, T initval)
 
void clear ()
 
MyT & operator= (const MyT &)
 
MyT & operator= (MyT &&)
 
bool operator== (const MyT &) const
 
bool operator!= (const MyT &a) const
 
const T & operator() (int, int) const
 
T & operator() (int, int)
 
void operator+= (const MyT &a)
 
void operator-= (const MyT &a)
 
void operator*= (T c)
 
void operator/= (T c)
 
void operator*= (const MyT &)
 
void copy (const MyT &)
 
template<class T2 >
void copy (const MatrixTemplate< T2 > &)
 
void copy (const T *vals)
 
void copyColumns (const T *vals)
 
void copyRows (const VectorT *rows)
 
void copyCols (const VectorT *cols)
 
void copySubMatrix (int i, int j, const MyT &)
 
void swap (MyT &)
 
void swapCopy (MyT &)
 
void add (const MyT &, const MyT &)
 
void sub (const MyT &, const MyT &)
 
void mul (const MyT &, const MyT &)
 
void mulTransposeA (const MyT &a, const MyT &b)
 
void mulTransposeB (const MyT &a, const MyT &b)
 
void mul (const VectorT &, VectorT &) const
 
void mulTranspose (const VectorT &, VectorT &) const
 
void mul (const MyT &, T)
 
void div (const MyT &, T)
 
void inc (const MyT &)
 
void dec (const MyT &)
 
void madd (const MyT &, T)
 
void madd (const VectorT &, VectorT &) const
 
void maddTranspose (const VectorT &, VectorT &) const
 
void setRef (const MyT &, int i=0, int j=0, int istride=1, int jstride=1, int m=-1, int n=-1)
 
void setRef (T *vals, int length, int offset=0, int istride=1, int jstride=1, int m=-1, int n=-1)
 
void setRefTranspose (const MyT &)
 
void set (T c)
 
void setZero ()
 
void setIdentity ()
 
void setNegative (const MyT &)
 
void setTranspose (const MyT &)
 
void setAdjoint (const MyT &)
 
void setInverse (const MyT &)
 
void inplaceNegative ()
 
void inplaceMul (T)
 
void inplaceDiv (T)
 
void inplaceTranspose ()
 
void inplaceAdjoint ()
 
void inplaceInverse ()
 
void getSubMatrixCopy (int i, int j, MyT &) const
 
bool isRef () const
 
bool hasDims (int _m, int _n) const
 
bool isEmpty () const
 
bool isValidRow (int i) const
 
bool isValidCol (int j) const
 
bool isCompact () const
 
bool isRowMajor () const
 
bool isColMajor () const
 
bool isSquare () const
 
bool isValid () const
 
bool isZero (T eps=0) const
 
bool isEqual (const MyT &a, T eps=0) const
 
bool isIdentity () const
 
bool isDiagonal () const
 
bool isSymmetric () const
 
bool isDiagonallyDominant () const
 
bool isOrthogonal () const
 
bool isInvertible () const
 
trace () const
 
determinant () const
 
diagonalProduct () const
 
minElement (int *i=NULL, int *j=NULL) const
 
maxElement (int *i=NULL, int *j=NULL) const
 
minAbsElement (int *i=NULL, int *j=NULL) const
 
maxAbsElement (int *i=NULL, int *j=NULL) const
 
bool Read (File &)
 
bool Write (File &) const
 
void getRowRef (int i, VectorT &) const
 
void getColRef (int j, VectorT &) const
 
void getDiagRef (int d, VectorT &) const
 
VectorT row (int i) const
 
VectorT col (int j) const
 
VectorT diag (int d) const
 
void getRowCopy (int i, VectorT &b) const
 
void getColCopy (int j, VectorT &b) const
 
void getDiagCopy (int d, VectorT &b) const
 
void setRow (int i, T c)
 
void setCol (int j, T c)
 
void setDiag (int d, T c)
 
void copyRow (int i, const VectorT &b)
 
void copyCol (int j, const VectorT &b)
 
void copyDiag (int d, const VectorT &b)
 
void copyRow (int i, const T *b)
 
void copyCol (int j, const T *b)
 
void copyDiag (int d, const T *b)
 
void incRow (int i, const VectorT &b)
 
void incCol (int j, const VectorT &b)
 
void incDiag (int d, const VectorT &b)
 
void mulRow (int i, T c)
 
void mulCol (int j, T c)
 
void mulDiag (int d, T c)
 
void maddRow (int i, const VectorT &b, T c)
 
void maddCol (int j, const VectorT &b, T c)
 
void maddDiag (int d, const VectorT &b, T c)
 
dotRow (int i, const VectorT &b) const
 
dotCol (int j, const VectorT &b) const
 
void incRow (int i, const MyT &m, int im)
 
void incCol (int j, const MyT &m, int jm)
 
void maddRow (int i, const MyT &m, int im, T c)
 
void maddCol (int j, const MyT &m, int jm, T c)
 
dotRow (int i, const MyT &m, int im) const
 
dotCol (int j, const MyT &m, int jm) const
 
void componentMul (const MyT &a, const MyT &b)
 
void componentDiv (const MyT &a, const MyT &b)
 
void componentMadd (const MyT &a, const MyT &b)
 
void inplaceComponentMul (const MyT &c)
 
void inplaceComponentDiv (const MyT &c)
 
template<>
void setAdjoint (const MyT &a)
 
template<>
void inplaceAdjoint ()
 
template<>
Complex minElement (int *_i, int *_j) const
 
template<>
Complex maxElement (int *_i, int *_j) const
 
template<>
Complex minAbsElement (int *_i, int *_j) const
 
template<>
Complex maxAbsElement (int *_i, int *_j) const
 

Public Attributes

int base
 
int istride
 
int m
 
int jstride
 
int n
 

Detailed Description

template<class T>
class Math::MatrixTemplate< T >

A matrix over the field T.

Much like VectorTemplate, this is a basic matrix class used throughout the math library. Element i,j is accessed via parentheses A(i,j). The matrix is m x n, such that the range of element indices is [0,A.m)x[0,A.n).

The operational modes of MatrixTemplate follow those of VectorTemplate, such as being able to handle both self-allocated data and referenced data. This can also operate in both row-major and column-major mode using non-contiguous data access. Element (i,j) accesses data[base+i*istride+j*jstride], so by changing the values of istride and jstride the desired effect can be achieved.

A handy tool for transposing a matrix without manipulating data is the setRefTranspose() method. If B.setRefTranspose(A) is called, then B(i,j) accesses the same data as A(j,i).

Also, it is handy to access rows, columns, or diagonals of the matrix as if they were vectors. Dozens of methods are provided for operations on rows, columns, and diagonals.


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