MDSTk Libraries  1.1.0
Medical Data Segmentation Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
mds::math::CSparseMatrix< T > Class Template Reference

Template for a two dimensional sparse matrix. More...

#include <mdsSparseMatrix.h>

Inheritance diagram for mds::math::CSparseMatrix< T >:
Inheritance graph
[legend]

List of all members.

Public Types

enum  { CLASS_SPARSEMATRIX }
 Templates that require members of the CMatrix class can use this enum to check the existence. More...
enum  { CLASS_OBJECT }
 Templates that require members of the CObject class can use this enum to check the existence. More...
enum  { HEAP_OBJECT = 0x70616568 }
 Signature used to recognize objects on the heap. More...
typedef CSparseMatrixBase
< CSparseMatrix< T > > 
tBase
 Base class.
typedef T tElement
 Matrix element type.
typedef CSparseMatrix< T > tMatrix
 Matrix type.
typedef Eigen::SparseMatrix
< tElement, Eigen::ColMajor > 
tStorage
 Underlying matrix data (see the Eigen library).

Public Member Functions

CSparseMatrixabs ()
 Makes absolute value of all non-dominant (i.e. non-zero) elements.
CSparseMatrixasDense (CMatrix< T > &result)
 Stores the sparse matrix as dense.
tStorageasEigen ()
 Returns reference to the underlying matrix data (see the Eigen library).
const tStorageasEigen () const
tElementat (tSize row, tSize col)
 Method returns reference to the element at (row, col).
tElement at (tSize row, tSize col) const
 Method returns element (by value) at (row, col).
tElementatRef (tSize row, tSize col)
 Method returns reference to the element at (row, col).
void clear ()
 Clears the whole matrix (i.e. removes all non zeros).
tSize cols () const
template<typename T >
CSparseMatrix< T > & create (tSize rows, tSize cols)
template<typename Derived >
CSparseMatrix< T > & create (const CSparseMatrixBase< Derived > &Matrix)
template<typename Derived >
CSparseMatrix< T > & create (const Eigen::SparseMatrixBase< Derived > &Matrix)
CSparseMatrixcreate (tSize NumOfRows, tSize NumOfCols)
 Creates new matrix of specified dimensions.
template<typename Derived >
CSparseMatrixcreate (const CSparseMatrixBase< Derived > &Matrix)
 Re-creates the matrix.
template<typename Derived >
CSparseMatrixcreate (const Eigen::SparseMatrixBase< Derived > &Matrix)
 Re-creates the matrix.
template<typename T >
 CSparseMatrix ()
template<typename T >
 CSparseMatrix (tSize rows, tSize cols)
template<typename T >
 CSparseMatrix (const CSparseMatrix< T > &Matrix)
template<typename Derived >
 CSparseMatrix (const Eigen::SparseMatrixBase< Derived > &Matrix)
 CSparseMatrix ()
 Declare iterator types tIterator and tConstIterator.
 CSparseMatrix (tSize NumOfRows, tSize NumOfCols)
 Constructor.
 CSparseMatrix (const CSparseMatrix &Matrix)
 Copy constructor.
template<typename Derived >
 CSparseMatrix (const Eigen::SparseMatrixBase< Derived > &Matrix)
 Constructor.
CSparseMatrixfill (const T &Value)
 Changes value of all non-dominant (i.e. non-zero) coefficients.
template<class Function >
Function forEach (Function Func) const
 Calls a function object for every matrix element.
template<class Function >
Function forEach (Function Func) const
 Calls a function object for every non-zero matrix element.
template<class Function >
Function forEachRef (Function Func)
 Calls a function object for every non-dominant matrix element.
template<class Function >
Function forEachRef (Function Func)
 Calls a function object for every non-zero matrix element.
tElement getDominant () const
 Returns the matrix dominant value.
tElement getDominant ()
 Returns matrix dominant value (i.e. zero).
tMatrixgetImpl ()
 Returns reference to the matrix implementation.
const tMatrixgetImpl () const
tSize getNumOfCols () const
tSize getNumOfNonDominant () const
 Returns number of non-dominant (i.e. non-zero) elements.
tSize getNumOfRows () const
 Returns the matrix dimensions.
int getReferencesCount () const
 Returns the number of references.
bool isOnHeap () const
 Returns true if the object is allocated on the heap.
bool isSquare () const
 Type of the matrix.
void lmult (const CVector< T > &vec, CVector< T > &result)
 Matrix vector left multiplication.
 MDS_SHAREDPTR (CSparseMatrix)
 Smart pointer type.
