LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
|
Simple matrix template class using policy classes to determine behavior. More...
#include <MatrixImpl.hpp>
Public Types | |
typedef T | element_type |
Public Member Functions | |
Matrix () | |
Unitialized matrix. | |
Matrix (T *p, const uint b, const uint a) | |
Wrap an existing block of data with a Matrix. | |
Matrix (const uint b, const uint a) | |
Create a new block of data for the requested Matrix. | |
Matrix< T, OrderPolicy, StoragePolicy > | copy (void) const |
Deep copy... | |
uint | rows (void) const |
uint | cols (void) const |
T & | operator() (const uint y, const uint x) |
Return the appropriate element (y-rows, x-cols) | |
const T & | operator() (const uint y, const uint x) const |
void | metaData (const std::string &s) |
std::string | metaData (void) const |
void | reset (void) |
Deallocate data... | |
Public Member Functions inherited from loos::Math::ColMajor | |
ColMajor (const uint y, const uint x) | |
ulong | size (void) const |
ulong | index (const uint y, const uint x) const |
Get the index into the linear array of data. | |
Friends | |
Matrix< T, RowMajor, StoragePolicy > | reinterpretOrder (const Matrix< T, ColMajor, StoragePolicy > &) |
Convert a Col-major to Row-major format. | |
Matrix< T, ColMajor, StoragePolicy > | reinterpretOrder (const Matrix< T, RowMajor, StoragePolicy > &) |
Convert a Row-major to Col-major format. | |
Additional Inherited Members | |
Protected Member Functions inherited from loos::Math::ColMajor | |
void | setSize (const uint y, const uint x) |
Reset the [virtual] size of the matrix. | |
Protected Attributes inherited from loos::Math::ColMajor | |
uint | m |
uint | n |
ulong | s |
Simple matrix template class using policy classes to determine behavior.
This class is essentially a wrapper around a block of data with a matrix-style interface. It is not (currently) meant to offer the same operations that a mathematical matrix would offer, despite being in the loos::Math namespace. There are two options to a Matrix, other than the raw data type. The memory layout can be configured, i.e. row-major, column-major, and triangular (symmetric). The storage method can also be configured as either a SharedArray (dense) or SparseArray (sparse). These options are passed to the Matrix template at instantiation. The default options are for a column-major matrix that is dense. For example, the simplest declaration:
creates a dense, column-major matrix M whose elements are a double.
This creates a dense, row-major matrix N whose elements are floats.
Finally,
creates a sparse, triangular matrix whose elements are ints.
Access to the elements of a matrix is permitted in two different ways. You can access the (j,i)'th element (j-rows, i-cols) by using operator(), i.e.
Alternatively, for dense matrices, you can access the linear array of data underneath the matrix interpretation using operator[], i.e.
For dense matrices, you can also access the raw block of memory by getting a pointer to it,
Finally, you can access iterators into the matrix much like you would with an STL container,
Not all Matrix interface functions are valid for all Matrix types. As mentioned above, you cannot access the pointer to a sparse matrix nor use the operator[]. Finally, all matrices are initialized with 0 for each element... \b NOTE Although the Matrix class lives in loos::Math, the I/O functions are all in the loos namespace. The reason for this is so you can import the loos namespace and get the I/O functions without importing the Matrix name, thereby allowing you to typedef it in your code...
For more information, see loos::writeAsciiMatrix() and loos::readAsciiMatrix()
|
inline |
Wrap an existing block of data with a Matrix.
This may not make sense, depending on storage policy (i.e. sparse matrices)