MDSTk Libraries
1.1.0
Medical Data Segmentation Toolkit
|
Template for a two dimensional sparse matrix. More...
#include <mdsSparseMatrixAlt.h>
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< tEntry > | tColumn |
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< tColumn > | tSparseMatrix |
Whole matrix structure is represented by vector of sparse columns. | |
Public Member Functions | |
CSparseMatrixAlt & | abs () |
Makes absolute value of all non-dominant elements. | |
CSparseMatrixAlt & | asDense (CMatrix< T > &) |
Stores the sparse matrix as dense. | |
tElement & | at (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). | |
tElement & | atRef (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 > | |
CSparseMatrixAlt & | create (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. | |
CSparseMatrixAlt & | fill (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. | |
tEntry & | getEntry (tSize row, tSize col) |
Returns reference to matrix internal entry. | |
const tEntry & | getEntry (tSize row, tSize col) const |
tMatrix & | getImpl () |
Returns reference to the matrix implementation. | |
const tMatrix & | getImpl () const |
tElement * | getNull () |
Returns null element of matrix. | |
const tElement * | getNull () 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. | |
CSparseMatrixAlt & | ones () |
Sets all elements to one (including non-dominant values). | |
tElement & | operator() (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). | |
CSparseMatrixAlt & | operator= (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 |
tMatrix & | set (tSize row, tSize col, const tElement &Value) |
Method sets value of element at (row, col). | |
CSparseMatrixAlt & | set (tSize row, tSize col, const tElement &el) |
Method sets value of element at (row, col). | |
CSparseMatrixAlt & | transpose (const CSparseMatrixAlt &) |
Transpose of the matrix. | |
CSparseMatrixAlt & | unit () |
Makes the matrix unit. | |
CSparseMatrixAlt & | zeros () |
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. |
Template for a two dimensional sparse matrix.
Operations worst case complexity:
typedef CSparseMatrixBase<CSparseMatrixAlt<T> > mds::math::CSparseMatrixAlt< T >::tBase |
Base class.
typedef tColumn::const_iterator mds::math::CSparseMatrixAlt< T >::tColConstIterator |
Const iterator over non-dominant values of column.
typedef tColumn::iterator mds::math::CSparseMatrixAlt< T >::tColIterator |
Iterator over non-dominant values of column.
typedef std::vector<tEntry> mds::math::CSparseMatrixAlt< T >::tColumn |
Sparse matrix column is represented by vector of entries.
typedef T mds::math::CSparseMatrixAlt< T >::tElement |
Matrix element type.
Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >.
typedef std::pair<tSize, tElement> mds::math::CSparseMatrixAlt< T >::tEntry |
One entry stored in column constists of row index and value.
typedef CSparseMatrixAlt< T > mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >::tMatrix [inherited] |
Matrix type.
typedef std::vector<tColumn> mds::math::CSparseMatrixAlt< T >::tSparseMatrix |
Whole matrix structure is represented by vector of sparse columns.
anonymous enum |
Templates that require members of the CMatrix class can use this enum to check the existence.
anonymous enum [inherited] |
Templates that require members of the CObject class can use this enum to check the existence.
CSparseMatrixAlt::CSparseMatrixAlt | ( | ) |
Declare iterator types tIterator and tConstIterator.
Constructor
mds::math::CSparseMatrixAlt< T >::CSparseMatrixAlt | ( | tSize | NumOfRows, |
tSize | NumOfCols | ||
) |
Constructor.
mds::math::CSparseMatrixAlt< T >::CSparseMatrixAlt | ( | tSize | NumOfRows, |
tSize | NumOfCols, | ||
const tElement & | Dominant | ||
) |
Constructor, in addition parametrized by dominant value.
CSparseMatrixAlt::CSparseMatrixAlt | ( | const CSparseMatrixAlt< T > & | Matrix | ) |
Copy constructor.
CSparseMatrixAlt::~CSparseMatrixAlt | ( | ) | [virtual] |
Destructor.
CSparseMatrixAlt< T > & CSparseMatrixAlt::abs | ( | ) |
Makes absolute value of all non-dominant elements.
void mds::base::CObject::addReference | ( | ) | const [protected, inherited] |
Increase the reference counter.
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).
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 > >.
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.
void CSparseMatrixAlt::clear | ( | ) |
Clears whole matrix.
tSize mds::math::CSparseMatrixAlt< T >::cols | ( | ) | const |
Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >.
void mds::math::CSparseMatrixAlt< T >::create | ( | tSize | rows, |
tSize | cols | ||
) |
void mds::math::CSparseMatrixAlt< T >::create | ( | tSize | rows, |
tSize | cols, | ||
const tElement & | dominant | ||
) |
void mds::math::CSparseMatrixAlt< T >::create | ( | tSize | NumOfRows, |
tSize | NumOfCols | ||
) |
Creates new matrix of specified dimensions.
CSparseMatrixAlt<T>& mds::math::CSparseMatrixAlt< T >::create | ( | const CSparseMatrixBase< Derived > & | Matrix | ) |
void mds::math::CSparseMatrixAlt< T >::create | ( | tSize | NumOfRows, |
tSize | NumOfCols, | ||
const tElement & | Dominant | ||
) |
Creates new matrix of specified dimensions and dominant entry.
CSparseMatrixAlt< T > & mds::math::CSparseMatrixAlt< T >::create | ( | const CSparseMatrixBase< Derived > & | Matrix | ) |
Re-creates the matrix.
bool mds::base::CObject::delReference | ( | ) | const [protected, inherited] |
Decrease the reference counter.
CSparseMatrixAlt< T > & CSparseMatrixAlt::fill | ( | const T & | Value | ) |
Fills the whole matrix using a given value.
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 > >.
Function mds::math::CSparseMatrixAlt< T >::forEach | ( | Function | Func | ) | const |
Calls a function object for every matrix element.
Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >.
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 > >.
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 > >.
tColIterator mds::math::CSparseMatrixAlt< T >::getColBegin | ( | tSize | col | ) |
Returns iterator (stl vector iterator) to begining of desired column.
tColConstIterator mds::math::CSparseMatrixAlt< T >::getColBegin | ( | tSize | col | ) | const |
tColIterator mds::math::CSparseMatrixAlt< T >::getColEnd | ( | tSize | col | ) |
Returns iterator (stl vector iterator) to end of desired column.
tColConstIterator mds::math::CSparseMatrixAlt< T >::getColEnd | ( | tSize | col | ) | const |
tSize mds::math::CSparseMatrixAlt< T >::getColSize | ( | tSize | col | ) | const |
Returns size of col-th column.
tElement mds::math::CSparseMatrixAlt< T >::getDominant | ( | ) | const |
Returns the matrix dominant value.
Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >.
CSparseMatrixAlt< T >::tEntry & CSparseMatrixAlt::getEntry | ( | tSize | row, |
tSize | col | ||
) |
Returns reference to matrix internal entry.
const CSparseMatrixAlt< T >::tEntry & mds::math::CSparseMatrixAlt< T >::getEntry | ( | tSize | row, |
tSize | col | ||
) | const |
tMatrix& mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >::getImpl | ( | ) | [inherited] |
Returns reference to the matrix implementation.
const tMatrix& mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >::getImpl | ( | ) | const [inherited] |
tElement* mds::math::CSparseMatrixAlt< T >::getNull | ( | ) |
Returns null element of matrix.
const tElement* mds::math::CSparseMatrixAlt< T >::getNull | ( | ) | const |
tSize mds::math::CSparseMatrixAlt< T >::getNumOfCols | ( | ) | const |
Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >.
tSize mds::math::CSparseMatrixAlt< T >::getNumOfNonDominant | ( | ) | const |
Returns number of non-dominant elements.
tSize mds::math::CSparseMatrixAlt< T >::getNumOfRows | ( | ) | const |
Returns the matrix dimensions.
Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >.
int mds::base::CObject::getReferencesCount | ( | ) | const [inherited] |
Returns the number of references.
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.
bool mds::math::CSparseMatrixAlt< T >::isSquare | ( | ) | const |
Type of the matrix.
void CSparseMatrixAlt::lmult | ( | const CVector< T > & | vec, |
CVector< T > & | result | ||
) |
Matrix vector left multiplication.
mds::math::CSparseMatrixAlt< T >::MDS_SHAREDPTR | ( | CSparseMatrixAlt< T > | ) |
Smart pointer type.
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).
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 > >.
CSparseMatrixAlt< T > & CSparseMatrixAlt::operator= | ( | const CSparseMatrixAlt< T > & | Matrix | ) |
Assignment operator.
Function mds::math::CSparseMatrixAlt< T >::pforEach | ( | Function | Func | ) | const |
Calls a function object for every non-dominant matrix element.
Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >.
Function mds::math::CSparseMatrixAlt< T >::pforEach | ( | Function | Func | ) | const |
Calls a function object for every matrix element.
Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >.
Function mds::math::CSparseMatrixAlt< T >::pforEachRef | ( | Function | Func | ) |
Calls a function object for every non-dominant matrix element.
Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >.
Function mds::math::CSparseMatrixAlt< T >::pforEachRef | ( | Function | Func | ) |
Calls a function object for every non-dominant matrix element.
Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrixAlt< T > >.
void CSparseMatrixAlt::rmult | ( | const CVector< T > & | vec, |
CVector< T > & | result | ||
) |
Matrix vector right multiplication.
tSize mds::math::CSparseMatrixAlt< T >::rows | ( | ) | const |
Returns the matrix dimensions.
Reimplemented from mds::math::CSparseMatrixBase< CSparseMatrixAlt< 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.
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).
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.
CSparseMatrixAlt& mds::math::CSparseMatrixAlt< T >::transpose | ( | const CSparseMatrixAlt< T > & | ) |
Transpose of the matrix.
CSparseMatrixAlt< T > & CSparseMatrixAlt::unit | ( | ) |
Makes the matrix unit.
CSparseMatrixAlt< T > & CSparseMatrixAlt::zeros | ( | ) |
Sets all entries in matrix to zero.
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.
tSparseMatrix mds::math::CSparseMatrixAlt< T >::m_Matrix [protected] |
Internal data storage.
tEntry mds::math::CSparseMatrixAlt< T >::m_NullEntry [protected] |
Null matrix entry.
tSize mds::math::CSparseMatrixAlt< T >::m_NumOfCols [protected] |
Number of columns.
tSize mds::math::CSparseMatrixAlt< T >::m_NumOfNonDominant [protected] |
Number of nondominant elements.
tSize mds::math::CSparseMatrixAlt< T >::m_NumOfRows [protected] |
Number of rows.