From 59a1ed0932a06fd91d444e563479e42b3df432f3 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 12 Feb 2009 15:29:20 +0000 Subject: [PATCH] fix bug in MapBase found by myguel --- 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; }