aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2010-09-06 11:51:42 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2010-09-06 11:51:42 +0200
commit9bb75937cc698b32f2fe6ffac3b4e09a89c3c5f7 (patch)
tree99d99731ff24bf0599b69d869107821cf7cee55c /Eigen/src
parent62eb4dc99bb79a0e2015548c248d6270928533f1 (diff)
fix += return by value like operations
Diffstat (limited to 'Eigen/src')
-rw-r--r--Eigen/src/Core/CwiseBinaryOp.h2
-rw-r--r--Eigen/src/Core/NoAlias.h8
-rw-r--r--Eigen/src/Core/SelfCwiseBinaryOp.h11
3 files changed, 16 insertions, 5 deletions
diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h
index 171140c27..5def0db2a 100644
--- a/Eigen/src/Core/CwiseBinaryOp.h
+++ b/Eigen/src/Core/CwiseBinaryOp.h
@@ -216,7 +216,7 @@ EIGEN_STRONG_INLINE Derived &
MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other)
{
SelfCwiseBinaryOp<ei_scalar_difference_op<Scalar>, Derived, OtherDerived> tmp(derived());
- tmp = other;
+ tmp = other.derived();
return derived();
}
diff --git a/Eigen/src/Core/NoAlias.h b/Eigen/src/Core/NoAlias.h
index 03198879f..53ad3bfee 100644
--- a/Eigen/src/Core/NoAlias.h
+++ b/Eigen/src/Core/NoAlias.h
@@ -59,7 +59,9 @@ class NoAlias
{
typedef SelfCwiseBinaryOp<ei_scalar_sum_op<Scalar>, ExpressionType, OtherDerived> SelfAdder;
SelfAdder tmp(m_expression);
- ei_assign_selector<SelfAdder,OtherDerived,false>::run(tmp,other.derived());
+ typedef typename ei_nested<OtherDerived>::type OtherDerivedNested;
+ typedef typename ei_cleantype<OtherDerivedNested>::type _OtherDerivedNested;
+ ei_assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived()));
return m_expression;
}
@@ -69,7 +71,9 @@ class NoAlias
{
typedef SelfCwiseBinaryOp<ei_scalar_difference_op<Scalar>, ExpressionType, OtherDerived> SelfAdder;
SelfAdder tmp(m_expression);
- ei_assign_selector<SelfAdder,OtherDerived,false>::run(tmp,other.derived());
+ typedef typename ei_nested<OtherDerived>::type OtherDerivedNested;
+ typedef typename ei_cleantype<OtherDerivedNested>::type _OtherDerivedNested;
+ ei_assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived()));
return m_expression;
}
diff --git a/Eigen/src/Core/SelfCwiseBinaryOp.h b/Eigen/src/Core/SelfCwiseBinaryOp.h
index 5100f6b25..f77589747 100644
--- a/Eigen/src/Core/SelfCwiseBinaryOp.h
+++ b/Eigen/src/Core/SelfCwiseBinaryOp.h
@@ -62,8 +62,6 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp
typedef typename ei_packet_traits<Scalar>::type Packet;
- using Base::operator=;
-
inline SelfCwiseBinaryOp(Lhs& xpr, const BinaryOp& func = BinaryOp()) : m_matrix(xpr), m_functor(func) {}
inline Index rows() const { return m_matrix.rows(); }
@@ -142,6 +140,15 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp
#endif
return *this;
}
+
+ // overloaded to honor evaluation of special matrices
+ // maybe another solution would be to not use SelfCwiseBinaryOp
+ // at first...
+ SelfCwiseBinaryOp& operator=(const Rhs& _rhs)
+ {
+ typename ei_nested<Rhs>::type rhs(_rhs);
+ return Base::operator=(rhs);
+ }
protected:
Lhs& m_matrix;