diff options
author | Gael Guennebaud <g.gael@free.fr> | 2010-05-19 16:37:17 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2010-05-19 16:37:17 +0200 |
commit | 2b6153d3ed3fb0096a6f10e97c884b1ad559192e (patch) | |
tree | ee5a3b304ed47fd8d4596eb94cf731dffe378f28 | |
parent | bf09fe55edd7114dfb150a8a9dbb62965e3e3201 (diff) |
simplify inner product
-rw-r--r-- | Eigen/src/Core/MapBase.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/Product.h | 24 | ||||
-rw-r--r-- | Eigen/src/Core/ProductBase.h | 2 |
3 files changed, 8 insertions, 22 deletions
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<typename Derived> class MapBase using Base::IsVectorAtCompileTime; using Base::Flags; using Base::IsRowMajor; - + using Base::CoeffReadCost; // using Base::derived; @@ -78,7 +78,7 @@ template<typename Derived> 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<GeneralProduct<Lhs,Rhs,InnerProduct> > template<typename Lhs, typename Rhs> class GeneralProduct<Lhs, Rhs, InnerProduct> : ei_no_assignment_operator, - public MatrixBase<GeneralProduct<Lhs, Rhs, InnerProduct> > + public Matrix<typename ei_scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType,1,1> { + typedef Matrix<typename ei_scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType,1,1> Base; public: - typedef MatrixBase<GeneralProduct> 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<typename Lhs::RealScalar, typename Rhs::RealScalar>::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<typename Derived, typename _Lhs, typename _Rhs> -struct ei_traits<ProductBase<Derived,_Lhs,_Rhs> > //: ei_traits<typename ei_cleantype<_Lhs>::type> +struct ei_traits<ProductBase<Derived,_Lhs,_Rhs> > { typedef MatrixXpr XprKind; typedef typename ei_cleantype<_Lhs>::type Lhs; |