From 2d1ae6fa0868f79c588ce6c64b30e3b268ddf641 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 16 Jun 2010 09:21:14 -0400 Subject: fix #126, part 1/2: fix the return type of coeff() on direcaccess xprs: was amounting to const (const Scalar&) which really doesn't make sense. --- Eigen/src/Core/DenseCoeffsBase.h | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'Eigen') diff --git a/Eigen/src/Core/DenseCoeffsBase.h b/Eigen/src/Core/DenseCoeffsBase.h index c55576c02..7d57d5abc 100644 --- a/Eigen/src/Core/DenseCoeffsBase.h +++ b/Eigen/src/Core/DenseCoeffsBase.h @@ -33,7 +33,8 @@ class DenseCoeffsBase : public EigenBase typedef typename ei_traits::Index Index; typedef typename ei_traits::Scalar Scalar; typedef typename ei_packet_traits::type PacketScalar; - typedef typename ei_meta_if::ret, const Scalar&, Scalar>::ret CoeffReturnType; + typedef typename ei_meta_if::ret, const Scalar&, const Scalar>::ret CoeffReturnType; + typedef typename ei_makeconst::type>::type PacketReturnType; typedef EigenBase Base; using Base::rows; @@ -71,14 +72,14 @@ class DenseCoeffsBase : public EigenBase * * \sa operator()(Index,Index) const, coeffRef(Index,Index), coeff(Index) const */ - EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index row, Index col) const + EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { ei_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); return derived().coeff(row, col); } - EIGEN_STRONG_INLINE const CoeffReturnType coeffByOuterInner(Index outer, Index inner) const + EIGEN_STRONG_INLINE CoeffReturnType coeffByOuterInner(Index outer, Index inner) const { return coeff(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner)); @@ -88,7 +89,7 @@ class DenseCoeffsBase : public EigenBase * * \sa operator()(Index,Index), operator[](Index) */ - EIGEN_STRONG_INLINE const CoeffReturnType operator()(Index row, Index col) const + EIGEN_STRONG_INLINE CoeffReturnType operator()(Index row, Index col) const { ei_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); @@ -110,7 +111,7 @@ class DenseCoeffsBase : public EigenBase * \sa operator[](Index) const, coeffRef(Index), coeff(Index,Index) const */ - EIGEN_STRONG_INLINE const CoeffReturnType + EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { ei_internal_assert(index >= 0 && index < size()); @@ -126,7 +127,7 @@ class DenseCoeffsBase : public EigenBase * z() const, w() const */ - EIGEN_STRONG_INLINE const CoeffReturnType + EIGEN_STRONG_INLINE CoeffReturnType operator[](Index index) const { EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime, @@ -145,7 +146,7 @@ class DenseCoeffsBase : public EigenBase * z() const, w() const */ - EIGEN_STRONG_INLINE const CoeffReturnType + EIGEN_STRONG_INLINE CoeffReturnType operator()(Index index) const { ei_assert(index >= 0 && index < size()); @@ -154,22 +155,22 @@ class DenseCoeffsBase : public EigenBase /** equivalent to operator[](0). */ - EIGEN_STRONG_INLINE const CoeffReturnType + EIGEN_STRONG_INLINE CoeffReturnType x() const { return (*this)[0]; } /** equivalent to operator[](1). */ - EIGEN_STRONG_INLINE const CoeffReturnType + EIGEN_STRONG_INLINE CoeffReturnType y() const { return (*this)[1]; } /** equivalent to operator[](2). */ - EIGEN_STRONG_INLINE const CoeffReturnType + EIGEN_STRONG_INLINE CoeffReturnType z() const { return (*this)[2]; } /** equivalent to operator[](3). */ - EIGEN_STRONG_INLINE const CoeffReturnType + EIGEN_STRONG_INLINE CoeffReturnType w() const { return (*this)[3]; } /** \returns the packet of coefficients starting at the given row and column. It is your responsibility @@ -182,8 +183,7 @@ class DenseCoeffsBase : public EigenBase */ template - EIGEN_STRONG_INLINE typename ei_packet_traits::type - packet(Index row, Index col) const + EIGEN_STRONG_INLINE PacketReturnType packet(Index row, Index col) const { ei_internal_assert(row >= 0 && row < rows() && col >= 0 && col < cols()); @@ -192,8 +192,7 @@ class DenseCoeffsBase : public EigenBase template - EIGEN_STRONG_INLINE typename ei_packet_traits::type - packetByOuterInner(Index outer, Index inner) const + EIGEN_STRONG_INLINE PacketReturnType packetByOuterInner(Index outer, Index inner) const { return packet(rowIndexByOuterInner(outer, inner), colIndexByOuterInner(outer, inner)); @@ -209,8 +208,7 @@ class DenseCoeffsBase : public EigenBase */ template - EIGEN_STRONG_INLINE typename ei_packet_traits::type - packet(Index index) const + EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const { ei_internal_assert(index >= 0 && index < size()); return derived().template packet(index); @@ -249,7 +247,6 @@ class DenseCoeffsBase : public DenseCoeffsBase typedef typename ei_traits::Scalar Scalar; typedef typename ei_packet_traits::type PacketScalar; typedef typename NumTraits::Real RealScalar; - typedef typename Base::CoeffReturnType CoeffReturnType; using Base::coeff; using Base::rows; -- cgit v1.2.3