tElementoperator() (tSize row, tSize col)
 Method returns reference to the element at (row, col).
tElement operator() (tSize row, tSize col) const
 Method returns element (by value) at (row, col).
template<typename T >
CSparseMatrix< T > & operator= (const CSparseMatrix< T > &Matrix)
CSparseMatrixoperator= (const CSparseMatrix &Matrix)
 Assignment operator.
template<typename Derived >
CSparseMatrixoperator= (const Eigen::SparseMatrixBase< Derived > &Matrix)
 Assignment operator.
template<typename Derived >
CSparseMatrix< T > & operator= (const Eigen::SparseMatrixBase< Derived > &Matrix)
template<class Function >
Function pforEach (Function Func) const
 Calls a function object for every matrix element.
template<class Function >
Function pforEach (Function Func) const
 Calls a function object for every non-zero matrix element.
template<class Function >
Function pforEachRef (Function Func)
 Calls a function object for every non-dominant matrix element.
template<class Function >
Function pforEachRef (Function Func)
 Calls a function object for every non-zero matrix element.
void rmult (const CVector< T > &vec, CVector< T > &result)
 Matrix vector right multiplication.
tSize rows () const
 Returns the matrix dimensions.
tMatrixset (tSize row, tSize col, const tElement &Value)
 Method sets value of element at (row, col).
CSparseMatrixset (tSize row, tSize col, const tElement &el)
 Method sets value of element at (row, col).
CSparseMatrixtranspose (const CSparseMatrix &Matrix)
 Transpose of the matrix.
CSparseMatrixunit ()
 Makes the matrix unit.
CSparseMatrixzeros ()
 Sets all entries in matrix to zero.
virtual ~CSparseMatrix ()
 Destructor.

Static Public Member Functions

static void * operator new (std::size_t Size)
 Allocates a new object on the heap.

Protected Member Functions

void addReference () const
 Increase the reference counter.
bool delReference () const
 Decrease the reference counter.

Protected Attributes

int m_iHeapObject
 Flag initialized if the object is on the heap.
int m_iReferences
 The number of references to the object.
tStorage m_Matrix
 Internal data storage.

Detailed Description

template<typename T>
class mds::math::CSparseMatrix< T >

Template for a two dimensional sparse matrix.


Member Typedef Documentation

template<typename T >
typedef CSparseMatrixBase<CSparseMatrix<T> > mds::math::CSparseMatrix< T >::tBase

Base class.

template<typename T >
typedef T mds::math::CSparseMatrix< T >::tElement

Matrix element type.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

Matrix type.

template<typename T >
typedef Eigen::SparseMatrix<tElement, Eigen::ColMajor> mds::math::CSparseMatrix< T >::tStorage

Underlying matrix data (see the Eigen library).


Member Enumeration Documentation

template<typename T >
anonymous enum

Templates that require members of the CMatrix class can use this enum to check the existence.

Enumerator:
CLASS_SPARSEMATRIX 
anonymous enum [inherited]

Templates that require members of the CObject class can use this enum to check the existence.

Enumerator:
CLASS_OBJECT 
anonymous enum [inherited]

Signature used to recognize objects on the heap.

Enumerator:
HEAP_OBJECT 

Constructor & Destructor Documentation

template<typename T >
mds::math::CSparseMatrix< T >::CSparseMatrix ( )

Declare iterator types tIterator and tConstIterator.

Default constructor.

template<typename T >
mds::math::CSparseMatrix< T >::CSparseMatrix ( tSize  NumOfRows,
tSize  NumOfCols 
)

Constructor.

template<typename T >
mds::math::CSparseMatrix< T >::CSparseMatrix ( const CSparseMatrix< T > &  Matrix)

Copy constructor.

  • Makes a new copy of the data.
template<typename T >
template<typename Derived >
mds::math::CSparseMatrix< T >::CSparseMatrix ( const Eigen::SparseMatrixBase< Derived > &  Matrix)

Constructor.

template<typename T >
CSparseMatrix::~CSparseMatrix ( ) [virtual]

Destructor.

template<typename T >
template<typename T >
mds::math::CSparseMatrix< T >::CSparseMatrix ( )
template<typename T >
template<typename T >
mds::math::CSparseMatrix< T >::CSparseMatrix ( tSize  rows,
tSize  cols 
)
template<typename T >
template<typename T >
mds::math::CSparseMatrix< T >::CSparseMatrix ( const CSparseMatrix< T > &  Matrix)
template<typename T >
template<typename Derived >
mds::math::CSparseMatrix< T >::CSparseMatrix ( const Eigen::SparseMatrixBase< Derived > &  Matrix)

