diff --git a/Eigen/src/Core/DenseStorageBase.h b/Eigen/src/Core/DenseStorageBase.h index f3d6e8944..313ac037c 100644 --- a/Eigen/src/Core/DenseStorageBase.h +++ b/Eigen/src/Core/DenseStorageBase.h @@ -490,7 +490,7 @@ class DenseStorageBase : public _Base return ei_assign_selector::run(this->derived(), other.derived()); } - static EIGEN_STRONG_INLINE void _check_template_params() + EIGEN_STRONG_INLINE void _check_template_params() { #ifdef EIGEN_DEBUG_MATRIX_CTOR EIGEN_DEBUG_MATRIX_CTOR; diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index 5c51ea27c..fa3207f65 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -42,7 +42,8 @@ struct ei_traits > //: ei_traits::ColsAtCompileTime, MaxRowsAtCompileTime = ei_traits::MaxRowsAtCompileTime, MaxColsAtCompileTime = ei_traits::MaxColsAtCompileTime, - Flags = EvalBeforeNestingBit | EvalBeforeAssigningBit, + Flags = EvalBeforeNestingBit | EvalBeforeAssigningBit | NestByRefBit, // Note that EvalBeforeNestingBit and NestByRefBit + // are not used in practice because ei_nested is overloaded for products CoeffReadCost = 0 // FIXME why is it needed ? }; }; @@ -137,11 +138,21 @@ class ProductBase : public MatrixBase Diagonal diagonal(int index) { return Diagonal(LazyCoeffBaseProductType(CoeffBaseProductType(m_lhs, m_rhs))).diagonal(index); } + // Implicit convertion to the nested type (trigger the evaluation of the product) + operator const PlainMatrixType& () const + { + m_result.resize(m_lhs.rows(), m_rhs.cols()); + this->evalTo(m_result); + return m_result; + } + protected: const LhsNested m_lhs; const RhsNested m_rhs; + mutable PlainMatrixType m_result; + private: // discard coeff methods @@ -151,6 +162,14 @@ class ProductBase : public MatrixBase void coeffRef(int); }; +// here we need to overload the nested rule for products +// such that the nested type is a const reference to a plain matrix +template +struct ei_nested, N, PlainMatrixType> +{ + typedef PlainMatrixType const& type; +}; + template class ScaledProduct;