From 566934c330c6ca521b99a2a332acbeccd3f9b1e2 Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Wed, 2 Dec 2009 20:20:50 +0000 Subject: [PATCH] see #3649: * applied patch * existing unit test seem to work svn path=/trunk/boost/numeric/ublas/; revision=58104 --- include/boost/numeric/ublas/traits.hpp | 86 ++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/include/boost/numeric/ublas/traits.hpp b/include/boost/numeric/ublas/traits.hpp index acfaa7ad..7b01fecf 100644 --- a/include/boost/numeric/ublas/traits.hpp +++ b/include/boost/numeric/ublas/traits.hpp @@ -23,6 +23,11 @@ #include #include +#include +#include +#include +#include +#include // anonymous namespace to avoid ADL issues namespace { @@ -60,6 +65,87 @@ namespace boost { namespace numeric { namespace ublas { typedef typename id::type promote_type; }; + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator+ (I in1, std::complex const& in2 ) { + return R (in1) + in2; + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator+ (std::complex const& in1, I in2) { + return in1 + R (in2); + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator- (I in1, std::complex const& in2) { + return R (in1) - in2; + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator- (std::complex const& in1, I in2) { + return in1 - R (in2); + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator* (I in1, std::complex const& in2) { + return R (in1) * in2; + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator* (std::complex const& in1, I in2) { + return in1 * R(in2); + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator/ (I in1, std::complex const& in2) { + return R(in1) / in2; + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator/ (std::complex const& in1, I in2) { + return in1 / R (in2); + } + + // Type traits - generic numeric properties and functions template