aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/MapBase.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-02-12 15:29:20 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-02-12 15:29:20 +0000
commit59a1ed0932a06fd91d444e563479e42b3df432f3 (patch)
tree38c8add3182685c13b9eaccbf0d2ec8cc27b3b77 /Eigen/src/Core/MapBase.h
parent51c991af459b86aab4a0a9575edba378e20e8621 (diff)
fix bug in MapBase found by myguel
Diffstat (limited to 'Eigen/src/Core/MapBase.h')
-rw-r--r--Eigen/src/Core/MapBase.h8
1 files 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<typename Derived> class MapBase
inline Scalar& coeffRef(int index)
{
- return *const_cast<Scalar*>(m_data + index);
+ ei_assert(Derived::IsVectorAtCompileTime || (ei_traits<Derived>::Flags & LinearAccessBit));
+ if ( ((RowsAtCompileTime == 1) == IsRowMajor) )
+ return const_cast<Scalar*>(m_data)[index];
+ else
+ return const_cast<Scalar*>(m_data)[index*stride()];
}
template<int LoadMode>
@@ -150,7 +154,7 @@ template<typename Derived> class MapBase
|| ( rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
&& cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)));
}
-
+
template<typename OtherDerived>
Derived& operator+=(const MatrixBase<OtherDerived>& other)
{ return derived() = forceAligned() + other; }