complex¶
Defined in header <Kokkos_Complex.hpp> which is included from <Kokkos_Core.hpp>
Description¶
complex is a class template for representing and manipulating complex numbers.
This is intended as a replacement for
std::complex<T>.Note: If
zhas typeKokkos::complex<T>, casting such asreinterpret_cast<T(&)[2]>(z)leads to undefined behavior (this differs fromstd::complex).
Interface¶
- 
template<class T>
class complex¶ - Template Parameters:
 T – The type of the real and imaginary components.
Tmust be a floating point type (float,double,long double) or an extended floating point type.Tcannot beconstand/orvolatilequalified.Some types might not work with a specific backend (such as
long doubleon CUDA or SYCL).
Public Types:
Constructors & Assignment Operators:
- 
complex()¶
 Default constructor zero initializes the real and imaginary components.
- 
template<class U>
complex(complex<U> z) noexcept¶ Conversion constructor initializes the real component to
static_cast<T>(z.real())and the imaginary component tostatic_cast<T>(z.imag()).Constraints:
Uis convertible toT.
- 
complex &operator=(std::complex<T> z) noexcept¶
 Implicit conversion from
std::complexinitializes the real component toz.real()and the imaginary component toz.imag().
- 
constexpr complex &operator=(T r) noexcept¶
 Initializes the real component to
rand zero initializes the imaginary component.
- 
constexpr complex(T r, T i) noexcept¶
 Initializes the real component to
rand the imaginary component toi.
- 
volatile complex &operator=(volatile const complex&) volatile noexcept¶
 Deprecated since version 4.0.0.
- 
void operator=(const T&) volatile noexcept¶
 Deprecated since version 4.0.0.
Note
Some of the deprecated assignment operators have templated implementations so as not to be copy assignment operators.
Public Member Functions:
- 
constexpr complex &operator+=(T v) noexcept¶
 Adds the complex value
complex(v)to the complex value*thisand stores the sum in*this.
- 
constexpr complex &operator-=(T v) noexcept¶
 Subtracts the complex value
complex(v)from the complex value*thisand stores the difference in*this.
- 
constexpr complex &operator*=(T v) noexcept¶
 Multiplies the complex value
complex(v)by the complex value*thisand stores the product in*this.
- 
constexpr complex &operator/=(T v) noexcept¶
 Divides the complex value
complex(v)into the complex value*thisand stores the quotient in*this.
- 
void operator/=(volatile const complex &v) volatile noexcept(noexcept(T{} / T{}))¶
 Deprecated since version 4.0.0.
- 
void operator/=(volatile const T &v) volatile noexcept(noexcept(T{} / T{}))¶
 Deprecated since version 4.0.0.
Non-Member Functions:
- 
template<typename T1, typename T2>
bool operator==(std::complex<T1> x, complex<T2> y) noexcept¶ - Returns:
 trueif and only if the real component ofcomplex(x)equals the real component ofcomplex(y)and the imaginary component ofcomplex(x)equals the imaginary component ofcomplex(y).
- 
template<typename T1, typename T2>
bool operator!=(std::complex<T1> x, complex<T2> y) noexcept¶ - Returns:
 !(x == y)
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator+(complex<T1> x, complex<T2> y) noexcept¶ 
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator+(complex<T1> x, T2 y) noexcept¶ 
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator+(T1 x, complex<T2> y) noexcept¶ - Returns:
 The complex value
complex(x)added to the complex valuecomplex(y).
- 
template<typename T>
complex<T> operator-(complex<T> x) noexcept¶ - Returns:
 complex(-x.real(), -x.imag())
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator-(complex<T1> x, complex<T2> y) noexcept¶ 
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator-(complex<T1> x, T2 y) noexcept¶ 
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator-(T1 x, complex<T2> y) noexcept¶ - Returns:
 The complex value
complex(y)subtracted from the complex valuecomplex(x).
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator*(complex<T1> x, complex<T2> y) noexcept¶ 
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator*(complex<T1> x, T2 y) noexcept¶ 
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator*(T1 x, complex<T2> y) noexcept¶ 
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator*(std::complex<T1> x, complex<T2> y) noexcept¶ - Returns:
 The complex value
complex(x)multiplied by the complex valuecomplex(y).
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator/(complex<T1> x, complex<T2> y) noexcept¶ 
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator/(complex<T1> x, T2 y) noexcept¶ 
- 
template<typename T1, typename T2>
complex<std::common_type_t<T1, T2>> operator/(T1 x, complex<T2> y) noexcept¶ - Returns:
 The complex value
complex(y)divided into the complex valuecomplex(x).
- 
template<typename T>
std::istream &operator>>(std::ostream &i, complex<T> &x)¶ Extracts a complex number x of the form:
u,(u)or(u,v)whereuis the real part andvis the imaginary part and returnsi.
- 
template<typename T>
std::ostream &operator<<(std::ostream &o, complex<T> x)¶ - Returns:
 o << std::complex(x)
- 
template<typenmame T>
complex<T> polar(T rho, T theta = T())¶ - Returns:
 The
complexvalue corresponding to a complex number whose magnitude isrhoand whose phase angle istheta.
- 
template<typename T1, typename T2>
complex<U> pow(T1 x, complex<T2> y)¶ - Returns:
 The complex power of base
xraised to they-th power, defined asexp(y * log(x)).UisfloatifT1andT2arefloat; otherwiseUislong doubleifT1orT2islong double; otherwiseUisdouble.
- 
template<typename T>
complex<T> sqrt(complex<T> x)¶ - Returns:
 The complex square root of
x, in the range of the right half-plane.
- 
template<typename T>
complex<T> exp(std::complex<T> x)¶ - Returns:
 The complex base-e exponential of
complex(x).
- 
template<typename T>
complex<T> log(complex<T> x)¶ - Returns:
 The complex natural (base-e) logarithm of x.
- 
template<typename T>
complex<T> log10(complex<T> x)¶ - Returns:
 The complex common (base-10) logarithm of
x, defined aslog(x) / log(10).
- 
template<typename T>
complex<T> acosh(complex<T> x)¶ - Returns:
 The complex arc hyperbolic cosine of
x.