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

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

#include <mdsSparseMatrixAlt.h>

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

List of all members.

Classes

struct  CEntryCompare
 Nested function class for comparing two std::pairs according to the first element instead of lexicographical. More...

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
< CSparseMatrixAlt< T > > 
tBase
 Base class.
typedef tColumn::const_iterator tColConstIterator
 Const iterator over non-dominant values of column.
typedef tColumn::iterator tColIterator
 Iterator over non-dominant values of column.
typedef std::vector< tEntrytColumn
 Sparse matrix column is represented by vector of entries.
typedef T tElement
 Matrix element type.
typedef std::pair< tSize,
tElement
tEntry
 One entry stored in column constists of row index and value.
typedef CSparseMatrixAlt< T > tMatrix
 Matrix type.
typedef std::vector< tColumntSparseMatrix
 Whole matrix structure is represented by vector of sparse columns.

Public Member Functions

CSparseMatrixAltabs ()
 Makes absolute value of all non-dominant elements.
CSparseMatrixAltasDense (CMatrix< T > &)
 Stores the sparse matrix as dense.
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 whole matrix.
tSize cols () const
template<typename T >
void create (tSize rows, tSize cols)
template<typename T >
void create (tSize rows, tSize cols, const tElement &dominant)
void create (tSize NumOfRows, tSize NumOfCols)
 Creates new matrix of specified dimensions.
template<typename Derived >
CSparseMatrixAlt< T > & create (const CSparseMatrixBase< Derived > &Matrix)
void create (tSize NumOfRows, tSize NumOfCols, const tElement &Dominant)
 Creates new matrix of specified dimensions and dominant entry.
template<typename Derived >
CSparseMatrixAltcreate (const CSparseMatrixBase< Derived > &Matrix)
 Re-creates the matrix.
 CSparseMatrixAlt ()
 Declare iterator types tIterator and tConstIterator.
 CSparseMatrixAlt (tSize NumOfRows, tSize NumOfCols)
 Constructor.
 CSparseMatrixAlt (tSize NumOfRows, tSize NumOfCols, const tElement &Dominant)
 Constructor, in addition parametrized by dominant value.
 CSparseMatrixAlt (const CSparseMatrixAlt &Matrix)
 Copy constructor.
CSparseMatrixAltfill (const T &Value)
 Fills the whole matrix using a given value.
template<class Function >
Function forEach (Function Func) const
 Calls a function object for every non-dominant matrix element.
template<class Function >
Function forEach (Function Func) const
 Calls a function object for every 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-dominant matrix element.
tColIterator getColBegin (tSize col)
 Returns iterator (stl vector iterator) to begining of desired column.
tColConstIterator getColBegin (tSize col) const
tColIterator getColEnd (tSize col)
 Returns iterator (stl vector iterator) to end of desired column.
tColConstIterator getColEnd (tSize col) const
tSize getColSize (tSize col) const
 Returns size of col-th column.
tElement getDominant () const
 Returns the matrix dominant value.
tEntrygetEntry (tSize row, tSize col)
 Returns reference to matrix internal entry.
const tEntrygetEntry (tSize row, tSize col) const
tMatrixgetImpl ()
 Returns reference to the matrix implementation.
const tMatrixgetImpl () const
tElementgetNull ()
 Returns null element of matrix.
const tElementgetNull () const
tSize getNumOfCols () const
tSize getNumOfNonDominant () const
 Returns number of non-dominant elements.
tSize getNumOfRows () const
 Returns the matrix dimensions.
int getReferencesCount () const
 Returns the number of references.
void insert (tSize row, tSize col, tColIterator &col_pos, tElement element)
 Inserts new element into matrix.
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 (CSparseMatrixAlt)
 Smart pointer type.
CSparseMatrixAltones ()
 Sets all elements to one (including non-dominant values).
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).
CSparseMatrixAltoperator= (const CSparseMatrixAlt &Matrix)
 Assignment operator.
template<class Function >
Function pforEach (Function Func) const
 Calls a function object for every non-dominant matrix element.
template<class Function >
Function pforEach (Function Func) const
 Calls a function object for every 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-dominant matrix element.
void rmult (const CVector< T > &vec, CVector< T > &result)
 Matrix vector right multiplication.
tSize rows () const
 Returns the matrix dimensions.
bool search (tSize row, tSize col, tColIterator &it)
 Searches col-th column for index row, returns iterator to that element when found or iterator to first greater value in case i was not found via it parameter.
bool search (tSize row, tSize col, tColConstIterator &it) const
tMatrixset (tSize row, tSize col, const tElement &Value)
 Method sets value of element at (row, col).
