MRPT  1.9.9
List of all members | Public Types | Public Member Functions | Protected Attributes
mrpt::math::CSparseSymmetricalMatrix< T > Class Template Reference

Detailed Description

template<class T>
class mrpt::math::CSparseSymmetricalMatrix< T >

A sparse matrix container for square symmetrical content around the main diagonal.

This class saves half of the space with respect to CSparseMatrixTemplate since only those entries (c,r) such as c>=r are really stored, but both (c,r) and (r,c) can be retrieved or set and both redirect to the same internal cell container.

See also
CSparseMatrixTemplate

Definition at line 404 of file CSparseMatrixTemplate.h.

#include <mrpt/math/CSparseMatrixTemplate.h>

Inheritance diagram for mrpt::math::CSparseSymmetricalMatrix< T >:

Public Types

using SparseMatrixMap = typename std::map< std::pair< size_t, size_t >, T >
 Internal map type, used to store the actual matrix. More...
 
using const_iterator = typename SparseMatrixMap::const_iterator
 Const iterator to move through the matrix. More...
 
using const_reverse_iterator = typename SparseMatrixMap::const_reverse_iterator
 Const reverse iterator to move through the matrix. More...
 

Public Member Functions

 CSparseSymmetricalMatrix ()
 
 CSparseSymmetricalMatrix (const CSparseSymmetricalMatrix &o)
 
 CSparseSymmetricalMatrix (const CSparseMatrixTemplate< T > &o)
 
virtual ~CSparseSymmetricalMatrix ()=default
 
void resize (size_t matrixSize)
 
operator() (size_t r, size_t c) const
 
T & operator() (size_t r, size_t c)
 
CSparseMatrixTemplate< T > operator() (size_t firstRow, size_t lastRow, size_t firstColumn, size_t lastColumn) const
 Extracts a submatrix form the matrix. More...
 
bool exists (size_t r, size_t c) const
 Element access operator. More...
 
size_t rows () const
 Returns the amount of rows in this matrix. More...
 
size_t cols () const
 Returns the amount of columns in this matrix. More...
 
template<typename VECTOR >
void getRow (size_t nRow, VECTOR &vec) const
 Extracts a full row from the matrix. More...
 
template<typename VECTOR >
void getColumn (size_t nCol, VECTOR &vec) const
 Extracts a full column from the matrix. More...
 
void insert (size_t row, size_t column, const T &obj)
 Inserts an element into the matrix. More...
 
template<class MATRIX_LIKE >
void insertMatrix (size_t row, size_t column, const MATRIX_LIKE &mat)
 Inserts submatrix at a given location. More...
 
const_iterator begin () const
 Returns an iterator which points to the starting point of the matrix. More...
 
const_iterator end () const
 Returns an iterator which points to the end of the matrix. More...
 
const_reverse_iterator rbegin () const
 Returns an iterator which points to the end of the matrix, and can be used to move backwards. More...
 
const_reverse_iterator rend () const
 Returns an iterator which points to the starting point of the matrix, although it's the upper limit of the matrix since it's a reverse iterator. More...
 
template<typename VECTOR >
void setRow (size_t nRow, const VECTOR &vec, const T &nullObject=T())
 Inserts a full row into the matrix. More...
 
template<typename VECTOR >
void setColumn (size_t nCol, const VECTOR &vec, const T &nullObject=T())
 Inserts a full column into the matrix. More...
 
void resize (size_t nRows, size_t nCols)
 Changes the size of the matrix. More...
 
template<typename VECTOR >
void asVector (VECTOR &vec) const
 Gets a vector containing all the elements of the matrix, ignoring their position. More...
 
size_t getNonNullElements () const
 Gets the amount of non-null elements inside the matrix. More...
 
bool empty () const
 Are there no elements set to !=0 ? More...
 
size_t getNullElements () const
 Gets the amount of null elements inside the matrix. More...
 
bool isNull (size_t nRow, size_t nCol) const
 Checks whether an element of the matrix is the default object. More...
 
bool isNotNull (size_t nRow, size_t nCol) const
 Checks whether an element of the matrix is not the default object. More...
 
void clear ()
 Completely removes all elements, although maintaining the matrix's size. More...
 
void purge (T nullObject=T())
 Checks each non-null elements against the basic objects, erasing unnecesary references to it. More...
 

