Boost logo

Ublas :

Subject: Re: [ublas] enable complex @ int
From: Neal Becker (ndbecker2_at_[hidden])
Date: 2009-09-29 14:24:09


namespace boost { namespace numeric { namespace ublas {

      template<typename R>
      typename boost::enable_if<boost::is_float<R>, std::complex<R> >::type
inline operator+ (int in1, std::complex<R> const& in2 ) {
        return R (in1) + in2;
      }

      template<typename R>
      typename boost::enable_if<boost::is_float<R>, std::complex<R> >::type
inline operator+ (std::complex<R> const& in1, int in2) {
        return in1 + R (in2);
      }

      template<typename R>
      typename boost::enable_if<boost::is_float<R>, std::complex<R> >::type
inline operator- (int in1, std::complex<R> const& in2) {
        return R (in1) - in2;
      }

      template<typename R>
      typename boost::enable_if<boost::is_float<R>, std::complex<R> >::type
inline operator- (std::complex<R> const& in1, int in2) {
        return in1 - R (in2);
      }

      template<typename R>
      typename boost::enable_if<boost::is_float<R>, std::complex<R> >::type
inline operator* (int in1, std::complex<R> const& in2) {
        return R (in1) * in2;
      }

      template<typename R>
      typename boost::enable_if<boost::is_float<R>, std::complex<R> >::type
inline operator* (std::complex<R> const& in1, int in2) {
        return in1 * R(in2);
      }

      template<typename R>
      typename boost::enable_if<boost::is_float<R>, std::complex<R> >::type
inline operator/ (int in1, std::complex<R> const& in2) {
        return R(in1) / in2;
      }

      template<typename R>
      typename boost::enable_if<boost::is_float<R>, std::complex<R> >::type
inline operator/ (std::complex<R> const& in1, int in2) {
        return in1 / R (in2);
      }