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; }