Protected Attributes

size_t mRows {0}
 Size of the matrix. More...
 
size_t mColumns {0}
 
SparseMatrixMap objectList
 Actual matrix. More...
 

Member Typedef Documentation

◆ const_iterator

template<class T>
using mrpt::math::CSparseMatrixTemplate< T >::const_iterator = typename SparseMatrixMap::const_iterator
inherited

Const iterator to move through the matrix.

See also
CSparseMatrixTemplate::const_reverse_iterator

Definition at line 52 of file CSparseMatrixTemplate.h.

◆ const_reverse_iterator

template<class T>
using mrpt::math::CSparseMatrixTemplate< T >::const_reverse_iterator = typename SparseMatrixMap::const_reverse_iterator
inherited

Const reverse iterator to move through the matrix.

See also
CSparseMatrixTemplate::const_iterator

Definition at line 58 of file CSparseMatrixTemplate.h.

◆ SparseMatrixMap

template<class T>
using mrpt::math::CSparseMatrixTemplate< T >::SparseMatrixMap = typename std::map<std::pair<size_t, size_t>, T>
inherited

Internal map type, used to store the actual matrix.

Definition at line 47 of file CSparseMatrixTemplate.h.

Constructor & Destructor Documentation

◆ CSparseSymmetricalMatrix() [1/3]

Definition at line 407 of file CSparseMatrixTemplate.h.

◆ CSparseSymmetricalMatrix() [2/3]

template<class T >
mrpt::math::CSparseSymmetricalMatrix< T >::CSparseSymmetricalMatrix ( const CSparseSymmetricalMatrix< T > &  o)
inlineexplicit

Definition at line 408 of file CSparseMatrixTemplate.h.

◆ CSparseSymmetricalMatrix() [3/3]

template<class T >
mrpt::math::CSparseSymmetricalMatrix< T >::CSparseSymmetricalMatrix ( const CSparseMatrixTemplate< T > &  o)
inlineexplicit

Definition at line 412 of file CSparseMatrixTemplate.h.

◆ ~CSparseSymmetricalMatrix()

template<class T >
virtual mrpt::math::CSparseSymmetricalMatrix< T >::~CSparseSymmetricalMatrix ( )
virtualdefault

Member Function Documentation

◆ asVector()

template<class T>
template<typename VECTOR >
void mrpt::math::CSparseMatrixTemplate< T >::asVector ( VECTOR &  vec) const
inlineinherited

Gets a vector containing all the elements of the matrix, ignoring their position.

Definition at line 330 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::objectList.

◆ begin()

template<class T>
const_iterator mrpt::math::CSparseMatrixTemplate< T >::begin ( ) const
inlineinherited

Returns an iterator which points to the starting point of the matrix.

It's a const_iterator, so that the usar isn't able to modify the matrix content into an invalid state.

See also
end,rbegin,rend

Definition at line 205 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::objectList.

Referenced by mrpt::math::CSparseMatrixTemplate< T >::operator()(), and mrpt::math::CSparseMatrixTemplate< T >::purge().

Here is the caller graph for this function:

◆ clear()

template<class T>
void mrpt::math::CSparseMatrixTemplate< T >::clear ( )
inlineinherited

Completely removes all elements, although maintaining the matrix's size.

Definition at line 380 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::objectList.

Referenced by mrpt::math::intersect().

Here is the caller graph for this function:

◆ cols()

template<class T>
size_t mrpt::math::CSparseMatrixTemplate< T >::cols ( ) const
inlineinherited

Returns the amount of columns in this matrix.

See also
rows()

Definition at line 120 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::mColumns.

Referenced by depthFirstSearch(), and mrpt::math::intersect().

Here is the caller graph for this function:

◆ empty()

template<class T>
bool mrpt::math::CSparseMatrixTemplate< T >::empty ( ) const
inlineinherited

Are there no elements set to !=0 ?

See also
getNullElements,isNull,isNotNull

Definition at line 347 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::objectList.

◆ end()

template<class T>
const_iterator mrpt::math::CSparseMatrixTemplate< T >::end ( ) const
inlineinherited

Returns an iterator which points to the end of the matrix.

It's a const_iterator, so that the usar isn't able to modify the matrix content into an invalid state.

See also
begin,rbegin,rend

