From 4bb2446796dcefba4746dc511ba74d68c00be668 Mon Sep 17 00:00:00 2001 From: Charles Schlosser Date: Fri, 16 Dec 2022 16:48:50 +0000 Subject: [PATCH] Add operators to CompressedStorageIterator --- Eigen/src/SparseCore/SparseCompressedBase.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Eigen/src/SparseCore/SparseCompressedBase.h b/Eigen/src/SparseCore/SparseCompressedBase.h index e034ee07b..243cd1643 100644 --- a/Eigen/src/SparseCore/SparseCompressedBase.h +++ b/Eigen/src/SparseCore/SparseCompressedBase.h @@ -411,16 +411,18 @@ public: return *this; } - inline bool operator==(const CompressedStorageIterator& other) const { return m_index == other.m_index; } - inline bool operator!=(const CompressedStorageIterator& other) const { return m_index != other.m_index; } - inline bool operator< (const CompressedStorageIterator& other) const { return m_index < other.m_index; } inline CompressedStorageIterator operator+(difference_type offset) const { return CompressedStorageIterator(m_index + offset, m_data); } inline CompressedStorageIterator operator-(difference_type offset) const { return CompressedStorageIterator(m_index - offset, m_data); } inline difference_type operator-(const CompressedStorageIterator& other) const { return m_index - other.m_index; } inline CompressedStorageIterator& operator++() { ++m_index; return *this; } inline CompressedStorageIterator& operator--() { --m_index; return *this; } + inline CompressedStorageIterator& operator+=(difference_type offset) { m_index += offset; return *this; } + inline CompressedStorageIterator& operator-=(difference_type offset) { m_index -= offset; return *this; } inline reference operator*() const { return reference(m_data.m_innerIndexIterator + m_index, m_data.m_valueIterator + m_index); } + #define MAKE_COMP(OP) inline bool operator OP(const CompressedStorageIterator& other) const { return m_index OP other.m_index; } + MAKE_COMP(<) MAKE_COMP(>) MAKE_COMP(>=) MAKE_COMP(<=) MAKE_COMP(!=) MAKE_COMP(==) + protected: difference_type m_index; reference m_data;