CSparseMatrixAltset (tSize row, tSize col, const tElement &el)
 Method sets value of element at (row, col).
CSparseMatrixAlttranspose (const CSparseMatrixAlt &)
 Transpose of the matrix.
CSparseMatrixAltunit ()
 Makes the matrix unit.
CSparseMatrixAltzeros ()
 Sets all entries in matrix to zero.
virtual ~CSparseMatrixAlt ()
 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

tElement m_Dominant
 Dominant matrix value.
int m_iHeapObject
 Flag initialized if the object is on the heap.
int m_iReferences
 The number of references to the object.
tSparseMatrix m_Matrix
 Internal data storage.
tEntry m_NullEntry
 Null matrix entry.
tSize m_NumOfCols
 Number of columns.
tSize m_NumOfNonDominant
 Number of nondominant elements.
tSize m_NumOfRows
 Number of rows.

Detailed Description

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

Template for a two dimensional sparse matrix.

Operations worst case complexity:


Member Typedef Documentation

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

Base class.

template<typename T >
typedef tColumn::const_iterator mds::math::CSparseMatrixAlt< T >::tColConstIterator

Const iterator over non-dominant values of column.

template<typename T >
typedef tColumn::iterator mds::math::CSparseMatrixAlt< T >::tColIterator

Iterator over non-dominant values of column.

template<typename T >
typedef std::vector<tEntry> mds::math::CSparseMatrixAlt< T >::tColumn

Sparse matrix column is represented by vector of entries.

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

Matrix element type.

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

template<typename T >
typedef std::pair<tSize, tElement> mds::math::CSparseMatrixAlt< T >::tEntry

One entry stored in column constists of row index and value.

Matrix type.

template<typename T >
typedef std::vector<tColumn> mds::math::CSparseMatrixAlt< T >::tSparseMatrix

Whole matrix structure is represented by vector of sparse columns.


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 >
CSparseMatrixAlt::CSparseMatrixAlt ( )

Declare iterator types tIterator and tConstIterator.

Constructor

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

Constructor.

template<typename T >
mds::math::CSparseMatrixAlt< T >::CSparseMatrixAlt ( tSize  NumOfRows,
tSize  NumOfCols,
const tElement Dominant 
)

Constructor, in addition parametrized by dominant value.

template<typename T >
CSparseMatrixAlt::CSparseMatrixAlt ( const CSparseMatrixAlt< T > &  Matrix)

Copy constructor.

  • Makes a new copy of the data.
template<typename T >
CSparseMatrixAlt::~CSparseMatrixAlt ( ) [virtual]

Destructor.


Member Function Documentation

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

Makes absolute value of all non-dominant elements.

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

Increase the reference counter.

template<typename T >
CSparseMatrixAlt& mds::math::CSparseMatrixAlt< T >::asDense ( CMatrix< T > &  )

Stores the sparse matrix as dense.

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

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

template<typename T >
CSparseMatrixAlt< T >::tElement CSparseMatrixAlt::at ( tSize  row,
tSize  col 
) const

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

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

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

template<typename T >
CSparseMatrixAlt< T >::tElement & CSparseMatrixAlt::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 CSparseMatrixAlt::clear ( )

Clears whole matrix.

template<typename T >
tSize mds::math::CSparseMatrixAlt< T >::cols ( ) const
template<typename T >
template<typename T >
void mds::math::CSparseMatrixAlt< T >::create ( tSize  rows,
tSize  cols 
)
template<typename T >
template<typename T >
void mds::math::CSparseMatrixAlt< T >::create ( tSize  rows,
tSize  cols,
const tElement dominant 
)
template<typename T >
void mds::math::CSparseMatrixAlt< T >::create ( tSize  NumOfRows,
tSize  NumOfCols 
)

Creates new matrix of specified dimensions.

template<typename T >
template<typename Derived >
CSparseMatrixAlt<T>& mds::math::CSparseMatrixAlt< T >::create ( const CSparseMatrixBase< Derived > &  Matrix)
template<typename T >
void mds::math::CSparseMatrixAlt< T >::create ( tSize  NumOfRows,
tSize  NumOfCols,
const tElement Dominant 
)

Creates new matrix of specified dimensions and dominant entry.

