diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index 9fdb74f1c..4c95684f0 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -83,7 +83,11 @@ class ProductBase : public MatrixBase typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType; typedef typename ei_cleantype::type _ActualRhsType; - typedef typename ProductReturnType::Type LazyCoeffBaseProductType; + // here we don't use ProductReturnType::Type because we must nest it by value. + typedef typename ei_nested<_LhsNested, _RhsNested::ColsAtCompileTime, typename ei_plain_matrix_type<_LhsNested>::type >::type LazyLhsNested; + typedef typename ei_nested<_RhsNested, _LhsNested::RowsAtCompileTime, typename ei_plain_matrix_type<_RhsNested>::type >::type LazyRhsNested; + typedef CoeffBasedProduct NestedByValueLazyCoeffBaseProductType; + public: typedef typename Base::PlainMatrixType PlainMatrixType; @@ -114,25 +118,25 @@ class ProductBase : public MatrixBase const _LhsNested& lhs() const { return m_lhs; } const _RhsNested& rhs() const { return m_rhs; } - const Diagonal diagonal() const - { return LazyCoeffBaseProductType(m_lhs, m_rhs); } + const Diagonal diagonal() const + { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs); } - Diagonal diagonal() - { return LazyCoeffBaseProductType(m_lhs, m_rhs); } + Diagonal diagonal() + { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs); } template - const Diagonal diagonal() const - { return LazyCoeffBaseProductType(m_lhs, m_rhs); } + const Diagonal diagonal() const + { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs); } template - Diagonal diagonal() - { return LazyCoeffBaseProductType(m_lhs, m_rhs); } + Diagonal diagonal() + { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs); } - const Diagonal diagonal(int index) const - { return LazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); } + const Diagonal diagonal(int index) const + { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); } - Diagonal diagonal(int index) - { return LazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); } + Diagonal diagonal(int index) + { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); } // Implicit convertion to the nested type (trigger the evaluation of the product) operator const PlainMatrixType& () const diff --git a/Eigen/src/Core/products/CoeffBasedProduct.h b/Eigen/src/Core/products/CoeffBasedProduct.h index c9d333072..af0d2e2a2 100644 --- a/Eigen/src/Core/products/CoeffBasedProduct.h +++ b/Eigen/src/Core/products/CoeffBasedProduct.h @@ -129,6 +129,10 @@ class CoeffBasedProduct public: + inline CoeffBasedProduct(const CoeffBasedProduct& other) + : Base(), m_lhs(other.m_lhs), m_rhs(other.m_rhs) + {} + template inline CoeffBasedProduct(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs)