diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index 975a80bd3..fc8b254d7 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -38,6 +38,27 @@ class DiagonalMatrixBase : ei_no_assignment_operator, protected: typedef typename ei_cleantype::type _CoeffsVectorType; + + template + struct construct_from_expression; + + // = vector + template + struct construct_from_expression + { + static void run(Derived& dst, const OtherDerived& src) + { dst.diagonal() = src; } + }; + + // = diagonal expression + template + struct construct_from_expression + { + static void run(Derived& dst, const OtherDerived& src) + { dst.diagonal() = src.diagonal(); } + }; /** Default constructor without initialization */ inline DiagonalMatrixBase() {} @@ -50,27 +71,6 @@ class DiagonalMatrixBase : ei_no_assignment_operator, construct_from_expression::run(derived(),other.derived()); } - template - struct construct_from_expression; - - // = vector - template - struct construct_from_expression - { - static void run(Derived& dst, const OtherDerived& src) - { dst.m_coeffs = src; } - }; - - // = diagonal - template - struct construct_from_expression - { - static void run(Derived& dst, const OtherDerived& src) - { dst.m_coeffs = src.diagonal(); } - }; - public: inline DiagonalMatrixBase(const _CoeffsVectorType& coeffs) : m_coeffs(coeffs) @@ -79,21 +79,6 @@ class DiagonalMatrixBase : ei_no_assignment_operator, ei_assert(coeffs.size() > 0); } - template - struct ei_diagonal_product_ctor { - static void run(DiagonalMatrixBase& dst, const OtherDerived& src) - { dst.m_coeffs = src; } - }; - - template - struct ei_diagonal_product_ctor { - static void run(DiagonalMatrixBase& dst, const OtherDerived& src) - { - EIGEN_STATIC_ASSERT((OtherDerived::Flags&Diagonal)==Diagonal, THIS_METHOD_IS_ONLY_FOR_DIAGONAL_MATRIX); - dst.m_coeffs = src.diagonal(); - } - }; - template inline DiagonalMatrixWrapper, _CoeffsVectorType> > > cast() const { diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index 734ef1929..5b5907073 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -92,7 +92,8 @@ MatrixBase::redux(const BinaryOp& func) const const bool unroll = SizeAtCompileTime * CoeffReadCost + (SizeAtCompileTime-1) * ei_functor_traits::Cost <= EIGEN_UNROLLING_LIMIT; - return ei_redux_impl + typedef typename ei_cleantype::type ThisNested; + return ei_redux_impl ::run(derived(), func); } diff --git a/Eigen/src/Core/Sum.h b/Eigen/src/Core/Sum.h index 6d7e9959f..7eddda14a 100644 --- a/Eigen/src/Core/Sum.h +++ b/Eigen/src/Core/Sum.h @@ -252,7 +252,8 @@ template inline typename ei_traits::Scalar MatrixBase::sum() const { - return ei_sum_impl::run(derived()); + typedef typename ei_cleantype::type ThisNested; + return ei_sum_impl::run(derived()); } /** \returns the trace of \c *this, i.e. the sum of the coefficients on the main diagonal.