template<typename T >
template<typename Derived >
CSparseMatrixAlt< T > & mds::math::CSparseMatrixAlt< T >::create ( const CSparseMatrixBase< 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 >
CSparseMatrixAlt< T > & CSparseMatrixAlt::fill ( const T &  Value)

Fills the whole matrix using a given value.

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

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

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

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

Calls a function object for every matrix element.

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

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

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

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

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

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

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

template<typename T >
tColIterator mds::math::CSparseMatrixAlt< T >::getColBegin ( tSize  col)

Returns iterator (stl vector iterator) to begining of desired column.

template<typename T >
tColConstIterator mds::math::CSparseMatrixAlt< T >::getColBegin ( tSize  col) const
template<typename T >
tColIterator mds::math::CSparseMatrixAlt< T >::getColEnd ( tSize  col)

Returns iterator (stl vector iterator) to end of desired column.

template<typename T >
tColConstIterator mds::math::CSparseMatrixAlt< T >::getColEnd ( tSize  col) const
template<typename T >
tSize mds::math::CSparseMatrixAlt< T >::getColSize ( tSize  col) const

Returns size of col-th column.

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

Returns the matrix dominant value.

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

template<typename T >
CSparseMatrixAlt< T >::tEntry & CSparseMatrixAlt::getEntry ( tSize  row,
tSize  col 
)

Returns reference to matrix internal entry.

template<typename T >
const CSparseMatrixAlt< T >::tEntry & mds::math::CSparseMatrixAlt< T >::getEntry ( tSize  row,
tSize  col 
) const

Returns reference to the matrix implementation.

const tMatrix& mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >::getImpl ( ) const [inherited]
template<typename T >
tElement* mds::math::CSparseMatrixAlt< T >::getNull ( )

Returns null element of matrix.

template<typename T >
const tElement* mds::math::CSparseMatrixAlt< T >::getNull ( ) const
template<typename T >
tSize mds::math::CSparseMatrixAlt< T >::getNumOfCols ( ) const
template<typename T >
tSize mds::math::CSparseMatrixAlt< T >::getNumOfNonDominant ( ) const

Returns number of non-dominant elements.

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

Returns the matrix dimensions.

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

Returns the number of references.

template<typename T >
void CSparseMatrixAlt::insert ( tSize  row,
tSize  col,
tColIterator col_pos,
tElement  element 
)

Inserts new element into matrix.

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

Returns true if the object is allocated on the heap.

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

Type of the matrix.

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

Matrix vector left multiplication.

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

Smart pointer type.

  • Declares type tSmartPtr.
template<typename T >
CSparseMatrixAlt< T > & CSparseMatrixAlt::ones ( )

Sets all elements to one (including non-dominant values).

static void* mds::base::CObject::operator new ( std::size_t  Size) [static, inherited]

Allocates a new object on the heap.

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

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

template<typename T >
CSparseMatrixAlt< T >::tElement CSparseMatrixAlt::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< CSparseMatrixAlt< T > >.

template<typename T >
CSparseMatrixAlt< T > & CSparseMatrixAlt::operator= ( const CSparseMatrixAlt< T > &  Matrix)

Assignment operator.

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

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

  • Parallel version.

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

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

Calls a function object for every matrix element.

  • Parallel version.

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

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

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

  • Parallel version.

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

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

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

  • Parallel version.

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

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

Matrix vector right multiplication.

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

Returns the matrix dimensions.

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

template<typename T >
bool CSparseMatrixAlt::search ( tSize  row,
tSize  col,
tColIterator it 
)

Searches col-th column for index row, returns iterator to that element when found or iterator to first greater value in case i was not found via it parameter.

template<typename T >
bool mds::math::CSparseMatrixAlt< T >::search ( tSize  row,
tSize  col,
tColConstIterator it 
) const
tMatrix& mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >::set ( tSize  row,
tSize  col,
const tElement Value 
) [inherited]

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

template<typename T >
CSparseMatrixAlt< T > & CSparseMatrixAlt::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 >
CSparseMatrixAlt& mds::math::CSparseMatrixAlt< T >::transpose ( const CSparseMatrixAlt< T > &  )

Transpose of the matrix.

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

Makes the matrix unit.

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

Sets all entries in matrix to zero.


Member Data Documentation

template<typename T >
tElement mds::math::CSparseMatrixAlt< T >::m_Dominant [protected]

Dominant matrix value.

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 >
tSparseMatrix mds::math::CSparseMatrixAlt< T >::m_Matrix [protected]

Internal data storage.

template<typename T >
tEntry mds::math::CSparseMatrixAlt< T >::m_NullEntry [protected]

Null matrix entry.

template<typename T >
tSize mds::math::CSparseMatrixAlt< T >::m_NumOfCols [protected]

Number of columns.

template<typename T >
tSize mds::math::CSparseMatrixAlt< T >::m_NumOfNonDominant [protected]

Number of nondominant elements.

template<typename T >
tSize mds::math::CSparseMatrixAlt< T >::m_NumOfRows [protected]

Number of rows.


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