LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
loos::Math::Matrix< T, OrderPolicy, StoragePolicy > Class Template Reference

Simple matrix template class using policy classes to determine behavior. More...

#include <MatrixImpl.hpp>

Inheritance diagram for loos::Math::Matrix< T, OrderPolicy, StoragePolicy >:
Inheritance graph
[legend]
Collaboration diagram for loos::Math::Matrix< T, OrderPolicy, StoragePolicy >:
Collaboration graph
[legend]

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, StoragePolicycopy (void) const
 Deep copy...
 
uint rows (void) const
 
uint cols (void) const
 
Toperator() (const uint y, const uint x)
 Return the appropriate element (y-rows, x-cols)
 
const Toperator() (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, StoragePolicyreinterpretOrder (const Matrix< T, ColMajor, StoragePolicy > &)
 Convert a Col-major to Row-major format.
 
Matrix< T, ColMajor, StoragePolicyreinterpretOrder (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
 

Detailed Description

template<typename T, class OrderPolicy = ColMajor, template< typename > class StoragePolicy = SharedArray>
class loos::Math::Matrix< T, OrderPolicy, StoragePolicy >

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:
Simple matrix template class using policy classes to determine behavior.
Definition MatrixImpl.hpp:148
Matrix()
Unitialized matrix.
Definition MatrixImpl.hpp:154

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.

M(j,i) = foo;
fu = M(j+1,i);

Alternatively, for dense matrices, you can access the linear array of data underneath the matrix interpretation using operator[], i.e.

foo = M[i*rows+j];
M[i*rows+j+1] = fu;

For dense matrices, you can also access the raw block of memory by getting a pointer to it,

double *dblptr = M.get();
   Finally, you can access iterators into the matrix much like you would
   with an STL container,
std::copy(M.begin(), M.end(), ostream_iterator<double>(cout, "\n"));
   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...
using namespace std;
using namespace loos;
...
writeAsciiMatrix(filename, M, "My matrix");
Namespace for most things not already encapsulated within a class.
Definition version.cpp:3
std::ostream & writeAsciiMatrix(std::ostream &os, const Math::Matrix< T, P, S > &M, const std::string &meta, const Math::Range &start, const Math::Range &end, const bool trans=false, F fmt=F())
Write a submatrix to a stream.
Definition MatrixWrite.hpp:140
   For more information, see loos::writeAsciiMatrix() and loos::readAsciiMatrix()

Constructor & Destructor Documentation

◆ Matrix()

template<typename T , class OrderPolicy = ColMajor, template< typename > class StoragePolicy = SharedArray>
loos::Math::Matrix< T, OrderPolicy, StoragePolicy >::Matrix ( T * p,
const uint b,
const uint a )
inline

Wrap an existing block of data with a Matrix.

This may not make sense, depending on storage policy (i.e. sparse matrices)


The documentation for this class was generated from the following file: