fix resizing in noalias for blocks, and make -=/+= use evaluators

This commit is contained in:
Gael Guennebaud 2013-12-13 18:06:58 +01:00
parent 2ca0ccd2f2
commit e94fe4cc3e
2 changed files with 9 additions and 1 deletions

View File

@ -213,8 +213,12 @@ template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived & EIGEN_STRONG_INLINE Derived &
MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other) MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other)
{ {
#ifdef EIGEN_TEST_EVALUATORS
call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar>());
#else
SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, Derived, OtherDerived> tmp(derived()); SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, Derived, OtherDerived> tmp(derived());
tmp = other.derived(); tmp = other.derived();
#endif
return derived(); return derived();
} }
@ -227,8 +231,12 @@ template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived & EIGEN_STRONG_INLINE Derived &
MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other) MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
{ {
#ifdef EIGEN_TEST_EVALUATORS
call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar>());
#else
SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, Derived, OtherDerived> tmp(derived()); SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, Derived, OtherDerived> tmp(derived());
tmp = other.derived(); tmp = other.derived();
#endif
return derived(); return derived();
} }

View File

@ -41,7 +41,7 @@ class NoAlias
EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other) EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other)
{ {
// TODO either call resize here or call "call_assignment" through m_expression.lazyAssign() ?? // TODO either call resize here or call "call_assignment" through m_expression.lazyAssign() ??
m_expression.resizeLike(other.derived()); m_expression.resize(other.derived().rows(), other.derived().cols());
call_assignment(*this, other.derived(), internal::assign_op<Scalar>()); call_assignment(*this, other.derived(), internal::assign_op<Scalar>());
return m_expression; return m_expression;
} }