From 37054987217d04cf649ba86324092bc14e9f0788 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 26 Aug 2009 00:24:22 +0200 Subject: [PATCH] add coeff(int,int), coeff(int) and value() functions to the inner product specialization --- Eigen/src/Core/Product.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index d70344deb..71203a362 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -164,11 +164,20 @@ class GeneralProduct GeneralProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs) {} + EIGEN_STRONG_INLINE Scalar value() const + { + return (m_lhs.transpose().cwise()*m_rhs).sum(); + } + template void scaleAndAddTo(Dest& dst, Scalar alpha) const { ei_assert(dst.rows()==1 && dst.cols()==1); - dst.coeffRef(0,0) += alpha * (m_lhs.transpose().cwise()*m_rhs).sum(); + dst.coeffRef(0,0) += alpha * value(); } + + EIGEN_STRONG_INLINE Scalar coeff(int, int) const { return value(); } + + EIGEN_STRONG_INLINE Scalar coeff(int) const { return value(); } }; /***********************************************************************