|
golib
0.5
|
Basic sparse matrix class with Matlab mxArray support. More...
#include <gosparsematrix.h>
Public Types | |
| enum | { UNSORTED, ROW_WISE, COLUMN_WISE } |
Public Member Functions | |
| goSparseMatrix (int rows=0, int cols=0) | |
| void | init () |
| void | setSize (int rows, int cols) |
| void | set (int row, int col, double value) |
| Not implemented. More... | |
| int | getElementCount () const |
| Get the total number of nonzero elements. More... | |
| int | getSortType () const |
| bool | fillBegin (int elementCount) |
| Begin filling elementCount elements in this matrix. More... | |
| int | fillNext (int row, int col, double value) |
| Fills the next element in this matrix. More... | |
| void | fillEnd (int sortType=ROW_WISE) |
| Ends filling the matrix. More... | |
| bool | matrixVectorMult (goArray< goDouble > &ret, const goArray< goDouble > &v) |
| (this) * v More... | |
| template<class Tv > | |
| bool | matrixVectorMult (goMath::Vector< Tv > &ret, const goMath::Vector< Tv > &v) |
| (this) * v More... | |
| bool | vectorMatrixMult (goArray< goDouble > &ret, const goArray< goDouble > &v) |
| v' * (this) More... | |
| bool | matrixVectorMult (goSparseMatrix &ret, const goArray< goDouble > &v) |
| (this) * v More... | |
| template<class Tv > | |
| bool | matrixVectorMult (goSparseMatrix &ret, const goMath::Vector< Tv > &v) |
| (this) * v More... | |
| bool | vectorMatrixMult (goSparseMatrix &ret, const goArray< goDouble > &v) |
| v' * (this) More... | |
| bool | matrixMatrixMult (goSparseMatrix &ret, goSparseMatrix &m) |
| bool | matrixMatrixAdd (goSparseMatrix &ret, goSparseMatrix &m) |
| bool | matrixMatrixSubtract (goSparseMatrix &ret, goSparseMatrix &m) |
| goSparseMatrix & | operator*= (goDouble scalar) |
| goSparseMatrix | operator* (const goSparseMatrix &other) const |
| template<class Tv > | |
| goMath::Vector< Tv > | operator* (const goMath::Vector< Tv > &v) const |
| goSparseMatrix | operator* (goDouble s) const |
| goSparseMatrix | operator+ (const goSparseMatrix &m) const |
| goSparseMatrix | operator- (const goSparseMatrix &m) const |
| goIndex_t | row (goIndex_t elementIndex) const |
| Returns the row of the element at elementIndex. | |
| goIndex_t | column (goIndex_t elementIndex) const |
| Returns the row of the element at elementIndex. | |
| goDouble | value (goIndex_t elementIndex) const |
| Returns the value of the element at elementIndex. | |
| int | getRowCount () const |
| Returns the number of rows. | |
| int | getColumnCount () const |
| Returns the number of columns. | |
| const goArray< goIndex_t > & | getRowStart () const |
| For row-sorted matrices. | |
| const goArray< goIndex_t > & | getColStart () const |
| For column-sorted matrices. | |
| void | sortRows (bool sort_columns=false) |
| Sorts in ascending row order. More... | |
| void | sortColumns (bool sort_rows=false) |
| Sorts in ascending column order. More... | |
| void | findRows () |
| void | findColumns () |
| bool | appendRow (const goSparseMatrix &r) |
| Appends the row matrix r to this matrix. More... | |
| bool | appendRows (const goSparseMatrix &m) |
| void | transpose () |
| goArray< goIndex_t > & | getColIndex () |
| const goArray< goIndex_t > & | getColIndex () const |
| goArray< goIndex_t > & | getRowIndex () |
| const goArray< goIndex_t > & | getRowIndex () const |
| goArray< goDouble > & | getValues () |
| const goArray< goDouble > & | getValues () const |
Protected Member Functions | |
| void | setSortType (int t) |
Basic sparse matrix class with Matlab mxArray support.
Provides facilities to fill and read a sparse matrix without the pain in the $#! caused by Matlab's C interface.
However, there are a few things to remember:
It is not too well tested but worked so far for me. There are some more or less limited multiplication functions for goArray and other goSparseMatrix objects. Extend as needed.
To fill a mxArray with 3 values, you could do:
Make a "get all nonzero elements" method.
TEST ADD / MULT / SUBTRACT METHODS THOROUGHLY!