diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-12-12 12:54:45 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-12-12 12:54:45 +0000 |
commit | 1ed17b037db20ebe8eed954d4fa975b9e0ac82f6 (patch) | |
tree | 672b08ede4939d2abbe7172d50145fd8428059e6 /Eigen/src/Core/MapBase.h | |
parent | 5015e483613490ae65433e8eeae00dc176aeedf3 (diff) |
* fix a couple of warnings (patch from Armin Berres)
* allow Map to map null data
Diffstat (limited to 'Eigen/src/Core/MapBase.h')
-rw-r--r-- | Eigen/src/Core/MapBase.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index 5151b7047..ceedb08cb 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -53,7 +53,7 @@ template<typename Derived> class MapBase ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime, SizeAtCompileTime = Base::SizeAtCompileTime }; - + typedef typename ei_traits<Derived>::AlignedDerivedType AlignedDerivedType; typedef typename ei_traits<Derived>::Scalar Scalar; typedef typename Base::PacketScalar PacketScalar; @@ -83,7 +83,7 @@ template<typename Derived> class MapBase else // column-major return const_cast<Scalar*>(m_data)[row + col * stride()]; } - + inline const Scalar coeff(int index) const { ei_assert(Derived::IsVectorAtCompileTime || (ei_traits<Derived>::Flags & LinearAccessBit)); @@ -138,28 +138,29 @@ template<typename Derived> class MapBase m_cols(ColsAtCompileTime == Dynamic ? size : ColsAtCompileTime) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) - ei_assert(size > 0); + ei_assert(size > 0 || data == 0); ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == size); } inline MapBase(const Scalar* data, int rows, int cols) : m_data(data), m_rows(rows), m_cols(cols) { - ei_assert(rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) - && cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); + ei_assert( (data == 0) + || ( 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; } - + template<typename OtherDerived> Derived& operator-=(const MatrixBase<OtherDerived>& other) { return derived() = forceAligned() - other; } Derived& operator*=(const Scalar& other) { return derived() = forceAligned() * other; } - + Derived& operator/=(const Scalar& other) { return derived() = forceAligned() / other; } |