From 95e4508b043bae7c4cd0200dbd868a61b4cd0191 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 12 Feb 2009 15:32:32 +0000 Subject: [PATCH] backporting rev925153 (bugfix in MapBase::coeffRef(int) ) --- Eigen/src/Core/MapBase.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index e616cdcc8..7014f27f6 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -96,7 +96,11 @@ template class MapBase inline Scalar& coeffRef(int index) { - return *const_cast(m_data + index); + ei_assert(Derived::IsVectorAtCompileTime || (ei_traits::Flags & LinearAccessBit)); + if ( ((RowsAtCompileTime == 1) == IsRowMajor) ) + return const_cast(m_data)[index]; + else + return const_cast(m_data)[index*stride()]; } template @@ -150,7 +154,7 @@ template class MapBase || ( rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols))); } - + template Derived& operator+=(const MatrixBase& other) { return derived() = forceAligned() + other; }