From 7b60713e87ba24d3b0fa8f486bba8665151e9f31 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sat, 15 Aug 2009 11:52:50 +0200 Subject: my previous fix was not very good --- Eigen/src/Core/ProductBase.h | 26 +++++++++++++++++++++----- Eigen/src/Core/util/Meta.h | 7 +------ 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'Eigen/src') diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index 2090a0e49..b5ed5ae8f 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -149,15 +149,31 @@ class ScaledProduct; // define all overloads defined in MatrixBase. Furthermore, Using // "using Base::operator*" would not work with MSVC. // -// Also note that here we accept any type which can be converted to Derived::Scalar. -template -const ScaledProduct operator*(const ProductBase& prod, Scalar x) +// Also note that here we accept any compatible scalar types +template +const ScaledProduct +operator*(const ProductBase& prod, typename Derived::Scalar x) { return ScaledProduct(prod.derived(), x); } -template -const ScaledProduct operator*(Scalar x,const ProductBase& prod) +template +typename ei_enable_if::ret, + const ScaledProduct >::type +operator*(const ProductBase& prod, typename Derived::RealScalar x) { return ScaledProduct(prod.derived(), x); } + +template +const ScaledProduct +operator*(typename Derived::Scalar x,const ProductBase& prod) +{ return ScaledProduct(prod.derived(), x); } + +template +typename ei_enable_if::ret, + const ScaledProduct >::type +operator*(typename Derived::RealScalar x,const ProductBase& prod) +{ return ScaledProduct(prod.derived(), x); } + + template struct ei_traits > : ei_traits, diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 029d966fd..3a960bea6 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -155,12 +155,7 @@ template class ei_meta_sqrt { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; }; /** \internal determines whether the product of two numeric types is allowed and what the return type is */ -template struct ei_scalar_product_traits -{ - // dummy general case where T and U aren't compatible -- not allowed anyway but we catch it elsewhere - //enum { Cost = NumTraits::MulCost }; - typedef T ReturnType; -}; +template struct ei_scalar_product_traits; template struct ei_scalar_product_traits { -- cgit v1.2.3