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>
46struct norm_type< cusp::complex<T> >
66inline typename cusp::norm_type<T>::type
69 return z > 0 ? z : -z;
76inline typename cusp::norm_type<T>::type
117 typedef T value_type;
126 inline _CCCL_HOST_DEVICE
127 complex(
const T & re = T(),
const T& im = T());
136 template <
typename X>
137 inline _CCCL_HOST_DEVICE
138 complex(
const complex<X> & z);
147 template <
typename X>
149 complex(
const std::complex<X> & z);
161 inline complex<T>& operator+=(
const complex<T> z);
169 inline complex<T>& operator-=(
const complex<T> z);
177 inline complex<T>& operator*=(
const complex<T> z);
185 inline complex<T>& operator/=(
const complex<T> z);
196 _CCCL_HOST_DEVICE
inline T real()
const volatile {
202 _CCCL_HOST_DEVICE
inline T imag()
const volatile {
208 _CCCL_HOST_DEVICE
inline T real()
const {
214 _CCCL_HOST_DEVICE
inline T imag()
const {
229 _CCCL_HOST_DEVICE
inline void real(T re)
volatile {
237 _CCCL_HOST_DEVICE
inline void imag(T im)
volatile {
245 _CCCL_HOST_DEVICE
inline void real(T re) {
253 _CCCL_HOST_DEVICE
inline void imag(T im) {
263 inline operator std::complex<T>()
const {
264 return std::complex<T>(real(),imag());
278template<
typename T> _CCCL_HOST_DEVICE
inline T
abs(
const complex<T>& z);
284template<
typename T> _CCCL_HOST_DEVICE
inline T arg(
const complex<T>& z);
290template<
typename T> _CCCL_HOST_DEVICE
inline T
norm(
const complex<T>& z);
296template<
typename T> _CCCL_HOST_DEVICE
inline complex<T>
conj(
const complex<T>& z);
303template<
typename T> _CCCL_HOST_DEVICE
inline complex<T> polar(
const T& m,
const T& theta = 0);
312template<
typename T> _CCCL_HOST_DEVICE
inline complex<T> proj(
const T& z);
323template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator*(
const complex<T>& lhs,
const complex<T>& rhs);
330template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator*(
const complex<T>& lhs,
const T & rhs);
337template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator*(
const T& lhs,
const complex<T>& rhs);
344template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator/(
const complex<T>& lhs,
const complex<T>& rhs);
351template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator/(
const complex<T>& lhs,
const T & rhs);
358template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator/(
const T& lhs,
const complex<T> & rhs);
365template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator+(
const complex<T>& lhs,
const complex<T>& rhs);
372template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator+(
const complex<T>& lhs,
const T & rhs);
379template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator+(
const T& lhs,
const complex<T>& rhs);
386template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator-(
const complex<T>& lhs,
const complex<T>& rhs);
393template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator-(
const complex<T>& lhs,
const T & rhs);
400template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator-(
const T& lhs,
const complex<T>& rhs);
410template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator+(
const complex<T>& rhs);
416template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> operator-(
const complex<T>& rhs);
426template <
typename T> _CCCL_HOST_DEVICE complex<T> exp(
const complex<T>& z);
432template <
typename T> _CCCL_HOST_DEVICE complex<T> log(
const complex<T>& z);
438template <
typename T> _CCCL_HOST_DEVICE
inline complex<T> log10(
const complex<T>& z);
449template <
typename T> _CCCL_HOST_DEVICE complex<T> pow(
const complex<T>& x,
const complex<T>& y);
456template <
typename T> _CCCL_HOST_DEVICE complex<T> pow(
const complex<T>& x,
const T& y);
463template <
typename T> _CCCL_HOST_DEVICE complex<T> pow(
const T& x,
const complex<T>& y);
472template <
typename T,
typename U> _CCCL_HOST_DEVICE complex<typename detail::promoted_numerical_type<T,U>::type > pow(
const complex<T>& x,
const complex<U>& y);
480template <
typename T,
typename U> _CCCL_HOST_DEVICE complex<typename detail::promoted_numerical_type<T,U>::type > pow(
const complex<T>& x,
const U& y);
488template <
typename T,
typename U> _CCCL_HOST_DEVICE complex<typename detail::promoted_numerical_type<T,U>::type > pow(
const T& x,
const complex<U>& y);
496template <
typename T> _CCCL_HOST_DEVICE complex<T> sqrt(
const complex<T>&z);
506template <
typename T> _CCCL_HOST_DEVICE complex<T> cos(
const complex<T>&z);
512template <
typename T> _CCCL_HOST_DEVICE complex<T> sin(
const complex<T>&z);
518template <
typename T> _CCCL_HOST_DEVICE complex<T> tan(
const complex<T>&z);
528template <
typename T> _CCCL_HOST_DEVICE complex<T> cosh(
const complex<T>& z);
534template <
typename T> _CCCL_HOST_DEVICE complex<T> sinh(
const complex<T>&z);
540template <
typename T> _CCCL_HOST_DEVICE complex<T> tanh(
const complex<T>&z);
553template <
typename T> _CCCL_HOST_DEVICE complex<T> acos(
const complex<T>& z);
562template <
typename T> _CCCL_HOST_DEVICE complex<T> asin(
const complex<T>& z);
571template <
typename T> _CCCL_HOST_DEVICE complex<T> atan(
const complex<T>& z);
584template <
typename T> _CCCL_HOST_DEVICE complex<T> acosh(
const complex<T>& z);
593template <
typename T> _CCCL_HOST_DEVICE complex<T> asinh(
const complex<T>& z);
602template <
typename T> _CCCL_HOST_DEVICE complex<T> atanh(
const complex<T>& z);
613template<
typename ValueType,
class charT,
class traits>
614std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os,
const complex<ValueType>& z);
627template<
typename ValueType,
typename charT,
class traits>
628std::basic_istream<charT, traits>&
629operator>>(std::basic_istream<charT, traits>& is, complex<ValueType>& z);
640template <
typename T> _CCCL_HOST_DEVICE
inline bool operator==(
const complex<T>& lhs,
const complex<T>& rhs);
647template <
typename T> _CCCL_HOST_DEVICE
inline bool operator==(
const T & lhs,
const complex<T>& rhs);
654template <
typename T> _CCCL_HOST_DEVICE
inline bool operator==(
const complex<T> & lhs,
const T& rhs);
661template <
typename T> _CCCL_HOST_DEVICE
inline bool operator!=(
const complex<T>& lhs,
const complex<T>& rhs);
668template <
typename T> _CCCL_HOST_DEVICE
inline bool operator!=(
const T & lhs,
const complex<T>& rhs);
675template <
typename T> _CCCL_HOST_DEVICE
inline bool operator!=(
const complex<T> & lhs,
const T& rhs);
677#include <thrust/detail/complex/complex.inl>
_CCCL_HOST_DEVICE cusp::norm_type< T >::type abs(const T &z)
Compute the absolute value of z.
_CCCL_HOST_DEVICE cusp::norm_type< T >::type norm(const T &z)
Compute the norm of z.
_CCCL_HOST_DEVICE T conj(const T &z)
Compute the complex conjugate of z. For real types, returns z unchanged.