From 2b6153d3ed3fb0096a6f10e97c884b1ad559192e Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 19 May 2010 16:37:17 +0200 Subject: simplify inner product --- Eigen/src/Core/MapBase.h | 4 ++-- Eigen/src/Core/Product.h | 24 +++++------------------- Eigen/src/Core/ProductBase.h | 2 +- 3 files changed, 8 insertions(+), 22 deletions(-) (limited to 'Eigen') diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index 5674094c4..08b81c134 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -56,7 +56,7 @@ template class MapBase using Base::IsVectorAtCompileTime; using Base::Flags; using Base::IsRowMajor; - + using Base::CoeffReadCost; // using Base::derived; @@ -78,7 +78,7 @@ template class MapBase using Base::outerStride; using Base::rowStride; using Base::colStride; - + typedef typename Base::CoeffReturnType CoeffReturnType; diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 22240b37a..156f043b7 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -169,33 +169,19 @@ struct ei_traits > template class GeneralProduct : ei_no_assignment_operator, - public MatrixBase > + public Matrix::ReturnType,1,1> { + typedef Matrix::ReturnType,1,1> Base; public: - typedef MatrixBase Base; - EIGEN_DENSE_PUBLIC_INTERFACE(GeneralProduct) - - EIGEN_DONT_INLINE GeneralProduct(const Lhs& lhs, const Rhs& rhs) + 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_value; + Base::coeffRef(0,0) = (lhs.transpose().cwiseProduct(rhs)).sum(); } - EIGEN_STRONG_INLINE Scalar coeff(int, int) const { return value(); } - - EIGEN_STRONG_INLINE Scalar coeff(int) const { return value(); } - protected: - Scalar m_value; + typename Base::Scalar value() const { return Base::coeff(0,0); } }; /*********************************************************************** diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index b7c4ac11d..fbf77f2a5 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -29,7 +29,7 @@ * */ template -struct ei_traits > //: ei_traits::type> +struct ei_traits > { typedef MatrixXpr XprKind; typedef typename ei_cleantype<_Lhs>::type Lhs; -- cgit v1.2.3