Template Struct complex¶
Defined in File complex.h
Struct Documentation¶
-
template<typename
T
>
structcomplex
¶ complex
is the Thrust equivalent tostd::complex
. It is functionally identical to it, but can also be used in device code whichstd::complex
currently cannot.- Template Parameters
T
: The type used to hold the real and imaginary parts. Should befloat
ordouble
. Others types are not supported.
Public Types
-
typedef T
value_type
¶ value_type
is the type ofcomplex's
real and imaginary parts.
Public Functions
-
__host__ __device__ thrust::complex::complex(const T & re)
Construct a complex number with an imaginary part of 0.
- Parameters
re
: The real part of the number.
-
__host__ __device__ thrust::complex::complex(const T & re, const T & im)
Construct a complex number from its real and imaginary parts.
- Parameters
re
: The real part of the number.im
: The imaginary part of the number.
-
__host__ __device__ thrust::complex::complex()
Default construct a complex number.
-
__host__ __device__ thrust::complex::complex(const complex < T > & z)
This copy constructor copies from a
complex
with a type that is convertible to thiscomplex's
value_type
.- Parameters
z
: Thecomplex
to copy from.
-
template<typename U>__host__ __device__ thrust::complex::complex(const complex < U > & z)
This converting copy constructor copies from a
complex
with a type that is convertible to thiscomplex's
value_type
.- Parameters
z
: Thecomplex
to copy from.
- Template Parameters
U
: is convertible tovalue_type
.
-
__host__ THRUST_STD_COMPLEX_DEVICE thrust::complex::complex(const std::complex< T > & z)
This converting copy constructor copies from a
std::complex
with a type that is convertible to thiscomplex's
value_type
.- Parameters
z
: Thecomplex
to copy from.
-
template<typename U>__host__ THRUST_STD_COMPLEX_DEVICE thrust::complex::complex(const std::complex< U > & z)
This converting copy constructor copies from a
std::complex
with a type that is convertible to thiscomplex's
value_type
.- Parameters
z
: Thecomplex
to copy from.
- Template Parameters
U
: is convertible tovalue_type
.
-
__host__ __device__ complex& thrust::complex::operator=(const T & re)
Assign
re
to the real part of thiscomplex
and set the imaginary part to 0.- Parameters
re
: The real part of the number.
-
__host__ __device__ complex& thrust::complex::operator=(const complex < T > & z)
Assign
z.real()
andz.imag()
to the real and imaginary parts of thiscomplex
respectively.- Parameters
z
: Thecomplex
to copy from.
-
template<typename U>__host__ __device__ complex& thrust::complex::operator=(const complex < U > & z)
Assign
z.real()
andz.imag()
to the real and imaginary parts of thiscomplex
respectively.- Parameters
z
: Thecomplex
to copy from.
- Template Parameters
U
: is convertible tovalue_type
.
-
__host__ THRUST_STD_COMPLEX_DEVICE complex& thrust::complex::operator=(const std::complex< T > & z)
Assign
z.real()
andz.imag()
to the real and imaginary parts of thiscomplex
respectively.- Parameters
z
: Thecomplex
to copy from.
-
template<typename U>__host__ THRUST_STD_COMPLEX_DEVICE complex& thrust::complex::operator=(const std::complex< U > & z)
Assign
z.real()
andz.imag()
to the real and imaginary parts of thiscomplex
respectively.- Parameters
z
: Thecomplex
to copy from.
- Template Parameters
U
: is convertible tovalue_type
.
-
template<typename U>__host__ __device__ complex<T>& thrust::complex::operator+=(const complex < U > & z)
Adds a
complex
to thiscomplex
and assigns the result to thiscomplex
.- Parameters
z
: Thecomplex
to be added.
- Template Parameters
U
: is convertible tovalue_type
.
-
template<typename U>__host__ __device__ complex<T>& thrust::complex::operator-=(const complex < U > & z)
Subtracts a
complex
from thiscomplex
and assigns the result to thiscomplex
.- Parameters
z
: Thecomplex
to be subtracted.
- Template Parameters
U
: is convertible tovalue_type
.
-
template<typename U>__host__ __device__ complex<T>& thrust::complex::operator*=(const complex < U > & z)
Multiplies this
complex
by anothercomplex
and assigns the result to thiscomplex
.- Parameters
z
: Thecomplex
to be multiplied.
- Template Parameters
U
: is convertible tovalue_type
.
-
template<typename U>__host__ __device__ complex<T>& thrust::complex::operator/=(const complex < U > & z)
Divides this
complex
by anothercomplex
and assigns the result to thiscomplex
.- Parameters
z
: Thecomplex
to be divided.
- Template Parameters
U
: is convertible tovalue_type
.
-
template<typename U>__host__ __device__ complex<T>& thrust::complex::operator+=(const U & z)
Adds a scalar to this
complex
and assigns the result to thiscomplex
.- Parameters
z
: Thecomplex
to be added.
- Template Parameters
U
: is convertible tovalue_type
.
-
template<typename U>__host__ __device__ complex<T>& thrust::complex::operator-=(const U & z)
Subtracts a scalar from this
complex
and assigns the result to thiscomplex
.- Parameters
z
: The scalar to be subtracted.
- Template Parameters
U
: is convertible tovalue_type
.
-
template<typename U>__host__ __device__ complex<T>& thrust::complex::operator*=(const U & z)
Multiplies this
complex
by a scalar and assigns the result to thiscomplex
.- Parameters
z
: The scalar to be multiplied.
- Template Parameters
U
: is convertible tovalue_type
.
-
template<typename U>__host__ __device__ complex<T>& thrust::complex::operator/=(const U & z)
Divides this
complex
by a scalar and assigns the result to thiscomplex
.- Parameters
z
: The scalar to be divided.
- Template Parameters
U
: is convertible tovalue_type
.
-
__host__ __device__ T thrust::complex::real() const volatile
Returns the real part of this
complex
.
-
__host__ __device__ T thrust::complex::imag() const volatile
Returns the imaginary part of this
complex
.
-
__host__ __device__ T thrust::complex::real() const
Returns the real part of this
complex
.
-
__host__ __device__ T thrust::complex::imag() const
Returns the imaginary part of this
complex
.
-
__host__ __device__ void thrust::complex::real(T re) volatile
Sets the real part of this
complex
.- Parameters
re
: The new real part of thiscomplex
.
-
__host__ __device__ void thrust::complex::imag(T im) volatile
Sets the imaginary part of this
complex
.- Parameters
im
: The new imaginary part of thiscomplex.e
-
__host__ __device__ void thrust::complex::real(T re)
Sets the real part of this
complex
.- Parameters
re
: The new real part of thiscomplex
.
-
__host__ __device__ void thrust::complex::imag(T im)
Sets the imaginary part of this
complex
.- Parameters
im
: The new imaginary part of thiscomplex
.
-
__host__ __device__ thrust::complex::operator std::complex< T >() const
Casts this
complex
to astd::complex
of the same type.