2
0
mirror of https://github.com/boostorg/ublas.git synced 2026-02-21 15:32:12 +00:00
* applied patch
 * existing unit test seem to work


[SVN r58104]
This commit is contained in:
Gunter Winkler
2009-12-02 20:20:50 +00:00
parent f3d44c0ba7
commit 980f49be7b

View File

@@ -23,6 +23,11 @@
#include <boost/type_traits.hpp>
#include <complex>
#include <boost/typeof/typeof.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/mpl/and.hpp>
// 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 R, typename I>
typename boost::enable_if<
mpl::and_<
boost::is_float<R>,
boost::is_integral<I>
>,
std::complex<R> >::type inline operator+ (I in1, std::complex<R> const& in2 ) {
return R (in1) + in2;
}
template<typename R, typename I>
typename boost::enable_if<
mpl::and_<
boost::is_float<R>,
boost::is_integral<I>
>,
std::complex<R> >::type inline operator+ (std::complex<R> const& in1, I in2) {
return in1 + R (in2);
}
template<typename R, typename I>
typename boost::enable_if<
mpl::and_<
boost::is_float<R>,
boost::is_integral<I>
>,
std::complex<R> >::type inline operator- (I in1, std::complex<R> const& in2) {
return R (in1) - in2;
}
template<typename R, typename I>
typename boost::enable_if<
mpl::and_<
boost::is_float<R>,
boost::is_integral<I>
>,
std::complex<R> >::type inline operator- (std::complex<R> const& in1, I in2) {
return in1 - R (in2);
}
template<typename R, typename I>
typename boost::enable_if<
mpl::and_<
boost::is_float<R>,
boost::is_integral<I>
>,
std::complex<R> >::type inline operator* (I in1, std::complex<R> const& in2) {
return R (in1) * in2;
}
template<typename R, typename I>
typename boost::enable_if<
mpl::and_<
boost::is_float<R>,
boost::is_integral<I>
>,
std::complex<R> >::type inline operator* (std::complex<R> const& in1, I in2) {
return in1 * R(in2);
}
template<typename R, typename I>
typename boost::enable_if<
mpl::and_<
boost::is_float<R>,
boost::is_integral<I>
>,
std::complex<R> >::type inline operator/ (I in1, std::complex<R> const& in2) {
return R(in1) / in2;
}
template<typename R, typename I>
typename boost::enable_if<
mpl::and_<
boost::is_float<R>,
boost::is_integral<I>
>,
std::complex<R> >::type inline operator/ (std::complex<R> const& in1, I in2) {
return in1 / R (in2);
}
// Type traits - generic numeric properties and functions
template<class T>