Definition at line 212 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::objectList.

Referenced by mrpt::math::CSparseMatrixTemplate< T >::operator()(), mrpt::math::CSparseSymmetricalMatrix< T >::operator()(), and mrpt::math::CSparseMatrixTemplate< T >::purge().

Here is the caller graph for this function:

◆ exists()

template<class T>
bool mrpt::math::CSparseMatrixTemplate< T >::exists ( size_t  r,
size_t  c 
) const
inlineinherited

◆ getColumn()

template<class T>
template<typename VECTOR >
void mrpt::math::CSparseMatrixTemplate< T >::getColumn ( size_t  nCol,
VECTOR &  vec 
) const
inlineinherited

Extracts a full column from the matrix.

See also
getColCount,getRow,setColumn
Exceptions
std::logic_erroron out of range.

Definition at line 159 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.

◆ getNonNullElements()

template<class T>
size_t mrpt::math::CSparseMatrixTemplate< T >::getNonNullElements ( ) const
inlineinherited

Gets the amount of non-null elements inside the matrix.

See also
getNullElements,isNull,isNotNull

Definition at line 343 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::objectList.

Referenced by mrpt::math::CSparseMatrixTemplate< T >::getNullElements(), and mrpt::math::intersect().

Here is the caller graph for this function:

◆ getNullElements()

template<class T>
size_t mrpt::math::CSparseMatrixTemplate< T >::getNullElements ( ) const
inlineinherited

Gets the amount of null elements inside the matrix.

See also
getNonNullElements,isNull,isNotNull

Definition at line 352 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::getNonNullElements(), mrpt::math::CSparseMatrixTemplate< T >::mColumns, and mrpt::math::CSparseMatrixTemplate< T >::mRows.

Here is the call graph for this function:

◆ getRow()

template<class T>
template<typename VECTOR >
void mrpt::math::CSparseMatrixTemplate< T >::getRow ( size_t  nRow,
VECTOR &  vec 
) const
inlineinherited

Extracts a full row from the matrix.

See also
rows(),getColumn,setRow
Exceptions
std::logic_erroron out of range.

Definition at line 127 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.

◆ insert()

template<class T>
void mrpt::math::CSparseMatrixTemplate< T >::insert ( size_t  row,
size_t  column,
const T &  obj 
)
inlineinherited

Inserts an element into the matrix.

See also
operator()(size_t,size_t)

Definition at line 183 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::operator()().

Here is the call graph for this function:

◆ insertMatrix()

template<class T>
template<class MATRIX_LIKE >
void mrpt::math::CSparseMatrixTemplate< T >::insertMatrix ( size_t  row,
size_t  column,
const MATRIX_LIKE &  mat 
)
inlineinherited

Inserts submatrix at a given location.

Definition at line 190 of file CSparseMatrixTemplate.h.

◆ isNotNull()

template<class T>
bool mrpt::math::CSparseMatrixTemplate< T >::isNotNull ( size_t  nRow,
size_t  nCol 
) const
inlineinherited

Checks whether an element of the matrix is not the default object.

See also
getNonNullElements,getNullElements,isNull

Definition at line 371 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.

Referenced by depthFirstSearch().

Here is the caller graph for this function:

◆ isNull()

template<class T>
bool mrpt::math::CSparseMatrixTemplate< T >::isNull ( size_t  nRow,
size_t  nCol 
) const
inlineinherited

Checks whether an element of the matrix is the default object.

See also
getNonNullElements,getNullElements,isNotNull
Exceptions
std::logic_erroron out of range

Definition at line 361 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.

◆ operator()() [1/3]

template<class T>
CSparseMatrixTemplate<T> mrpt::math::CSparseMatrixTemplate< T >::operator() ( size_t  firstRow,
size_t  lastRow,
size_t  firstColumn,
size_t  lastColumn 
) const
inlineinherited

Extracts a submatrix form the matrix.

See also
operator()(size_t,size_t)
Exceptions
std::logic_erroron invalid bounds.

Definition at line 303 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::begin(), mrpt::math::CSparseMatrixTemplate< T >::end(), mrpt::math::CSparseMatrixTemplate< T >::mColumns, and mrpt::math::CSparseMatrixTemplate< T >::mRows.

Here is the call graph for this function:

◆ operator()() [2/3]

