|
| Matrix (const char *name, sval n, sval m=1, bool isShared=false) throw (MemException) |
| Constructs a matrix named `name' of `n' rows and `m' columns, local if `isShared' is false and shared otherwise. More...
|
|
| Matrix (const char *name, const char *type, sval n, sval m=1, bool isShared=false) throw (MemException) |
| Constructs a matrix named `name' with type `type' of `n' rows and `m' columns, local if `isShared' is false and shared otherwise. More...
|
|
| Matrix (const char *name, const char *type, const char *sharedname, const char *serialmeta, sval n, sval m) throw (MemException) |
| Constructor for unpickling only, do not use. More...
|
|
| Matrix (const char *name, const char *type, const T *array, sval n, sval m, bool isShared=false) throw (MemException) |
| Constructor for converting a memory pointer into a Matrix, this will copy n*m values from `array'. More...
|
|
virtual | ~Matrix () |
|
T * | dataPtr () const |
|
Matrix< T > * | clone (const char *newname=NULL, bool isShared=false) const |
| Copy the contents of this matrix into a newly allocated one (which can be shared if isShared is true), using `newname' if not NULL and getName() otherwise. More...
|
|
const char * | getName () const |
|
const char * | getSharedName () const |
|
const char * | getType () const |
|
void | setName (const char *name) |
|
void | setType (const char *type) |
|
bool | isShared () const |
| Returns true if the matrix is allocated in shared memory. More...
|
|
void | setShared (bool val) throw (MemException) |
|
void | clear () throw (MemException) |
|
sval | n () const |
| Get the number of rows. More...
|
|
sval | m () const |
| Get the number of columns. More...
|
|
sval | memSize () const |
| Get the total memory usage in bytes. More...
|
|
void | fill (const T &t) |
| Set every cell of the matrix to the given value. More...
|
|
template<typename R > |
void | copyFrom (const Matrix< R > *r) |
| Copy the data bitwise from `r', the number of bytes copied is the minimum or either matrices' size. More...
|
|
Matrix< T > * | subMatrix (const char *name, sval n, sval m=1, sval noff=0, sval moff=0, bool isShared=false) const throw (MemException) |
| Create a submatrix from this one of dimensions (n,m), starting at row `noff' and column `moff'. More...
|
|
Matrix< T > * | reshape (const char *name, sval n, sval m, bool isShared=false) const throw (MemException) |
|
template<typename Ctx > |
void | applyFunc (T(*op)(Ctx, const T &, sval, sval), Ctx ctx, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1) |
| Apply the function `op' to each cell from (minrow,mincol) to (maxrow-1,maxcol-1), passing in `ctx' as the first argument for each call. More...
|
|
template<typename R , typename OpType > |
void | scalarop (const R &r, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1) |
| Apply the operation OpType::op to every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix with `r' as the second operand. More...
|
|
template<typename R , typename OpType > |
void | matop (const Matrix< R > &mat, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1) |
| Apply the operation OpType::op to every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix with the equivalent cell in `mat' as the second operand. More...
|
|
template<typename R > |
void | add (const R &r, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1) |
| Add `r' to every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix. More...
|
|
template<typename R > |
void | sub (const R &r, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1) |
| Subtract `r' from every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix. More...
|
|
template<typename R > |
void | mul (const R &r, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1) |
| Multiple every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix by `r'. More...
|
|
template<typename R > |
void | div (const R &r, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1) |
| Divide every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix by `r'. More...
|
|
template<typename R > |
void | addm (const Matrix< R > &mat, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1) |
| Add every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in `mat' to the same cell in the matrix. More...
|
|
template<typename R > |
void | subm (const Matrix< R > &mat, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1) |
| Subtract every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in `mat' from the same cell in the matrix. More...
|
|
template<typename R > |
void | mulm (const Matrix< R > &mat, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1) |
| Multiply every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix by the same in `mat'. More...
|
|
template<typename R > |
void | divm (const Matrix< R > &mat, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1) |
| Divide every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix by the same in `mat'. More...
|
|
void | reorderColumns (const sval *orderinds) throw (IndexException) |
|
void | swapEndian () |
|
T & | at (sval n, sval m=0) const |
| Same as getAt except returning a reference and no bounds check. More...
|
|
const T & | atc (sval n, sval m=0) const |
|
void | ats (sval n, sval m, const T &t) |
|
T & | operator() (sval n, sval m=0) const |
| Same as getAt except returning a reference and no bounds check. More...
|
|
T & | operator[] (sval n) const |
|
T | getAt (sval n, sval m=0) const throw (IndexException) |
| Get the element at (n,m) in the matrix, throws exception if `n' or `m' out of range. More...
|
|
void | setAt (const T &t, sval n, sval m=0) throw (IndexException) |
| Set the value at (n,m) to t. More...
|
|
void | setN (sval _newn) throw (MemException) |
| Resize the matrix to have _newn rows, throws exception if shared. More...
|
|
void | setM (sval _newm) throw (MemException) |
| Reshape to fit this many columns, does not allocate new columns but re-arranges existing ones and truncates the last row if necessary. More...
|
|
void | addRows (sval num) throw (MemException) |
| Add `num' rows, throws exception if shared. More...
|
|
void | reserveRows (sval num) throw (MemException) |
| Ensure that at least `num' rows are reserved in memory, throws exception if shared. More...
|
|
void | append (const Matrix< T > &t) throw (MemException) |
| Append `t' to the bottom of `this', throws exception if shared or if columns of `t' and `this' don't match. More...
|
|
void | append (const T &t, sval m=0) throw (MemException) |
| Append `t' to a new row, placing it in column `m'. More...
|
|
void | removeRow (sval n) throw (MemException,IndexException) |
|
void | readBinaryFile (const char *filename, size_t offset) throw (MemException) |
| Read a binary file of data into this matrix starting from byte `offset'. More...
|
|
void | readTextFile (const char *filename, sval numHeaders) throw (MemException) |
| Read a text file of data into this matrix which has with `numHeaders' values in the header line. More...
|
|
void | storeBinaryFile (const char *filename, int *header, sval headerlen) throw (MemException) |
| Store the header values `header' and then this matrix's contents to the file. More...
|
|
indexpair | indexOf (const T &t, sval aftern=0, sval afterm=0) const |
| Find the row-column pair in the matrix where `t' is found, or indexpair(n(),0) if not found (None in Python) More...
|
|
bool | hasMetaKey (const char *key) const |
| Returns true if a key-value pair with the given key is present. More...
|
|
std::vector< std::string > | getMetaKeys () const |
|
std::string | meta () const |
|
const char * | meta (const char *key) const |
| Returns the value associated with the given key or the empty string if none is stored. More...
|
|
void | meta (const char *key, const char *val) |
| Add the given key-value pair to the metadata, or overwrite an existing if present. Does nothing if either argument is NULL. More...
|
|
void | meta (const MetaType *m) |
| Copy all the metadata from `m' to `this'. More...
|
|
std::string | serializeMeta () const |
| Turn all metadata name-value pairs into one string suitable for pickling. More...
|
|
void | deserializeMeta (const std::string &s) |
| Break a string generated by the above back into name-value pairs and store in `this'. More...
|
|
template<typename T>
class RenderTypes::Matrix< T >
This represents a 2-dimensional array of data elements of type T. There are four typedefs given below for T being vec3, color, indexval, and real. A number of methods are provided for doing arithmetic with all the elements of a matrix and with whole matrices. A facility is provided for defining matrices as shared memory segments suitable for communication between processes.
Matrix types are indexed in (row,column) or (Y,X) order since they are used to represent lists or entries, are thus expandable by adding rows but not columns, and are stored in row major order.