Struct thrust::complex
complex
is the Thrust equivalent to std::complex
. It is functionally identical to it, but can also be used in device code which std::complex
currently cannot.
Template Parameters: T
: The type used to hold the real and imaginary parts. Should be float
or double
. Others types are not supported.
#include <thrust/complex.h>
template <typename T> struct thrust::complex { public: typedef see below value_type;
_CCCL_HOST_DEVICE complex(const T & re);
_CCCL_HOST_DEVICE complex(const T & re, const T & im);
complex() = default;
complex(const complex< T > & z) = default;
template <typename U> _CCCL_HOST_DEVICE complex(const complex< U > & z);
_CCCL_HOST _CCCL_DEVICE complex(const std::complex< T > & z);
template <typename U> _CCCL_HOST _CCCL_DEVICE complex(const std::complex< U > & z);
_CCCL_HOST_DEVICE complex & operator=(const T & re);
complex & operator=(const complex< T > & z) = default;
template <typename U> _CCCL_HOST_DEVICE complex & operator=(const complex< U > & z);
_CCCL_HOST _CCCL_DEVICE complex & operator=(const std::complex< T > & z);
template <typename U> _CCCL_HOST _CCCL_DEVICE complex & operator=(const std::complex< U > & z);
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator+=(const complex< U > & z);
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator-=(const complex< U > & z);
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator*=(const complex< U > & z);
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator/=(const complex< U > & z);
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator+=(const U & z);
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator-=(const U & z);
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator*=(const U & z);
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator/=(const U & z);
_CCCL_HOST_DEVICE T real() const;
_CCCL_HOST_DEVICE T imag() const;
_CCCL_HOST_DEVICE T real() const;
_CCCL_HOST_DEVICE T imag() const;
_CCCL_HOST_DEVICE void real(T re);
_CCCL_HOST_DEVICE void imag(T im);
_CCCL_HOST_DEVICE void real(T re);
_CCCL_HOST_DEVICE void imag(T im);
_CCCL_HOST complex< T >() const; };
Member Types
Typedef thrust::complex::value_type
typedef Tvalue_type;
value_type
is the type of complex's
real and imaginary parts.
Member Functions
Function thrust::complex::complex
_CCCL_HOST_DEVICE complex(const T & re);
Construct a complex number with an imaginary part of 0.
Function Parameters: re
: The real part of the number.
Function thrust::complex::complex
_CCCL_HOST_DEVICE complex(const T & re, const T & im);
Construct a complex number from its real and imaginary parts.
Function Parameters:
re
The real part of the number.im
The imaginary part of the number.
Function thrust::complex::complex
complex() = default;
Default construct a complex number.
Function thrust::complex::complex
complex(const complex< T > & z) = default;
This copy constructor copies from a complex
with a type that is convertible to this complex's
value_type
.
Function Parameters: z
: The complex
to copy from.
Function thrust::complex::complex
template <typename U> _CCCL_HOST_DEVICE complex(const complex< U > & z);
This converting copy constructor copies from a complex
with a type that is convertible to this complex's
value_type
.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The complex
to copy from.
Function thrust::complex::complex
_CCCL_HOST _CCCL_DEVICE complex(const std::complex< T > & z);
This converting copy constructor copies from a std::complex
with a type that is convertible to this complex's
value_type
.
Function Parameters: z
: The complex
to copy from.
Function thrust::complex::complex
template <typename U> _CCCL_HOST _CCCL_DEVICE complex(const std::complex< U > & z);
This converting copy constructor copies from a std::complex
with a type that is convertible to this complex's
value_type
.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The complex
to copy from.
Function thrust::complex::operator=
_CCCL_HOST_DEVICE complex & operator=(const T & re);
Assign re
to the real part of this complex
and set the imaginary part to 0.
Function Parameters: re
: The real part of the number.
Function thrust::complex::operator=
complex & operator=(const complex< T > & z) = default;
Assign z.real()
and z.imag()
to the real and imaginary parts of this complex
respectively.
Function Parameters: z
: The complex
to copy from.
Function thrust::complex::operator=
template <typename U> _CCCL_HOST_DEVICE complex & operator=(const complex< U > & z);
Assign z.real()
and z.imag()
to the real and imaginary parts of this complex
respectively.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The complex
to copy from.
Function thrust::complex::operator=
_CCCL_HOST _CCCL_DEVICE complex & operator=(const std::complex< T > & z);
Assign z.real()
and z.imag()
to the real and imaginary parts of this complex
respectively.
Function Parameters: z
: The complex
to copy from.
Function thrust::complex::operator=
template <typename U> _CCCL_HOST _CCCL_DEVICE complex & operator=(const std::complex< U > & z);
Assign z.real()
and z.imag()
to the real and imaginary parts of this complex
respectively.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The complex
to copy from.
Function thrust::complex::operator+=
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator+=(const complex< U > & z);
Adds a complex
to this complex
and assigns the result to this complex
.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The complex
to be added.
Function thrust::complex::operator-=
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator-=(const complex< U > & z);
Subtracts a complex
from this complex
and assigns the result to this complex
.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The complex
to be subtracted.
Function thrust::complex::operator*=
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator*=(const complex< U > & z);
Multiplies this complex
by another complex
and assigns the result to this complex
.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The complex
to be multiplied.
Function thrust::complex::operator/=
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator/=(const complex< U > & z);
Divides this complex
by another complex
and assigns the result to this complex
.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The complex
to be divided.
Function thrust::complex::operator+=
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator+=(const U & z);
Adds a scalar to this complex
and assigns the result to this complex
.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The complex
to be added.
Function thrust::complex::operator-=
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator-=(const U & z);
Subtracts a scalar from this complex
and assigns the result to this complex
.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The scalar to be subtracted.
Function thrust::complex::operator*=
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator*=(const U & z);
Multiplies this complex
by a scalar and assigns the result to this complex
.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The scalar to be multiplied.
Function thrust::complex::operator/=
template <typename U> _CCCL_HOST_DEVICE complex< T > & operator/=(const U & z);
Divides this complex
by a scalar and assigns the result to this complex
.
Template Parameters: U
: is convertible to value_type
.
Function Parameters: z
: The scalar to be divided.
Function thrust::complex::real
_CCCL_HOST_DEVICE T real() const;
Returns the real part of this complex
.
Function thrust::complex::imag
_CCCL_HOST_DEVICE T imag() const;
Returns the imaginary part of this complex
.
Function thrust::complex::real
_CCCL_HOST_DEVICE T real() const;
Returns the real part of this complex
.
Function thrust::complex::imag
_CCCL_HOST_DEVICE T imag() const;
Returns the imaginary part of this complex
.
Function thrust::complex::real
_CCCL_HOST_DEVICE void real(T re);
Sets the real part of this complex
.
Function Parameters: re
: The new real part of this complex
.
Function thrust::complex::imag
_CCCL_HOST_DEVICE void imag(T im);
Sets the imaginary part of this complex
.
Function Parameters: im
: The new imaginary part of this complex.e
Function thrust::complex::real
_CCCL_HOST_DEVICE void real(T re);
Sets the real part of this complex
.
Function Parameters: re
: The new real part of this complex
.
Function thrust::complex::imag
_CCCL_HOST_DEVICE void imag(T im);
Sets the imaginary part of this complex
.
Function Parameters: im
: The new imaginary part of this complex
.
Function thrust::complex::complex< T >
_CCCL_HOST operator std::complex< T >() const;
Casts this complex
to a std::complex
of the same type.