diff --git a/Eigen/src/Core/SelfCwiseBinaryOp.h b/Eigen/src/Core/SelfCwiseBinaryOp.h index 4a85e1140..7ec2a90e9 100644 --- a/Eigen/src/Core/SelfCwiseBinaryOp.h +++ b/Eigen/src/Core/SelfCwiseBinaryOp.h @@ -39,7 +39,10 @@ * \sa class SwapWrapper for a similar trick. */ template -struct ei_traits > : ei_traits {}; +struct ei_traits > : ei_traits +{ + +}; template class SelfCwiseBinaryOp : public ei_dense_xpr_base< SelfCwiseBinaryOp >::type @@ -113,6 +116,29 @@ template class SelfCwiseBinaryOp m_functor.packetOp(m_matrix.template packet(index),_other.template packet(index)) ); } + // reimplement lazyAssign to handle complex *= real + // see CwiseBinaryOp ctor for details + template + EIGEN_STRONG_INLINE SelfCwiseBinaryOp& lazyAssign(const DenseBase& rhs) + { + EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(MatrixType,RhsDerived) + + EIGEN_STATIC_ASSERT((ei_functor_allows_mixing_real_and_complex::ret + ? int(ei_is_same_type::ret) + : int(ei_is_same_type::ret)), + YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) + + #ifdef EIGEN_DEBUG_ASSIGN + ei_assign_traits::debug(); + #endif + ei_assert(rows() == rhs.rows() && cols() == rhs.cols()); + ei_assign_impl::run(*this,rhs.derived()); + #ifndef EIGEN_NO_DEBUG + checkTransposeAliasing(rhs.derived()); + #endif + return *this; + } + protected: MatrixType& m_matrix; const BinaryOp& m_functor; diff --git a/test/mixingtypes.cpp b/test/mixingtypes.cpp index c6cf00d28..0465f3059 100644 --- a/test/mixingtypes.cpp +++ b/test/mixingtypes.cpp @@ -97,6 +97,13 @@ template void mixingtypes(int size = SizeAtCompileType) // check outer product VERIFY_IS_APPROX((vf * vcf.transpose()).eval(), (vf.template cast >() * vcf.transpose()).eval()); + + // coeff wise product + + VERIFY_IS_APPROX((vf * vcf.transpose()).eval(), (vf.template cast >() * vcf.transpose()).eval()); + + Mat_cd mcd2 = mcd; + VERIFY_IS_APPROX(mcd.array() *= md.array(), mcd2.array() *= md.array().template cast >()); }