23 #include <cusp/detail/config.h>
25 #include <thrust/functional.h>
27 #if THRUST_VERSION >= 100800
28 #include <thrust/complex.h>
30 #include <cusp/detail/thrust/complex.h>
36 using thrust::complex;
46 struct norm_type< cusp::complex<T> >
64 inline typename cusp::norm_type<T>::type
67 return z > 0 ? z : -z;
73 inline typename cusp::norm_type<T>::type
106 template <
typename T>
113 typedef T value_type;
122 inline __host__ __device__
123 complex(
const T & re = T(),
const T& im = T());
132 template <
typename X>
133 inline __host__ __device__
134 complex(
const complex<X> & z);
143 template <
typename X>
145 complex(
const std::complex<X> & z);
157 inline complex<T>& operator+=(
const complex<T> z);
165 inline complex<T>& operator-=(
const complex<T> z);
173 inline complex<T>& operator*=(
const complex<T> z);
181 inline complex<T>& operator/=(
const complex<T> z);
192 __host__ __device__
inline T real()
const volatile {
198 __host__ __device__
inline T imag()
const volatile {
204 __host__ __device__
inline T real()
const {
210 __host__ __device__
inline T imag()
const {
225 __host__ __device__
inline void real(T re)
volatile {
233 __host__ __device__
inline void imag(T im)
volatile {
241 __host__ __device__
inline void real(T re) {
249 __host__ __device__
inline void imag(T im) {
259 inline operator std::complex<T>()
const {
260 return std::complex<T>(real(),imag());
274 template<
typename T> __host__ __device__
inline T abs(
const complex<T>& z);
280 template<
typename T> __host__ __device__
inline T arg(
const complex<T>& z);
286 template<
typename T> __host__ __device__
inline T norm(
const complex<T>& z);
292 template<
typename T> __host__ __device__
inline complex<T> conj(
const complex<T>& z);
299 template<
typename T> __host__ __device__
inline complex<T> polar(
const T& m,
const T& theta = 0);
308 template<
typename T> __host__ __device__
inline complex<T> proj(
const T& z);
319 template <
typename T> __host__ __device__
inline complex<T> operator*(
const complex<T>& lhs,
const complex<T>& rhs);
326 template <
typename T> __host__ __device__
inline complex<T> operator*(
const complex<T>& lhs,
const T & rhs);
333 template <
typename T> __host__ __device__
inline complex<T> operator*(
const T& lhs,
const complex<T>& rhs);
340 template <
typename T> __host__ __device__
inline complex<T> operator/(
const complex<T>& lhs,
const complex<T>& rhs);
347 template <
typename T> __host__ __device__
inline complex<T> operator/(
const complex<T>& lhs,
const T & rhs);
354 template <
typename T> __host__ __device__
inline complex<T> operator/(
const T& lhs,
const complex<T> & rhs);
361 template <
typename T> __host__ __device__
inline complex<T> operator+(
const complex<T>& lhs,
const complex<T>& rhs);
368 template <
typename T> __host__ __device__
inline complex<T> operator+(
const complex<T>& lhs,
const T & rhs);
375 template <
typename T> __host__ __device__
inline complex<T> operator+(
const T& lhs,
const complex<T>& rhs);
382 template <
typename T> __host__ __device__
inline complex<T> operator-(
const complex<T>& lhs,
const complex<T>& rhs);
389 template <
typename T> __host__ __device__
inline complex<T> operator-(
const complex<T>& lhs,
const T & rhs);
396 template <
typename T> __host__ __device__
inline complex<T> operator-(
const T& lhs,
const complex<T>& rhs);
406 template <
typename T> __host__ __device__
inline complex<T> operator+(
const complex<T>& rhs);
412 template <
typename T> __host__ __device__
inline complex<T> operator-(
const complex<T>& rhs);
422 template <
typename T> __host__ __device__ complex<T> exp(
const complex<T>& z);
428 template <
typename T> __host__ __device__ complex<T> log(
const complex<T>& z);
434 template <
typename T> __host__ __device__
inline complex<T> log10(
const complex<T>& z);
445 template <
typename T> __host__ __device__ complex<T> pow(
const complex<T>& x,
const complex<T>& y);
452 template <
typename T> __host__ __device__ complex<T> pow(
const complex<T>& x,
const T& y);
459 template <
typename T> __host__ __device__ complex<T> pow(
const T& x,
const complex<T>& y);
461 #if !defined _MSC_VER
468 template <
typename T,
typename U> __host__ __device__ complex<typename detail::promoted_numerical_type<T,U>::type > pow(
const complex<T>& x,
const complex<U>& y);
476 template <
typename T,
typename U> __host__ __device__ complex<typename detail::promoted_numerical_type<T,U>::type > pow(
const complex<T>& x,
const U& y);
484 template <
typename T,
typename U> __host__ __device__ complex<typename detail::promoted_numerical_type<T,U>::type > pow(
const T& x,
const complex<U>& y);
486 #endif // !defined _MSC_VER
492 template <
typename T> __host__ __device__ complex<T> sqrt(
const complex<T>&z);
502 template <
typename T> __host__ __device__ complex<T> cos(
const complex<T>&z);
508 template <
typename T> __host__ __device__ complex<T> sin(
const complex<T>&z);
514 template <
typename T> __host__ __device__ complex<T> tan(
const complex<T>&z);
524 template <
typename T> __host__ __device__ complex<T> cosh(
const complex<T>& z);
530 template <
typename T> __host__ __device__ complex<T> sinh(
const complex<T>&z);
536 template <
typename T> __host__ __device__ complex<T> tanh(
const complex<T>&z);
549 template <
typename T> __host__ __device__ complex<T> acos(
const complex<T>& z);
558 template <
typename T> __host__ __device__ complex<T> asin(
const complex<T>& z);
567 template <
typename T> __host__ __device__ complex<T> atan(
const complex<T>& z);
580 template <
typename T> __host__ __device__ complex<T> acosh(
const complex<T>& z);
589 template <
typename T> __host__ __device__ complex<T> asinh(
const complex<T>& z);
598 template <
typename T> __host__ __device__ complex<T> atanh(
const complex<T>& z);
609 template<
typename ValueType,
class charT,
class traits>
610 std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os,
const complex<ValueType>& z);
623 template<
typename ValueType,
typename charT,
class traits>
624 std::basic_istream<charT, traits>&
625 operator>>(std::basic_istream<charT, traits>& is, complex<ValueType>& z);
636 template <
typename T> __host__ __device__
inline bool operator==(
const complex<T>& lhs,
const complex<T>& rhs);
643 template <
typename T> __host__ __device__
inline bool operator==(
const T & lhs,
const complex<T>& rhs);
650 template <
typename T> __host__ __device__
inline bool operator==(
const complex<T> & lhs,
const T& rhs);
657 template <
typename T> __host__ __device__
inline bool operator!=(
const complex<T>& lhs,
const complex<T>& rhs);
664 template <
typename T> __host__ __device__
inline bool operator!=(
const T & lhs,
const complex<T>& rhs);
671 template <
typename T> __host__ __device__
inline bool operator!=(
const complex<T> & lhs,
const T& rhs);
673 #include <thrust/detail/complex/complex.inl>