template<class T >
T mrpt::math::CSparseSymmetricalMatrix< T >::operator() ( size_t  r,
size_t  c 
) const
inline

Definition at line 422 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::end().

Here is the call graph for this function:

◆ operator()() [3/3]

template<class T >
T& mrpt::math::CSparseSymmetricalMatrix< T >::operator() ( size_t  r,
size_t  c 
)
inline

Definition at line 432 of file CSparseMatrixTemplate.h.

◆ purge()

template<class T>
void mrpt::math::CSparseMatrixTemplate< T >::purge ( nullObject = T())
inlineinherited

Checks each non-null elements against the basic objects, erasing unnecesary references to it.

Definition at line 385 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::begin(), mrpt::math::CSparseMatrixTemplate< T >::end(), and mrpt::math::CSparseMatrixTemplate< T >::objectList.

Here is the call graph for this function:

◆ rbegin()

template<class T>
const_reverse_iterator mrpt::math::CSparseMatrixTemplate< T >::rbegin ( ) const
inlineinherited

Returns an iterator which points to the end of the matrix, and can be used to move backwards.

It's a const_reverse_iterator, so that the usar isn't able to modify the matrix content into an invalid state.

See also
begin,end,rend

Definition at line 219 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::objectList.

◆ rend()

template<class T>
const_reverse_iterator mrpt::math::CSparseMatrixTemplate< T >::rend ( ) const
inlineinherited

Returns an iterator which points to the starting point of the matrix, although it's the upper limit of the matrix since it's a reverse iterator.

Also, it's a const_reverse_iterator, so that the usar isn't able to modify the matrix content into an invalid state.

See also
begin,end,rbegin

Definition at line 227 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::objectList.

◆ resize() [1/2]

template<class T>
void mrpt::math::CSparseMatrixTemplate< T >::resize ( size_t  nRows,
size_t  nCols 
)
inlineinherited

Changes the size of the matrix.

Definition at line 281 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.

Referenced by mrpt::math::intersect(), and mrpt::math::CSparseSymmetricalMatrix< T >::resize().

Here is the caller graph for this function:

◆ resize() [2/2]

template<class T >
void mrpt::math::CSparseSymmetricalMatrix< T >::resize ( size_t  matrixSize)
inline

Definition at line 417 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::resize().

Here is the call graph for this function:

◆ rows()

template<class T>
size_t mrpt::math::CSparseMatrixTemplate< T >::rows ( ) const
inlineinherited

Returns the amount of rows in this matrix.

See also
getColCount,getRow

Definition at line 115 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::mRows.

Referenced by mrpt::math::intersect().

Here is the caller graph for this function:

◆ setColumn()

template<class T>
template<typename VECTOR >
void mrpt::math::CSparseMatrixTemplate< T >::setColumn ( size_t  nCol,
const VECTOR &  vec,
const T &  nullObject = T() 
)
inlineinherited

Inserts a full column into the matrix.

The third argument is used to specify a null object (which won't be inserted, since the matrix is sparse).

See also
getColumn
Exceptions
std::logic_erroron out of range or wrong sized vector.

Definition at line 261 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.

◆ setRow()

template<class T>
template<typename VECTOR >
void mrpt::math::CSparseMatrixTemplate< T >::setRow ( size_t  nRow,
const VECTOR &  vec,
const T &  nullObject = T() 
)
inlineinherited

Inserts a full row into the matrix.

The third argument is used to specify a null object (which won't be inserted, since the matrix is sparse).

See also
getRow
Exceptions
std::logic_erroron out of range or wrong sized vector.

Definition at line 236 of file CSparseMatrixTemplate.h.

References mrpt::math::CSparseMatrixTemplate< T >::mColumns, mrpt::math::CSparseMatrixTemplate< T >::mRows, and mrpt::math::CSparseMatrixTemplate< T >::objectList.

Member Data Documentation

◆ mColumns

template<class T>
size_t mrpt::math::CSparseMatrixTemplate< T >::mColumns {0}
protectedinherited

◆ mRows

template<class T>
size_t mrpt::math::CSparseMatrixTemplate< T >::mRows {0}
protectedinherited

◆ objectList

template<class T>
SparseMatrixMap mrpt::math::CSparseMatrixTemplate< T >::objectList
protectedinherited



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020