Member Function Documentation

template<typename T >
CSparseMatrix< T > & CSparseMatrix::abs ( )

Makes absolute value of all non-dominant (i.e. non-zero) elements.

void mds::base::CObject::addReference ( ) const [protected, inherited]

Increase the reference counter.

template<typename T >
CSparseMatrix< T > & CSparseMatrix::asDense ( CMatrix< T > &  result)

Stores the sparse matrix as dense.

template<typename T >
tStorage& mds::math::CSparseMatrix< T >::asEigen ( )

Returns reference to the underlying matrix data (see the Eigen library).

template<typename T >
const tStorage& mds::math::CSparseMatrix< T >::asEigen ( ) const
tElement& mds::math::CSparseMatrixBase< CSparseMatrix< T > >::at ( tSize  row,
tSize  col 
) [inherited]

Method returns reference to the element at (row, col).

template<typename T >
tElement mds::math::CSparseMatrix< T >::at ( tSize  row,
tSize  col 
) const

Method returns element (by value) at (row, col).

If specified element doesn't exist, returns the dominant value.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

template<typename T >
tElement& mds::math::CSparseMatrix< T >::atRef ( tSize  row,
tSize  col 
)

Method returns reference to the element at (row, col).

If specified element doesn't exist, it is inserted automatically.

template<typename T >
void CSparseMatrix::clear ( )

Clears the whole matrix (i.e. removes all non zeros).

template<typename T >
tSize mds::math::CSparseMatrix< T >::cols ( ) const
template<typename T >
template<typename T >
CSparseMatrix<T>& mds::math::CSparseMatrix< T >::create ( tSize  rows,
tSize  cols 
)
template<typename T >
template<typename Derived >
CSparseMatrix<T>& mds::math::CSparseMatrix< T >::create ( const CSparseMatrixBase< Derived > &  Matrix)
template<typename T >
template<typename Derived >
CSparseMatrix<T>& mds::math::CSparseMatrix< T >::create ( const Eigen::SparseMatrixBase< Derived > &  Matrix)
template<typename T >
CSparseMatrix< T > & mds::math::CSparseMatrix< T >::create ( tSize  NumOfRows,
tSize  NumOfCols 
)

Creates new matrix of specified dimensions.

template<typename T >
template<typename Derived >
CSparseMatrix< T > & mds::math::CSparseMatrix< T >::create ( const CSparseMatrixBase< Derived > &  Matrix)

Re-creates the matrix.

  • Makes a new copy of the data.
template<typename T >
template<typename Derived >
CSparseMatrix< T > & mds::math::CSparseMatrix< T >::create ( const Eigen::SparseMatrixBase< Derived > &  Matrix)

Re-creates the matrix.

  • Makes a new copy of the data.
bool mds::base::CObject::delReference ( ) const [protected, inherited]

Decrease the reference counter.

  • Returns true if the decremented number of references is lower or equal to zero and object must be deleted.
template<typename T >
CSparseMatrix< T > & CSparseMatrix::fill ( const T &  Value)

Changes value of all non-dominant (i.e. non-zero) coefficients.

template<typename T >
template<class Function >
Function mds::math::CSparseMatrix< T >::forEach ( Function  Func) const

Calls a function object for every matrix element.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

template<typename T >
template<class Function >
Function mds::math::CSparseMatrix< T >::forEach ( Function  Func) const

Calls a function object for every non-zero matrix element.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

template<typename T >
template<class Function >
Function mds::math::CSparseMatrix< T >::forEachRef ( Function  Func)

Calls a function object for every non-dominant matrix element.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

template<typename T >
template<class Function >
Function mds::math::CSparseMatrix< T >::forEachRef ( Function  Func)

Calls a function object for every non-zero matrix element.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

Returns the matrix dominant value.

template<typename T >
tElement mds::math::CSparseMatrix< T >::getDominant ( )

Returns matrix dominant value (i.e. zero).

Returns reference to the matrix implementation.

const tMatrix& mds::math::CSparseMatrixBase< CSparseMatrix< T > >::getImpl ( ) const [inherited]
template<typename T >
tSize mds::math::CSparseMatrix< T >::getNumOfCols ( ) const
template<typename T >
tSize mds::math::CSparseMatrix< T >::getNumOfNonDominant ( ) const

