#include <matrix.h>
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.
Definition at line 127 of file matrix.h.
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) |
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 |
int | convertToBuffer (D *buffer, unsigned int len) const |
stores the content of the matrix (row-wise) in the given buffer | |
list< D > | convertToList () const |
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 | |
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 | |
ostream & | operator<< (ostream &, const Matrix &) |
printing operator: output format: mxn ( row0 . |
|
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 Definition at line 90 of file matrix.cpp. |
|
constucts a instance on the base of a deep copy of the given matrix
Definition at line 85 of file matrix.cpp. |
|
|
|
returns a matrix that consists of b below this
Definition at line 383 of file matrix.cpp. |
|
addition: this = a + b
Definition at line 192 of file matrix.cpp. |
|
Definition at line 115 of file matrix.cpp. |
|
stores the content of the matrix (row-wise) in the given buffer
Definition at line 138 of file matrix.cpp. |
|
Definition at line 147 of file matrix.cpp. |
|
performs a deep copy of the given matrix
|
|
returns the product of all elements
Definition at line 365 of file matrix.cpp. |
|
returns the sum of all elements
Definition at line 374 of file matrix.cpp. |
|
|
|
|
|
maps the matrix to a new matrix with all elements mapped with the given function
Definition at line 273 of file matrix.cpp. |
|
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
Definition at line 286 of file matrix.cpp. |
|
scaling: this = a * fac
Definition at line 222 of file matrix.cpp. |
|
multiplication: this = a * b
Definition at line 204 of file matrix.cpp. |
|
column-wise multiplication
Definition at line 324 of file matrix.cpp. |
|
optimised multiplication of Matrix with its transposed: M * M^T
Definition at line 331 of file matrix.cpp. |
|
row-wise multiplication
Definition at line 318 of file matrix.cpp. |
|
optimised multiplication of transpsoed of Matrix with itself: M^T * M
Definition at line 348 of file matrix.cpp. |
|
product with scalar (double)
Definition at line 496 of file matrix.cpp. |
|
matrix product
Definition at line 490 of file matrix.cpp. |
|
|
|
|
|
Definition at line 479 of file matrix.cpp. |
|
performant combined assigment operators
|
|
Definition at line 484 of file matrix.cpp. |
|
|
|
deep copy
|
|
comparison operator (compares elements with tolerance distance of COMPARE_EPS)
Definition at line 513 of file matrix.cpp. |
|
special matrix potence:
Definition at line 506 of file matrix.cpp. |
|
Definition at line 109 of file matrix.cpp. |
|
sets the data (row-wise).
Definition at line 132 of file matrix.cpp. |
|
sets the size of the matrix and maybe the data if given (row-wise). If data=null then the matrix is set to zero
Definition at line 125 of file matrix.cpp. |
|
subtraction: this = a - b
Definition at line 198 of file matrix.cpp. |
|
sets the matrix a below (this) matrix
Definition at line 310 of file matrix.cpp. |
|
inplace subtraction: this = this - a
|
|
special inplace matrix potence:
Definition at line 242 of file matrix.cpp. |
|
inplace converts matrix to identity (use ^0 to get a copy version of it)
Definition at line 184 of file matrix.cpp. |
|
inplace mapping of matrix elements (element-wise application)
Definition at line 266 of file matrix.cpp. |
|
like toMap, but with an extra parameter for the mapping function.
Definition at line 279 of file matrix.cpp. |
|
inplace multiplication with scalar: this = this*fac
Definition at line 231 of file matrix.cpp. |
|
Inplace column-wise multiplication.
Definition at line 301 of file matrix.cpp. |
|
Inplace row-wise multiplication.
Definition at line 292 of file matrix.cpp. |
|
inplace addition: this = this + a
|
|
inplace transpose
Definition at line 162 of file matrix.cpp. |
|
inplace converts matrix to zero matrix
Definition at line 180 of file matrix.cpp. |
|
|
|
|
|
printing operator: output format: mxn (
.rown Definition at line 527 of file matrix.cpp. |