template class mrpt::math::CSparseSymmetricalMatrix

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:


#include <mrpt/math/CSparseMatrixTemplate.h>

template <class T>
class CSparseSymmetricalMatrix: public mrpt::math::CSparseMatrixTemplate
    // construction

    CSparseSymmetricalMatrix(const CSparseSymmetricalMatrix& o);
    CSparseSymmetricalMatrix(const CSparseMatrixTemplate<T>& o);


    void resize(size_t matrixSize);

    T operator () (
        size_t r,
        size_t c
        ) const;

    T& operator () (
        size_t r,
        size_t c

Inherited Members

    // typedefs

    typedef typename std::map<std::pair<size_t, size_t>, T> SparseMatrixMap;
    typedef typename SparseMatrixMap::const_iterator const_iterator;
    typedef typename SparseMatrixMap::const_reverse_iterator const_reverse_iterator;


    T operator () (size_t r, size_t c) const;
    bool exists(size_t r, size_t c) const;
    T& operator () (size_t r, size_t c);
    size_t rows() const;
    size_t cols() const;

    template <typename VECTOR>
    void getRow(size_t nRow, VECTOR& vec) const;

    template <typename VECTOR>
    void getColumn(size_t nCol, VECTOR& vec) const;

    void insert(size_t row, size_t column, const T& obj);

    template <class MATRIX_LIKE>
    void insertMatrix(
        size_t row,
        size_t column,
        const MATRIX_LIKE& mat

    const_iterator begin() const;
    const_iterator end() const;
    const_reverse_iterator rbegin() const;
    const_reverse_iterator rend() const;

    template <typename VECTOR>
    void setRow(
        size_t nRow,
        const VECTOR& vec,
        const T& nullObject = T()

    template <typename VECTOR>
    void setColumn(
        size_t nCol,
        const VECTOR& vec,
        const T& nullObject = T()

    void resize(size_t nRows, size_t nCols);
    CSparseMatrixTemplate<T> operator () (size_t firstRow, size_t lastRow, size_t firstColumn, size_t lastColumn) const;

    template <typename VECTOR>
    void asVector(VECTOR& vec) const;

    size_t getNonNullElements() const;
    bool empty() const;
    size_t getNullElements() const;
    bool isNull(size_t nRow, size_t nCol) const;
    bool isNotNull(size_t nRow, size_t nCol) const;
    void clear();
    void purge(T nullObject = T());