diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 791fddda9..e4b9b4d69 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -163,36 +163,39 @@ struct ProductReturnType template struct ei_traits > - : ei_traits, Lhs, Rhs> > + : ei_traits > {}; template class GeneralProduct - : public ProductBase, Lhs, Rhs> + : ei_no_assignment_operator, + public MatrixBase > { public: - EIGEN_PRODUCT_PUBLIC_INTERFACE(GeneralProduct) + typedef MatrixBase Base; + EIGEN_DENSE_PUBLIC_INTERFACE(GeneralProduct) - GeneralProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs) + EIGEN_DONT_INLINE GeneralProduct(const Lhs& lhs, const Rhs& rhs) { EIGEN_STATIC_ASSERT((ei_is_same_type::ret), YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) + + m_value = (lhs.transpose().cwiseProduct(rhs)).sum(); } + int rows() const { return 1; } + int cols() const { return 1; } + EIGEN_STRONG_INLINE Scalar value() const { - return (m_lhs.transpose().cwiseProduct(m_rhs)).sum(); - } - - template void scaleAndAddTo(Dest& dst, Scalar alpha) const - { - ei_assert(dst.rows()==1 && dst.cols()==1); - dst.coeffRef(0,0) += alpha * value(); + return m_value; } EIGEN_STRONG_INLINE Scalar coeff(int, int) const { return value(); } EIGEN_STRONG_INLINE Scalar coeff(int) const { return value(); } + protected: + Scalar m_value; }; /***********************************************************************