#include <matrix.h>
Inherits Storeable.
Inheritance diagram for Matrix:


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 | 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 | |
| static Matrix | map2 (D(*fun)(D, D), const Matrix &a, const Matrix &b) |
| binary map operator for matrices. | |
Friends | |
| std::ostream & | operator<< (std::ostream &, const Matrix &) |
| printing operator: output format: mxn ( row0 . | |
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.
integration/main.cpp, main.cpp, matrix/matrixexample.cpp, and sphererobot3masses.cpp.
| Matrix | ( | ) | [inline] |
default constructor: zero matrix (0x0)
constucts a matrix with the given size.
If _data is null then the matrix is filled with zeros. otherwise matrix will be filled with _data in a row-wise manner. In this case _data must be at least _m*_n elements long
| ~Matrix | ( | ) | [inline] |
| 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
| buffer | Buffer for storing the elements (should have the length given by len) | |
| len | Length of the provided buffer. In any case only min(len, getM()*getN()) elements are copied. |
| std::list< D > convertToList | ( | ) | const |
| void copy | ( | const Matrix & | c | ) | [inline] |
performs a deep copy of the given matrix
| D elementProduct | ( | ) | const |
returns the product of all elements
| D elementSum | ( | ) | const |
returns the sum of all elements
| unsigned short getM | ( | ) | const [inline] |
| unsigned short getN | ( | ) | const [inline] |
| bool isNulltimesNull | ( | ) |
returns true if matrix is a 0x0 matrix
maps the matrix to a new matrix with all elements mapped with the given function
binary map operator for matrices.
The resulting matrix consists of the function values applied to the elements of a and b. In haskell this would something like: map (uncurry . fun) $ zip a b
like map but with additional parameter for the mapping function
column-wise multiplication
| factors | column vector (Mx1) of factors, one for each column |
row-wise multiplication
| factors | column vector (Mx1) of factors, one for each row |
| bool operator== | ( | const Matrix & | c | ) | const |
comparison operator (compares elements with tolerance distance of COMPARE_EPS)
| Matrix operator^ | ( | int | exponent | ) | const |
special matrix potence:
| exponent | -1 -> inverse; 0 -> Identity Matrix; 1 -> itself; T -> Transpose |
| bool read | ( | FILE * | f | ) |
reads a Matrix from the given file stream (ascii)
| bool restore | ( | FILE * | f | ) | [virtual] |
| Matrix row | ( | unsigned short | index | ) | const |
| void set | ( | const D * | _data | ) |
sets the data (row-wise).
| _data | if null then matrix elements are set to zero otherwise the field MUST have the length should be getM()*getN() |
| 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).
If data=null then the matrix is set to zero
constructor Matrix(m,n,data)
| bool store | ( | FILE * | f | ) | const [virtual] |
| void toAbove | ( | const Matrix & | a | ) |
sets the matrix a below (this) matrix
| void toDiff | ( | const Matrix & | a | ) | [inline] |
inplace subtraction: this = this - a
| void toExp | ( | int | exponent | ) |
special inplace matrix potence:
| exponent | -1 -> inverse; (matrix MUST be SQUARE and NONZERO) 0 -> Identity Matrix; 1 -> itself; T -> Transpose |
| void toId | ( | ) |
inplace converts matrix to identity (use ^0 to get a copy version of it)
like toMap, but with an extra parameter for the mapping function.
| void toMult | ( | const D & | fac | ) |
inplace multiplication with scalar: this = this*fac
| void toMultcolwise | ( | const Matrix & | factors | ) |
Inplace column-wise multiplication.
| factors | column vector of factors, one for each column |
| void toMultrowwise | ( | const Matrix & | factors | ) |
Inplace row-wise multiplication.
| factors | column vector of factors, one for each row |
| void toSum | ( | const Matrix & | a | ) | [inline] |
inplace addition: this = this + a
| void toTranspose | ( | ) |
inplace transpose
| void toZero | ( | ) |
inplace converts matrix to zero matrix
| D& val | ( | unsigned short | i, | |
| unsigned short | j | |||
| ) | [inline] |
| D val | ( | unsigned short | i, | |
| unsigned short | j | |||
| ) | const [inline] |
| D valDef0 | ( | short | i, | |
| short | j | |||
| ) | const [inline] |
| bool write | ( | FILE * | f | ) | const |
writes the Matrix into the given file stream (ascii)
| std::ostream& operator<< | ( | std::ostream & | str, | |
| const Matrix & | mat | |||
| ) | [friend] |
printing operator: output format: mxn (
row0
.
.rown
) where rowX is tab seperated list of values
1.4.7