diff options
author | Gael Guennebaud <g.gael@free.fr> | 2011-12-04 14:57:43 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2011-12-04 14:57:43 +0100 |
commit | 9bd902ed9cd55198683f4248cd685b05851acaee (patch) | |
tree | 6ab520e249acb74d19d260092ceace3fb0ea61af /Eigen/src/SparseCore | |
parent | 9353bbac4ab4b899b78a1bc49d6b8edc4849171b (diff) |
fix bug #341: trisove on MappedSparseMatrix
Diffstat (limited to 'Eigen/src/SparseCore')
-rw-r--r-- | Eigen/src/SparseCore/MappedSparseMatrix.h | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/Eigen/src/SparseCore/MappedSparseMatrix.h b/Eigen/src/SparseCore/MappedSparseMatrix.h index 87aab8fed..2907e7129 100644 --- a/Eigen/src/SparseCore/MappedSparseMatrix.h +++ b/Eigen/src/SparseCore/MappedSparseMatrix.h @@ -111,6 +111,7 @@ class MappedSparseMatrix } class InnerIterator; + class ReverseInnerIterator; /** \returns the number of non zero coefficients */ inline Index nonZeros() const { return m_nnz; } @@ -136,12 +137,6 @@ class MappedSparseMatrix<Scalar,_Flags,_Index>::InnerIterator m_end(mat.outerIndexPtr()[outer+1]) {} - template<unsigned int Added, unsigned int Removed> - InnerIterator(const Flagged<MappedSparseMatrix,Added,Removed>& mat, Index outer) - : m_matrix(mat._expression()), m_id(m_matrix.outerIndexPtr()[outer]), - m_start(m_id), m_end(m_matrix.outerIndexPtr()[outer+1]) - {} - inline InnerIterator& operator++() { m_id++; return *this; } inline Scalar value() const { return m_matrix.valuePtr()[m_id]; } @@ -161,4 +156,35 @@ class MappedSparseMatrix<Scalar,_Flags,_Index>::InnerIterator const Index m_end; }; +template<typename Scalar, int _Flags, typename _Index> +class MappedSparseMatrix<Scalar,_Flags,_Index>::ReverseInnerIterator +{ + public: + ReverseInnerIterator(const MappedSparseMatrix& mat, Index outer) + : m_matrix(mat), + m_outer(outer), + m_id(mat.outerIndexPtr()[outer+1]), + m_start(mat.outerIndexPtr()[outer]), + m_end(m_id) + {} + + inline ReverseInnerIterator& operator--() { m_id--; return *this; } + + inline Scalar value() const { return m_matrix.valuePtr()[m_id-1]; } + inline Scalar& valueRef() { return const_cast<Scalar&>(m_matrix.valuePtr()[m_id-1]); } + + inline Index index() const { return m_matrix.innerIndexPtr()[m_id-1]; } + inline Index row() const { return IsRowMajor ? m_outer : index(); } + inline Index col() const { return IsRowMajor ? index() : m_outer; } + + inline operator bool() const { return (m_id <= m_end) && (m_id>m_start); } + + protected: + const MappedSparseMatrix& m_matrix; + const Index m_outer; + Index m_id; + const Index m_start; + const Index m_end; +}; + #endif // EIGEN_MAPPED_SPARSEMATRIX_H |