A sparse matrix class designed for matrix assembly purpose.
_Scalar | the scalar type, i.e. the type of the coefficients |
Unlike SparseMatrix, this class provides a much higher degree of flexibility. In particular, it allows random read/write accesses in log(rho*outer_size) where rho
is the probability that a coefficient is nonzero and outer_size is the number of columns if the matrix is column-major and the number of rows otherwise.
Internally, the data are stored as a std::vector of compressed vector. The performances of random writes might decrease as the number of nonzeros per inner-vector increase. In practice, we observed very good performance till about 100 nonzeros/vector, and the performance remains relatively good till 500 nonzeros/vectors.
Definition at line 67 of file DynamicSparseMatrix.h.
#include <src/Sparse/DynamicSparseMatrix.h>
Classes | |
class | InnerIterator |
Public Types | |
enum | { Options = _Options } |
typedef MappedSparseMatrix < Scalar, Flags > | Map |
Public Member Functions | |
Index | rows () const |
Index | cols () const |
Index | innerSize () const |
Index | outerSize () const |
Index | innerNonZeros (Index j) const |
std::vector< CompressedStorage < Scalar, Index > > & | _data () |
const std::vector < CompressedStorage< Scalar, Index > > & | _data () const |
Scalar | coeff (Index row, Index col) const |
Scalar & | coeffRef (Index row, Index col) |
void | setZero () |
Index | nonZeros () const |
void | reserve (Index reserveSize=1000) |
void | startVec (Index) |
Does nothing: provided for compatibility with SparseMatrix. | |
Scalar & | insertBack (Index row, Index col) |
Scalar & | insertBackByOuterInner (Index outer, Index inner) |
Scalar & | insert (Index row, Index col) |
void | finalize () |
Does nothing: provided for compatibility with SparseMatrix. | |
void | prune (Scalar reference, RealScalar epsilon=NumTraits< RealScalar >::dummy_precision()) |
Suppress all nonzeros which are smaller than reference under the tolerence epsilon. | |
void | resize (Index rows, Index cols) |
Resize the matrix without preserving the data (the matrix is set to zero) | |
void | resizeAndKeepData (Index rows, Index cols) |
DynamicSparseMatrix () | |
DynamicSparseMatrix (Index rows, Index cols) | |
template<typename OtherDerived > | |
DynamicSparseMatrix (const SparseMatrixBase< OtherDerived > &other) | |
DynamicSparseMatrix (const DynamicSparseMatrix &other) | |
void | swap (DynamicSparseMatrix &other) |
DynamicSparseMatrix & | operator= (const DynamicSparseMatrix &other) |
template<typename OtherDerived > | |
DynamicSparseMatrix & | operator= (const SparseMatrixBase< OtherDerived > &other) |
template<typename OtherDerived > | |
EIGEN_STRONG_INLINE DynamicSparseMatrix & | operator= (const ReturnByValue< OtherDerived > &func) |
~DynamicSparseMatrix () | |
Destructor. | |
EIGEN_DEPRECATED void | startFill (Index reserveSize=1000) |
EIGEN_DEPRECATED Scalar & | fill (Index row, Index col) |
EIGEN_DEPRECATED Scalar & | fillrand (Index row, Index col) |
EIGEN_DEPRECATED void | endFill () |
Protected Types | |
typedef DynamicSparseMatrix < Scalar,(Flags &~RowMajorBit)|(IsRowMajor?RowMajorBit:0)> | TransposedSparseMatrix |
Protected Attributes | |
Index | m_innerSize |
std::vector< CompressedStorage < Scalar, Index > > | m_data |
typedef MappedSparseMatrix<Scalar,Flags> DynamicSparseMatrix< _Scalar, _Options, _Index >::Map |
Definition at line 75 of file DynamicSparseMatrix.h.
typedef DynamicSparseMatrix<Scalar,(Flags&~RowMajorBit)|(IsRowMajor?RowMajorBit:0)> DynamicSparseMatrix< _Scalar, _Options, _Index >::TransposedSparseMatrix [protected] |
Definition at line 84 of file DynamicSparseMatrix.h.
anonymous enum |
Definition at line 78 of file DynamicSparseMatrix.h.
DynamicSparseMatrix< _Scalar, _Options, _Index >::DynamicSparseMatrix | ( | ) | [inline] |
Definition at line 235 of file DynamicSparseMatrix.h.
References eigen_assert, DynamicSparseMatrix< _Scalar, _Options, _Index >::innerSize(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::outerSize().
DynamicSparseMatrix< _Scalar, _Options, _Index >::DynamicSparseMatrix | ( | Index | rows, |
Index | cols | ||
) | [inline] |
Definition at line 241 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::resize().
DynamicSparseMatrix< _Scalar, _Options, _Index >::DynamicSparseMatrix | ( | const SparseMatrixBase< OtherDerived > & | other | ) | [inline] |
Definition at line 248 of file DynamicSparseMatrix.h.
References EigenBase< Derived >::derived().
DynamicSparseMatrix< _Scalar, _Options, _Index >::DynamicSparseMatrix | ( | const DynamicSparseMatrix< _Scalar, _Options, _Index > & | other | ) | [inline] |
Definition at line 254 of file DynamicSparseMatrix.h.
References EigenBase< Derived >::derived().
DynamicSparseMatrix< _Scalar, _Options, _Index >::~DynamicSparseMatrix | ( | ) | [inline] |
Destructor.
Definition at line 295 of file DynamicSparseMatrix.h.
std::vector<CompressedStorage<Scalar,Index> >& DynamicSparseMatrix< _Scalar, _Options, _Index >::_data | ( | ) | [inline] |
Definition at line 97 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data.
const std::vector<CompressedStorage<Scalar,Index> >& DynamicSparseMatrix< _Scalar, _Options, _Index >::_data | ( | ) | const [inline] |
Definition at line 98 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data.
Scalar DynamicSparseMatrix< _Scalar, _Options, _Index >::coeff | ( | Index | row, |
Index | col | ||
) | const [inline] |
Definition at line 103 of file DynamicSparseMatrix.h.
References SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::col(), SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::IsRowMajor, DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, and SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::row().
Scalar& DynamicSparseMatrix< _Scalar, _Options, _Index >::coeffRef | ( | Index | row, |
Index | col | ||
) | [inline] |
Definition at line 114 of file DynamicSparseMatrix.h.
References SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::col(), SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::IsRowMajor, DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, and SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::row().
Index DynamicSparseMatrix< _Scalar, _Options, _Index >::cols | ( | void | ) | const [inline] |
Reimplemented from SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >.
Definition at line 92 of file DynamicSparseMatrix.h.
References SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::IsRowMajor, DynamicSparseMatrix< _Scalar, _Options, _Index >::m_innerSize, and DynamicSparseMatrix< _Scalar, _Options, _Index >::outerSize().
Referenced by SparseSelfAdjointView< MatrixType, UpLo >::evalTo(), DynamicSparseMatrix< _Scalar, _Options, _Index >::operator=(), DynamicSparseMatrix< _Scalar, _Options, _Index >::resize(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::resizeAndKeepData().
EIGEN_DEPRECATED void DynamicSparseMatrix< _Scalar, _Options, _Index >::endFill | ( | ) | [inline] |
Provided for compatibility with SparseMatrix.
Definition at line 335 of file DynamicSparseMatrix.h.
EIGEN_DEPRECATED Scalar& DynamicSparseMatrix< _Scalar, _Options, _Index >::fill | ( | Index | row, |
Index | col | ||
) | [inline] |
In other words, assuming *this
is column-major, then there must not exists any nonzero coefficient of coordinates i
x
col such that i
>= row. Otherwise the matrix is invalid.
Definition at line 316 of file DynamicSparseMatrix.h.
References SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::col(), DynamicSparseMatrix< _Scalar, _Options, _Index >::insertBack(), SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::IsRowMajor, and SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::row().
EIGEN_DEPRECATED Scalar& DynamicSparseMatrix< _Scalar, _Options, _Index >::fillrand | ( | Index | row, |
Index | col | ||
) | [inline] |
Compared to the generic coeffRef(), the unique limitation is that we assume the coefficient does not exist yet.
Definition at line 328 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::insert().
void DynamicSparseMatrix< _Scalar, _Options, _Index >::finalize | ( | ) | [inline] |
Does nothing: provided for compatibility with SparseMatrix.
Definition at line 196 of file DynamicSparseMatrix.h.
Index DynamicSparseMatrix< _Scalar, _Options, _Index >::innerNonZeros | ( | Index | j | ) | const [inline] |
Definition at line 95 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data.
Index DynamicSparseMatrix< _Scalar, _Options, _Index >::innerSize | ( | ) | const [inline] |
Reimplemented from SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >.
Definition at line 93 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::m_innerSize.
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::DynamicSparseMatrix(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::resizeAndKeepData().
Scalar& DynamicSparseMatrix< _Scalar, _Options, _Index >::insert | ( | Index | row, |
Index | col | ||
) | [inline] |
Definition at line 175 of file DynamicSparseMatrix.h.
References SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::col(), SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::IsRowMajor, DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, and SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::row().
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::fillrand().
Scalar& DynamicSparseMatrix< _Scalar, _Options, _Index >::insertBack | ( | Index | row, |
Index | col | ||
) | [inline] |
Definition at line 160 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::insertBackByOuterInner(), and SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::IsRowMajor.
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::fill().
Scalar& DynamicSparseMatrix< _Scalar, _Options, _Index >::insertBackByOuterInner | ( | Index | outer, |
Index | inner | ||
) | [inline] |
Definition at line 166 of file DynamicSparseMatrix.h.
References eigen_assert, DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, DynamicSparseMatrix< _Scalar, _Options, _Index >::m_innerSize, and SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::size().
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::insertBack().
Index DynamicSparseMatrix< _Scalar, _Options, _Index >::nonZeros | ( | ) | const [inline] |
Reimplemented from SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >.
Definition at line 130 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, DynamicSparseMatrix< _Scalar, _Options, _Index >::outerSize(), and SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::size().
DynamicSparseMatrix& DynamicSparseMatrix< _Scalar, _Options, _Index >::operator= | ( | const DynamicSparseMatrix< _Scalar, _Options, _Index > & | other | ) | [inline] |
Reimplemented from SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >.
Definition at line 268 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::cols(), EigenBase< Derived >::const_cast_derived(), SparseMatrixBase< Derived >::isRValue(), DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, DynamicSparseMatrix< _Scalar, _Options, _Index >::resize(), DynamicSparseMatrix< _Scalar, _Options, _Index >::rows(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::swap().
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::operator=().
DynamicSparseMatrix& DynamicSparseMatrix< _Scalar, _Options, _Index >::operator= | ( | const SparseMatrixBase< OtherDerived > & | other | ) | [inline] |
Reimplemented from SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >.
Definition at line 283 of file DynamicSparseMatrix.h.
References EigenBase< Derived >::derived(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::operator=().
EIGEN_STRONG_INLINE DynamicSparseMatrix& DynamicSparseMatrix< _Scalar, _Options, _Index >::operator= | ( | const ReturnByValue< OtherDerived > & | func | ) | [inline] |
Reimplemented from SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >.
Definition at line 289 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::operator=().
Index DynamicSparseMatrix< _Scalar, _Options, _Index >::outerSize | ( | ) | const [inline] |
Reimplemented from SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >.
Definition at line 94 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data.
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::cols(), DynamicSparseMatrix< _Scalar, _Options, _Index >::DynamicSparseMatrix(), DynamicSparseMatrix< _Scalar, _Options, _Index >::nonZeros(), DynamicSparseMatrix< _Scalar, _Options, _Index >::prune(), DynamicSparseMatrix< _Scalar, _Options, _Index >::reserve(), DynamicSparseMatrix< _Scalar, _Options, _Index >::resize(), DynamicSparseMatrix< _Scalar, _Options, _Index >::resizeAndKeepData(), DynamicSparseMatrix< _Scalar, _Options, _Index >::rows(), DynamicSparseMatrix< _Scalar, _Options, _Index >::setZero(), and SparseInnerVectorSet< DynamicSparseMatrix< _Scalar, _Options >, Size >::SparseInnerVectorSet().
void DynamicSparseMatrix< _Scalar, _Options, _Index >::prune | ( | Scalar | reference, |
RealScalar | epsilon = NumTraits<RealScalar>::dummy_precision() |
||
) | [inline] |
Suppress all nonzeros which are smaller than reference under the tolerence epsilon.
Definition at line 199 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, and DynamicSparseMatrix< _Scalar, _Options, _Index >::outerSize().
void DynamicSparseMatrix< _Scalar, _Options, _Index >::reserve | ( | Index | reserveSize = 1000 | ) | [inline] |
Definition at line 140 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, and DynamicSparseMatrix< _Scalar, _Options, _Index >::outerSize().
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::startFill().
void DynamicSparseMatrix< _Scalar, _Options, _Index >::resize | ( | Index | rows, |
Index | cols | ||
) | [inline] |
Resize the matrix without preserving the data (the matrix is set to zero)
Definition at line 207 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::cols(), SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::IsRowMajor, DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, DynamicSparseMatrix< _Scalar, _Options, _Index >::m_innerSize, DynamicSparseMatrix< _Scalar, _Options, _Index >::outerSize(), DynamicSparseMatrix< _Scalar, _Options, _Index >::rows(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::setZero().
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::DynamicSparseMatrix(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::operator=().
void DynamicSparseMatrix< _Scalar, _Options, _Index >::resizeAndKeepData | ( | Index | rows, |
Index | cols | ||
) | [inline] |
Definition at line 218 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::cols(), DynamicSparseMatrix< _Scalar, _Options, _Index >::innerSize(), SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::IsRowMajor, DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, DynamicSparseMatrix< _Scalar, _Options, _Index >::m_innerSize, DynamicSparseMatrix< _Scalar, _Options, _Index >::outerSize(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::rows().
Index DynamicSparseMatrix< _Scalar, _Options, _Index >::rows | ( | void | ) | const [inline] |
Reimplemented from SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >.
Definition at line 91 of file DynamicSparseMatrix.h.
References SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Options, _Index > >::IsRowMajor, DynamicSparseMatrix< _Scalar, _Options, _Index >::m_innerSize, and DynamicSparseMatrix< _Scalar, _Options, _Index >::outerSize().
Referenced by SparseSelfAdjointView< MatrixType, UpLo >::evalTo(), DynamicSparseMatrix< _Scalar, _Options, _Index >::operator=(), DynamicSparseMatrix< _Scalar, _Options, _Index >::resize(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::resizeAndKeepData().
void DynamicSparseMatrix< _Scalar, _Options, _Index >::setZero | ( | ) | [inline] |
Definition at line 123 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, and DynamicSparseMatrix< _Scalar, _Options, _Index >::outerSize().
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::resize(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::startFill().
EIGEN_DEPRECATED void DynamicSparseMatrix< _Scalar, _Options, _Index >::startFill | ( | Index | reserveSize = 1000 | ) | [inline] |
Definition at line 301 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::reserve(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::setZero().
void DynamicSparseMatrix< _Scalar, _Options, _Index >::startVec | ( | Index | ) | [inline] |
Does nothing: provided for compatibility with SparseMatrix.
Definition at line 153 of file DynamicSparseMatrix.h.
void DynamicSparseMatrix< _Scalar, _Options, _Index >::swap | ( | DynamicSparseMatrix< _Scalar, _Options, _Index > & | other | ) | [inline] |
Definition at line 260 of file DynamicSparseMatrix.h.
References DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data, and DynamicSparseMatrix< _Scalar, _Options, _Index >::m_innerSize.
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::operator=().
std::vector<CompressedStorage<Scalar,Index> > DynamicSparseMatrix< _Scalar, _Options, _Index >::m_data [protected] |
Definition at line 87 of file DynamicSparseMatrix.h.
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::_data(), DynamicSparseMatrix< _Scalar, _Options, _Index >::coeff(), DynamicSparseMatrix< _Scalar, _Options, _Index >::coeffRef(), DynamicSparseMatrix< _Scalar, _Options, _Index >::innerNonZeros(), DynamicSparseMatrix< _Scalar, _Options, _Index >::insert(), DynamicSparseMatrix< _Scalar, _Options, _Index >::insertBackByOuterInner(), DynamicSparseMatrix< _Scalar, _Options, _Index >::nonZeros(), DynamicSparseMatrix< _Scalar, _Options, _Index >::operator=(), DynamicSparseMatrix< _Scalar, _Options, _Index >::outerSize(), DynamicSparseMatrix< _Scalar, _Options, _Index >::prune(), DynamicSparseMatrix< _Scalar, _Options, _Index >::reserve(), DynamicSparseMatrix< _Scalar, _Options, _Index >::resize(), DynamicSparseMatrix< _Scalar, _Options, _Index >::resizeAndKeepData(), DynamicSparseMatrix< _Scalar, _Options, _Index >::setZero(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::swap().
Index DynamicSparseMatrix< _Scalar, _Options, _Index >::m_innerSize [protected] |
Definition at line 86 of file DynamicSparseMatrix.h.
Referenced by DynamicSparseMatrix< _Scalar, _Options, _Index >::cols(), DynamicSparseMatrix< _Scalar, _Options, _Index >::innerSize(), DynamicSparseMatrix< _Scalar, _Options, _Index >::insertBackByOuterInner(), DynamicSparseMatrix< _Scalar, _Options, _Index >::resize(), DynamicSparseMatrix< _Scalar, _Options, _Index >::resizeAndKeepData(), DynamicSparseMatrix< _Scalar, _Options, _Index >::rows(), and DynamicSparseMatrix< _Scalar, _Options, _Index >::swap().
Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:40:17 UTC 2011 |