|
Public Member Functions |
| Matrix () |
| default constructor: zero matrix (0x0)
|
| Matrix (unsigned short _m, unsigned short _n, const D *_data=0) |
| constucts a matrix with the given size.
|
| Matrix (const Matrix &c) |
| constucts a instance on the base of a deep copy of the given matrix
|
| ~Matrix () |
unsigned short | getM () const |
unsigned short | getN () const |
D | val (unsigned short i, unsigned short j) const |
D & | val (unsigned short i, unsigned short j) |
D | valDef0 (short i, short j) const |
void | set (unsigned short _m, unsigned short _n, const D *_data=0) |
| sets the size of the matrix and maybe the data if given (row-wise).
|
void | set (const D *_data) |
| sets the data (row-wise).
|
Matrix | row (unsigned short index) const |
Matrix | rows (unsigned short startindex, unsigned short endindex) const |
Matrix | column (unsigned short index) const |
Matrix | columns (unsigned short startindex, unsigned short endindex) const |
int | convertToBuffer (D *buffer, unsigned int len) const |
| stores the content of the matrix (row-wise) in the given buffer
|
std::list< D > | convertToList () const |
bool | store (FILE *f) const |
| stores the Matrix into the given file stream (binary)
|
bool | restore (FILE *f) |
| reads a Matrix from the given file stream (binary)
|
bool | write (FILE *f) const |
| writes the Matrix into the given file stream (ascii)
|
bool | read (FILE *f) |
| reads a Matrix from the given file stream (ascii)
|
void | add (const Matrix &a, const Matrix &b) |
| addition: this = a + b
|
void | sub (const Matrix &a, const Matrix &b) |
| subtraction: this = a - b
|
void | mult (const Matrix &a, const Matrix &b) |
| multiplication: this = a * b
|
void | mult (const Matrix &a, const D &fac) |
| scaling: this = a * fac
|
bool | isNulltimesNull () |
| returns true if matrix is a 0x0 matrix
|
Matrix | map (D(*fun)(D)) const |
| maps the matrix to a new matrix with all elements mapped with the given function
|
Matrix | mapP (void *param, D(*fun)(void *, D)) const |
| like map but with additional parameter for the mapping function
|
Matrix | multrowwise (const Matrix &factors) const |
| row-wise multiplication
|
Matrix | multcolwise (const Matrix &factors) const |
| column-wise multiplication
|
Matrix | multMT () const |
| optimised multiplication of Matrix with its transposed: M * M^T
|
Matrix | multTM () const |
| optimised multiplication of transpsoed of Matrix with itself: M^T * M
|
D | elementProduct () const |
| returns the product of all elements
|
D | elementSum () const |
| returns the sum of all elements
|
Matrix | above (const Matrix &a) const |
| returns a matrix that consists of b below this
|
Matrix & | operator= (const Matrix &c) |
| deep copy
|
Matrix | operator+ (const Matrix &sum) const |
Matrix | operator- (const Matrix &sum) const |
Matrix | operator * (const Matrix &fac) const |
| matrix product
|
Matrix | operator * (const D &fac) const |
| product with scalar (double)
|
Matrix | operator^ (int exponent) const |
| special matrix potence:
|
Matrix & | operator+= (const Matrix &c) |
| performant combined assigment operators
|
Matrix & | operator-= (const Matrix &c) |
Matrix & | operator *= (const Matrix &c) |
Matrix & | operator *= (const D &fac) |
bool | operator== (const Matrix &c) const |
| comparison operator (compares elements with tolerance distance of COMPARE_EPS)
|
void | copy (const Matrix &c) |
| performs a deep copy of the given matrix
|
void | toTranspose () |
| inplace transpose
|
void | toZero () |
| inplace converts matrix to zero matrix
|
void | toId () |
| inplace converts matrix to identity (use ^0 to get a copy version of it)
|
void | toSum (const Matrix &a) |
| inplace addition: this = this + a
|
void | toDiff (const Matrix &a) |
| inplace subtraction: this = this - a
|
void | toMult (const D &fac) |
| inplace multiplication with scalar: this = this*fac
|
void | toExp (int exponent) |
| special inplace matrix potence:
|
void | toMap (D(*fun)(D)) |
| inplace mapping of matrix elements (element-wise application)
|
void | toMapP (void *param, D(*fun)(void *, D)) |
| like toMap, but with an extra parameter for the mapping function.
|
void | toMultrowwise (const Matrix &factors) |
| Inplace row-wise multiplication.
|
void | toMultcolwise (const Matrix &factors) |
| Inplace column-wise multiplication.
|
void | toAbove (const Matrix &a) |
| sets the matrix a below (this) matrix
|
Static Public Member Functions |
Matrix | map2 (D(*fun)(D, D), const Matrix &a, const Matrix &b) |
| binary map operator for matrices.
|
Private Member Functions |
void | allocate () |
void | invertnonzero () |
void | invert3x3 () |
void | invert2x2 () |
Private Attributes |
unsigned short | m |
unsigned short | n |
unsigned int | buffersize |
D * | data |
Friends |
std::ostream & | operator<< (std::ostream &, const Matrix &) |
| printing operator: output format: mxn (
row0
..rown
) where rowX is tab seperated list of values
|
Type D is datatype of matrix elements, which is fixed to double. There are basicly two different types of operation: Inplace operations and copy operations. Please use the latter ones unless you know what you are doing. Just in case of critical performance optimisation use the inplace operations. The most convinient way is to use the overloaded operators (like + * ...). All constructed matrices are initialised with zero elements (unless data is given). All functions perform range checks if in debug mode (NDEBUG is not defined). Please use -lmatrix_debug for testing.