diff options
Diffstat (limited to 'Eigen/src/Core/util/Meta.h')
-rw-r--r-- | Eigen/src/Core/util/Meta.h | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 7ecd59add..af661c313 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -375,33 +375,6 @@ template<typename T, typename U> struct scalar_product_traits enum { Defined = 0 }; }; -template<typename T> struct scalar_product_traits<T,T> -{ - enum { - // Cost = NumTraits<T>::MulCost, - Defined = 1 - }; - typedef T ReturnType; -}; - -template<typename T> struct scalar_product_traits<T,std::complex<T> > -{ - enum { - // Cost = 2*NumTraits<T>::MulCost, - Defined = 1 - }; - typedef std::complex<T> ReturnType; -}; - -template<typename T> struct scalar_product_traits<std::complex<T>, T> -{ - enum { - // Cost = 2*NumTraits<T>::MulCost, - Defined = 1 - }; - typedef std::complex<T> ReturnType; -}; - // FIXME quick workaround around current limitation of result_of // template<typename Scalar, typename ArgType0, typename ArgType1> // struct result_of<scalar_product_op<Scalar>(ArgType0,ArgType1)> { @@ -434,6 +407,43 @@ T div_ceil(const T &a, const T &b) } // end namespace numext + +/** \class ScalarBinaryOpTraits + * \ingroup Core_Module + * + * \brief Determines whether the given binary operation of two numeric types is allowed and what the scalar return type is. + * + * \sa CwiseBinaryOp + */ +template<typename ScalarA, typename ScalarB, typename BinaryOp> +struct ScalarBinaryOpTraits +#ifndef EIGEN_PARSED_BY_DOXYGEN + // for backward compatibility, use the hints given by the (deprecated) internal::scalar_product_traits class. + : internal::scalar_product_traits<ScalarA,ScalarB> +#endif // EIGEN_PARSED_BY_DOXYGEN +{}; + +template<typename T, typename BinaryOp> +struct ScalarBinaryOpTraits<T,T,BinaryOp> +{ + enum { Defined = 1 }; + typedef T ReturnType; +}; + +template<typename T, typename BinaryOp> +struct ScalarBinaryOpTraits<T,std::complex<T>,BinaryOp> +{ + enum { Defined = 1 }; + typedef std::complex<T> ReturnType; +}; + +template<typename T, typename BinaryOp> +struct ScalarBinaryOpTraits<std::complex<T>, T,BinaryOp> +{ + enum { Defined = 1 }; + typedef std::complex<T> ReturnType; +}; + } // end namespace Eigen #endif // EIGEN_META_H |