From a835dfca73a3fd00bf5ad4108f7c633f67414384 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 3 Sep 2015 14:53:51 +0200 Subject: [PATCH] InnerIterator::index() should really return a StorageIndex --- Eigen/src/SparseCore/SparseCwiseBinaryOp.h | 15 ++++++++++----- Eigen/src/SparseCore/SparseDiagonalProduct.h | 3 ++- Eigen/src/SparseCore/SparseTriangularView.h | 7 ++++--- Eigen/src/SparseCore/SparseVector.h | 4 ++-- Eigen/src/SparseCore/SparseView.h | 3 ++- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h index ae2995ced..1137424da 100644 --- a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +++ b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h @@ -74,6 +74,7 @@ public: class InnerIterator { typedef typename traits::Scalar Scalar; + typedef typename XprType::StorageIndex StorageIndex; public: @@ -114,7 +115,7 @@ public: EIGEN_STRONG_INLINE Scalar value() const { return m_value; } - EIGEN_STRONG_INLINE Index index() const { return m_id; } + EIGEN_STRONG_INLINE StorageIndex index() const { return m_id; } EIGEN_STRONG_INLINE Index row() const { return Lhs::IsRowMajor ? m_lhsIter.row() : index(); } EIGEN_STRONG_INLINE Index col() const { return Lhs::IsRowMajor ? index() : m_lhsIter.col(); } @@ -125,7 +126,7 @@ public: RhsIterator m_rhsIter; const BinaryOp& m_functor; Scalar m_value; - Index m_id; + StorageIndex m_id; }; @@ -166,6 +167,7 @@ public: class InnerIterator { typedef typename traits::Scalar Scalar; + typedef typename XprType::StorageIndex StorageIndex; public: @@ -197,7 +199,7 @@ public: EIGEN_STRONG_INLINE Scalar value() const { return m_functor(m_lhsIter.value(), m_rhsIter.value()); } - EIGEN_STRONG_INLINE Index index() const { return m_lhsIter.index(); } + EIGEN_STRONG_INLINE StorageIndex index() const { return m_lhsIter.index(); } EIGEN_STRONG_INLINE Index row() const { return m_lhsIter.row(); } EIGEN_STRONG_INLINE Index col() const { return m_lhsIter.col(); } @@ -247,6 +249,8 @@ public: class InnerIterator { typedef typename traits::Scalar Scalar; + typedef typename XprType::StorageIndex StorageIndex; + enum { IsRowMajor = (int(Rhs::Flags)&RowMajorBit)==RowMajorBit }; public: @@ -264,7 +268,7 @@ public: EIGEN_STRONG_INLINE Scalar value() const { return m_functor(m_lhsEval.coeff(IsRowMajor?m_outer:m_rhsIter.index(),IsRowMajor?m_rhsIter.index():m_outer), m_rhsIter.value()); } - EIGEN_STRONG_INLINE Index index() const { return m_rhsIter.index(); } + EIGEN_STRONG_INLINE StorageIndex index() const { return m_rhsIter.index(); } EIGEN_STRONG_INLINE Index row() const { return m_rhsIter.row(); } EIGEN_STRONG_INLINE Index col() const { return m_rhsIter.col(); } @@ -315,6 +319,7 @@ public: class InnerIterator { typedef typename traits::Scalar Scalar; + typedef typename XprType::StorageIndex StorageIndex; enum { IsRowMajor = (int(Lhs::Flags)&RowMajorBit)==RowMajorBit }; public: @@ -333,7 +338,7 @@ public: { return m_functor(m_lhsIter.value(), m_rhsEval.coeff(IsRowMajor?m_outer:m_lhsIter.index(),IsRowMajor?m_lhsIter.index():m_outer)); } - EIGEN_STRONG_INLINE Index index() const { return m_lhsIter.index(); } + EIGEN_STRONG_INLINE StorageIndex index() const { return m_lhsIter.index(); } EIGEN_STRONG_INLINE Index row() const { return m_lhsIter.row(); } EIGEN_STRONG_INLINE Index col() const { return m_lhsIter.col(); } diff --git a/Eigen/src/SparseCore/SparseDiagonalProduct.h b/Eigen/src/SparseCore/SparseDiagonalProduct.h index b3b80e35a..42e29cf70 100644 --- a/Eigen/src/SparseCore/SparseDiagonalProduct.h +++ b/Eigen/src/SparseCore/SparseDiagonalProduct.h @@ -91,6 +91,7 @@ template struct sparse_diagonal_product_evaluator { typedef typename SparseXprType::Scalar Scalar; + typedef typename SparseXprType::StorageIndex StorageIndex; typedef typename nested_eval::type DiagCoeffNested; @@ -104,7 +105,7 @@ struct sparse_diagonal_product_evaluator::InnerIterator : public MatrixT inline Index row() const { return (MatrixType::Flags&RowMajorBit ? Base::outer() : this->index()); } inline Index col() const { return (MatrixType::Flags&RowMajorBit ? this->index() : Base::outer()); } - inline Index index() const + inline StorageIndex index() const { if(HasUnitDiag && m_returnOne) return Base::outer(); else return Base::index(); @@ -175,6 +175,7 @@ struct unary_evaluator, IteratorBased> protected: typedef typename XprType::Scalar Scalar; + typedef typename XprType::StorageIndex StorageIndex; typedef typename evaluator::InnerIterator EvalIterator; enum { SkipFirst = ((Mode&Lower) && !(ArgType::Flags&RowMajorBit)) @@ -251,9 +252,9 @@ public: // inline Index row() const { return (ArgType::Flags&RowMajorBit ? Base::outer() : this->index()); } // inline Index col() const { return (ArgType::Flags&RowMajorBit ? this->index() : Base::outer()); } - inline Index index() const + inline StorageIndex index() const { - if(HasUnitDiag && m_returnOne) return Base::outer(); + if(HasUnitDiag && m_returnOne) return internal::convert_index(Base::outer()); else return Base::index(); } inline Scalar value() const diff --git a/Eigen/src/SparseCore/SparseVector.h b/Eigen/src/SparseCore/SparseVector.h index 68d3fe4fa..ccf9364f2 100644 --- a/Eigen/src/SparseCore/SparseVector.h +++ b/Eigen/src/SparseCore/SparseVector.h @@ -377,7 +377,7 @@ class SparseVector::InnerIterator inline Scalar value() const { return m_data.value(m_id); } inline Scalar& valueRef() { return const_cast(m_data.value(m_id)); } - inline Index index() const { return m_data.index(m_id); } + inline StorageIndex index() const { return m_data.index(m_id); } inline Index row() const { return IsColVector ? index() : 0; } inline Index col() const { return IsColVector ? 0 : index(); } @@ -414,7 +414,7 @@ class SparseVector::ReverseInnerIterator inline Scalar value() const { return m_data.value(m_id-1); } inline Scalar& valueRef() { return const_cast(m_data.value(m_id-1)); } - inline Index index() const { return m_data.index(m_id-1); } + inline StorageIndex index() const { return m_data.index(m_id-1); } inline Index row() const { return IsColVector ? index() : 0; } inline Index col() const { return IsColVector ? 0 : index(); } diff --git a/Eigen/src/SparseCore/SparseView.h b/Eigen/src/SparseCore/SparseView.h index dc054fbd1..761e72038 100644 --- a/Eigen/src/SparseCore/SparseView.h +++ b/Eigen/src/SparseCore/SparseView.h @@ -127,6 +127,7 @@ struct unary_evaluator, IndexBased> protected: enum { IsRowMajor = (XprType::Flags&RowMajorBit)==RowMajorBit }; typedef typename XprType::Scalar Scalar; + typedef typename XprType::StorageIndex StorageIndex; public: class InnerIterator @@ -152,7 +153,7 @@ struct unary_evaluator, IndexBased> : m_sve.m_argImpl.coeff(m_inner, m_outer); } - EIGEN_STRONG_INLINE Index index() const { return m_inner; } + EIGEN_STRONG_INLINE StorageIndex index() const { return m_inner; } inline Index row() const { return IsRowMajor ? m_outer : index(); } inline Index col() const { return IsRowMajor ? index() : m_outer; }