Returns number of non-dominant (i.e. non-zero) elements.

template<typename T >
tSize mds::math::CSparseMatrix< T >::getNumOfRows ( ) const

Returns the matrix dimensions.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

Returns the number of references.

bool mds::base::CObject::isOnHeap ( ) const [inherited]

Returns true if the object is allocated on the heap.

template<typename T >
bool mds::math::CSparseMatrix< T >::isSquare ( ) const

Type of the matrix.

  • Returns true if the matrix is square.
template<typename T >
void CSparseMatrix::lmult ( const CVector< T > &  vec,
CVector< T > &  result 
)

Matrix vector left multiplication.

template<typename T >
mds::math::CSparseMatrix< T >::MDS_SHAREDPTR ( CSparseMatrix< T >  )

Smart pointer type.

  • Declares type tSmartPtr.
static void* mds::base::CObject::operator new ( std::size_t  Size) [static, inherited]

Allocates a new object on the heap.

tElement& mds::math::CSparseMatrixBase< CSparseMatrix< T > >::operator() ( tSize  row,
tSize  col 
) [inherited]

Method returns reference to the element at (row, col).

template<typename T >
tElement mds::math::CSparseMatrix< T >::operator() ( tSize  row,
tSize  col 
) const

Method returns element (by value) at (row, col).

If specified element doesn't exist, it returns dominant value.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

template<typename T >
template<typename T >
CSparseMatrix<T>& mds::math::CSparseMatrix< T >::operator= ( const CSparseMatrix< T > &  Matrix)
template<typename T >
CSparseMatrix< T > & mds::math::CSparseMatrix< T >::operator= ( const CSparseMatrix< T > &  Matrix)

Assignment operator.

template<typename T >
template<typename Derived >
CSparseMatrix< T > & mds::math::CSparseMatrix< T >::operator= ( const Eigen::SparseMatrixBase< Derived > &  Matrix)

Assignment operator.

template<typename T >
template<typename Derived >
CSparseMatrix<T>& mds::math::CSparseMatrix< T >::operator= ( const Eigen::SparseMatrixBase< Derived > &  Matrix)
template<typename T >
template<class Function >
Function mds::math::CSparseMatrix< T >::pforEach ( Function  Func) const

Calls a function object for every matrix element.

  • Parallel version.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

template<typename T >
template<class Function >
Function mds::math::CSparseMatrix< T >::pforEach ( Function  Func) const

Calls a function object for every non-zero matrix element.

  • Parallel version.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

template<typename T >
template<class Function >
Function mds::math::CSparseMatrix< T >::pforEachRef ( Function  Func)

Calls a function object for every non-dominant matrix element.

  • Parallel version.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

template<typename T >
template<class Function >
Function mds::math::CSparseMatrix< T >::pforEachRef ( Function  Func)

Calls a function object for every non-zero matrix element.

  • Parallel version.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

template<typename T >
void CSparseMatrix::rmult ( const CVector< T > &  vec,
CVector< T > &  result 
)

Matrix vector right multiplication.

template<typename T >
tSize mds::math::CSparseMatrix< T >::rows ( ) const

Returns the matrix dimensions.

Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrix< T > >.

tMatrix& mds::math::CSparseMatrixBase< CSparseMatrix< T > >::set ( tSize  row,
tSize  col,
const tElement Value 
) [inherited]

Method sets value of element at (row, col).

template<typename T >
CSparseMatrix& mds::math::CSparseMatrix< T >::set ( tSize  row,
tSize  col,
const tElement el 
)

Method sets value of element at (row, col).

if element doesn't exist, new one is created.

template<typename T >
CSparseMatrix< T > & CSparseMatrix::transpose ( const CSparseMatrix< T > &  Matrix)

Transpose of the matrix.

template<typename T >
CSparseMatrix< T > & CSparseMatrix::unit ( )

Makes the matrix unit.

template<typename T >
CSparseMatrix< T > & CSparseMatrix::zeros ( )

Sets all entries in matrix to zero.


Member Data Documentation

int mds::base::CObject::m_iHeapObject [mutable, protected, inherited]

Flag initialized if the object is on the heap.

int mds::base::CObject::m_iReferences [mutable, protected, inherited]

The number of references to the object.

  • Zero if there is no reference.
template<typename T >
tStorage mds::math::CSparseMatrix< T >::m_Matrix [protected]

Internal data storage.


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