16#ifndef KOKKOS_COMPLEX_HPP
17#define KOKKOS_COMPLEX_HPP
18#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
19#define KOKKOS_IMPL_PUBLIC_INCLUDE
20#define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_COMPLEX
24#include <Kokkos_MathematicalFunctions.hpp>
25#include <Kokkos_NumericTraits.hpp>
26#include <Kokkos_ReductionIdentity.hpp>
27#include <impl/Kokkos_Error.hpp>
42template <
class RealType>
44#ifdef KOKKOS_ENABLE_COMPLEX_ALIGN
48 static_assert(std::is_floating_point_v<RealType> &&
49 std::is_same_v<RealType, std::remove_cv_t<RealType>>,
50 "Kokkos::complex can only be instantiated for a cv-unqualified "
51 "floating point type");
62 KOKKOS_DEFAULTED_FUNCTION
66 KOKKOS_DEFAULTED_FUNCTION
69 KOKKOS_DEFAULTED_FUNCTION
73 template <
class RType,
74 std::enable_if_t<std::is_convertible_v<RType, RealType>,
int> = 0>
86 KOKKOS_INLINE_FUNCTION
87 complex(
const std::complex<RealType>& src)
noexcept
94 : re_(
reinterpret_cast<const RealType (&)[2]
>(src)[0]),
95 im_(
reinterpret_cast<const RealType (&)[2]
>(src)[1]) {}
104 return std::complex<RealType>(re_, im_);
110 : re_(val), im_(
static_cast<RealType>(0)) {}
113 KOKKOS_INLINE_FUNCTION
134 KOKKOS_INLINE_FUNCTION
138 KOKKOS_INLINE_FUNCTION
142 KOKKOS_INLINE_FUNCTION
146 KOKKOS_INLINE_FUNCTION
150 KOKKOS_INLINE_FUNCTION
154 KOKKOS_INLINE_FUNCTION
157 constexpr KOKKOS_INLINE_FUNCTION
complex& operator+=(
164 constexpr KOKKOS_INLINE_FUNCTION complex& operator+=(
165 const RealType& src)
noexcept {
170 constexpr KOKKOS_INLINE_FUNCTION complex& operator-=(
171 const complex<RealType>& src)
noexcept {
177 constexpr KOKKOS_INLINE_FUNCTION complex& operator-=(
178 const RealType& src)
noexcept {
183 constexpr KOKKOS_INLINE_FUNCTION complex& operator*=(
184 const complex<RealType>& src)
noexcept {
185 const RealType realPart = re_ * src.re_ - im_ * src.im_;
186 const RealType imagPart = re_ * src.im_ + im_ * src.re_;
192 constexpr KOKKOS_INLINE_FUNCTION complex& operator*=(
193 const RealType& src)
noexcept {
200 constexpr KOKKOS_INLINE_FUNCTION complex& operator/=(
201 const complex<RealType>& y)
noexcept(
noexcept(RealType{} / RealType{})) {
205 const RealType s = fabs(y.real()) + fabs(y.imag());
211 if (s == RealType(0)) {
215 const complex x_scaled(this->re_ / s, this->im_ / s);
216 const complex y_conj_scaled(y.re_ / s, -(y.im_) / s);
217 const RealType y_scaled_abs =
218 y_conj_scaled.re_ * y_conj_scaled.re_ +
219 y_conj_scaled.im_ * y_conj_scaled.im_;
220 *
this = x_scaled * y_conj_scaled;
221 *
this /= y_scaled_abs;
226 constexpr KOKKOS_INLINE_FUNCTION complex& operator/=(
227 const std::complex<RealType>& y)
noexcept(
noexcept(RealType{} /
232 const RealType s = fabs(y.real()) + fabs(y.imag());
237 if (s == RealType(0)) {
241 const complex x_scaled(this->re_ / s, this->im_ / s);
242 const complex y_conj_scaled(y.re_ / s, -(y.im_) / s);
243 const RealType y_scaled_abs =
244 y_conj_scaled.re_ * y_conj_scaled.re_ +
245 y_conj_scaled.im_ * y_conj_scaled.im_;
246 *
this = x_scaled * y_conj_scaled;
247 *
this /= y_scaled_abs;
252 constexpr KOKKOS_INLINE_FUNCTION complex& operator/=(
253 const RealType& src)
noexcept(
noexcept(RealType{} / RealType{})) {
259 template <
size_t I,
typename RT>
260 friend constexpr const RT& get(
const complex<RT>&)
noexcept;
262 template <
size_t I,
typename RT>
263 friend constexpr const RT&& get(
const complex<RT>&&) noexcept;
265#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
267 template <
class RType,
268 std::enable_if_t<std::is_convertible_v<RType, RealType>,
int> = 0>
269 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION
270 complex(
const volatile complex<RType>& src)
noexcept
274 : re_(src.re_), im_(src.im_) {}
296 template <
class Complex,
297 std::enable_if_t<std::is_same_v<Complex, complex>,
int> = 0>
298 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION
void operator=(
299 const Complex& src)
volatile noexcept {
319 template <
class Complex,
320 std::enable_if_t<std::is_same_v<Complex, complex>,
int> = 0>
321 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION
volatile complex& operator=(
322 const volatile Complex& src)
volatile noexcept {
341 template <
class Complex,
342 std::enable_if_t<std::is_same_v<Complex, complex>,
int> = 0>
343 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION complex& operator=(
344 const volatile Complex& src)
noexcept {
354 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION
void operator=(
355 const volatile RealType& val)
noexcept {
363 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION complex& operator=(
364 const RealType& val)
volatile noexcept {
372 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION complex& operator=(
373 const volatile RealType& val)
volatile noexcept {
380 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION
volatile RealType&
381 imag() volatile noexcept {
386 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION
volatile RealType&
387 real() volatile noexcept {
392 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION RealType imag() const
398 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION RealType real() const
403 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION
void operator+=(
404 const volatile complex<RealType>& src)
volatile noexcept {
409 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION
void operator+=(
410 const volatile RealType& src)
volatile noexcept {
414 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION
void operator*=(
415 const volatile complex<RealType>& src)
volatile noexcept {
416 const RealType realPart = re_ * src.re_ - im_ * src.im_;
417 const RealType imagPart = re_ * src.im_ + im_ * src.re_;
423 KOKKOS_DEPRECATED KOKKOS_INLINE_FUNCTION
void operator*=(
424 const volatile RealType& src)
volatile noexcept {
436template <
typename RealType>
437struct std::tuple_size<Kokkos::complex<RealType>>
438 : std::integral_constant<size_t, 2> {};
440template <
size_t I,
typename RealType>
441struct std::tuple_element<I, Kokkos::complex<RealType>> {
442 static_assert(I < 2);
443 using type = RealType;
450template <
size_t I,
typename RealType>
451KOKKOS_FUNCTION
constexpr RealType& get(complex<RealType>& z)
noexcept {
452 static_assert(I < 2);
453 if constexpr (I == 0)
457#ifdef KOKKOS_COMPILER_INTEL
458 __builtin_unreachable();
462template <
size_t I,
typename RealType>
463KOKKOS_FUNCTION
constexpr RealType&& get(complex<RealType>&& z)
noexcept {
464 static_assert(I < 2);
465 if constexpr (I == 0)
466 return std::move(z.real());
468 return std::move(z.imag());
469#ifdef KOKKOS_COMPILER_INTEL
470 __builtin_unreachable();
474template <
size_t I,
typename RealType>
475KOKKOS_FUNCTION
constexpr const RealType& get(
476 const complex<RealType>& z)
noexcept {
477 static_assert(I < 2);
478 if constexpr (I == 0)
482#ifdef KOKKOS_COMPILER_INTEL
483 __builtin_unreachable();
487template <
size_t I,
typename RealType>
488KOKKOS_FUNCTION
constexpr const RealType&& get(
489 const complex<RealType>&& z)
noexcept {
490 static_assert(I < 2);
491 if constexpr (I == 0)
492 return std::move(z.re_);
494 return std::move(z.im_);
495#ifdef KOKKOS_COMPILER_INTEL
496 __builtin_unreachable();
508template <
class RealType1,
class RealType2>
509KOKKOS_INLINE_FUNCTION
bool operator==(complex<RealType1>
const& x,
510 complex<RealType2>
const& y)
noexcept {
511 using common_type = std::common_type_t<RealType1, RealType2>;
512 return common_type(x.real()) == common_type(y.real()) &&
513 common_type(x.imag()) == common_type(y.imag());
519template <
class RealType1,
class RealType2>
520inline bool operator==(std::complex<RealType1>
const& x,
521 complex<RealType2>
const& y)
noexcept {
522 using common_type = std::common_type_t<RealType1, RealType2>;
523 return common_type(x.real()) == common_type(y.real()) &&
524 common_type(x.imag()) == common_type(y.imag());
528template <
class RealType1,
class RealType2>
529inline bool operator==(complex<RealType1>
const& x,
530 std::complex<RealType2>
const& y)
noexcept {
531 using common_type = std::common_type_t<RealType1, RealType2>;
532 return common_type(x.real()) == common_type(y.real()) &&
533 common_type(x.imag()) == common_type(y.imag());
538 class RealType1,
class RealType2,
540 std::enable_if_t<std::is_convertible_v<RealType2, RealType1>,
int> = 0>
541KOKKOS_INLINE_FUNCTION
bool operator==(complex<RealType1>
const& x,
542 RealType2
const& y)
noexcept {
543 using common_type = std::common_type_t<RealType1, RealType2>;
544 return common_type(x.real()) == common_type(y) &&
545 common_type(x.imag()) == common_type(0);
550 class RealType1,
class RealType2,
552 std::enable_if_t<std::is_convertible_v<RealType1, RealType2>,
int> = 0>
553KOKKOS_INLINE_FUNCTION
bool operator==(RealType1
const& x,
554 complex<RealType2>
const& y)
noexcept {
555 using common_type = std::common_type_t<RealType1, RealType2>;
556 return common_type(x) == common_type(y.real()) &&
557 common_type(0) == common_type(y.imag());
561template <
class RealType1,
class RealType2>
562KOKKOS_INLINE_FUNCTION
bool operator!=(complex<RealType1>
const& x,
563 complex<RealType2>
const& y)
noexcept {
564 using common_type = std::common_type_t<RealType1, RealType2>;
565 return common_type(x.real()) != common_type(y.real()) ||
566 common_type(x.imag()) != common_type(y.imag());
570template <
class RealType1,
class RealType2>
571inline bool operator!=(std::complex<RealType1>
const& x,
572 complex<RealType2>
const& y)
noexcept {
573 using common_type = std::common_type_t<RealType1, RealType2>;
574 return common_type(x.real()) != common_type(y.real()) ||
575 common_type(x.imag()) != common_type(y.imag());
579template <
class RealType1,
class RealType2>
580inline bool operator!=(complex<RealType1>
const& x,
581 std::complex<RealType2>
const& y)
noexcept {
582 using common_type = std::common_type_t<RealType1, RealType2>;
583 return common_type(x.real()) != common_type(y.real()) ||
584 common_type(x.imag()) != common_type(y.imag());
589 class RealType1,
class RealType2,
591 std::enable_if_t<std::is_convertible_v<RealType2, RealType1>,
int> = 0>
592KOKKOS_INLINE_FUNCTION
bool operator!=(complex<RealType1>
const& x,
593 RealType2
const& y)
noexcept {
594 using common_type = std::common_type_t<RealType1, RealType2>;
595 return common_type(x.real()) != common_type(y) ||
596 common_type(x.imag()) != common_type(0);
601 class RealType1,
class RealType2,
603 std::enable_if_t<std::is_convertible_v<RealType1, RealType2>,
int> = 0>
604KOKKOS_INLINE_FUNCTION
bool operator!=(RealType1
const& x,
605 complex<RealType2>
const& y)
noexcept {
606 using common_type = std::common_type_t<RealType1, RealType2>;
607 return common_type(x) != common_type(y.real()) ||
608 common_type(0) != common_type(y.imag());
615template <
class RealType1,
class RealType2>
616KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
617operator+(
const complex<RealType1>& x,
const complex<RealType2>& y)
noexcept {
618 return complex<std::common_type_t<RealType1, RealType2>>(x.real() + y.real(),
619 x.imag() + y.imag());
623template <
class RealType1,
class RealType2>
624KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
625operator+(
const complex<RealType1>& x,
const RealType2& y)
noexcept {
626 return complex<std::common_type_t<RealType1, RealType2>>(x.real() + y,
631template <
class RealType1,
class RealType2>
632KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
633operator+(
const RealType1& x,
const complex<RealType2>& y)
noexcept {
634 return complex<std::common_type_t<RealType1, RealType2>>(x + y.real(),
639template <
class RealType>
640KOKKOS_INLINE_FUNCTION complex<RealType> operator+(
641 const complex<RealType>& x)
noexcept {
642 return complex<RealType>{+x.real(), +x.imag()};
646template <
class RealType1,
class RealType2>
647KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
648operator-(
const complex<RealType1>& x,
const complex<RealType2>& y)
noexcept {
649 return complex<std::common_type_t<RealType1, RealType2>>(x.real() - y.real(),
650 x.imag() - y.imag());
654template <
class RealType1,
class RealType2>
655KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
656operator-(
const complex<RealType1>& x,
const RealType2& y)
noexcept {
657 return complex<std::common_type_t<RealType1, RealType2>>(x.real() - y,
662template <
class RealType1,
class RealType2>
663KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
664operator-(
const RealType1& x,
const complex<RealType2>& y)
noexcept {
665 return complex<std::common_type_t<RealType1, RealType2>>(x - y.real(),
670template <
class RealType>
671KOKKOS_INLINE_FUNCTION complex<RealType> operator-(
672 const complex<RealType>& x)
noexcept {
673 return complex<RealType>(-x.real(), -x.imag());
677template <
class RealType1,
class RealType2>
678KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
679operator*(
const complex<RealType1>& x,
const complex<RealType2>& y)
noexcept {
680 return complex<std::common_type_t<RealType1, RealType2>>(
681 x.real() * y.real() - x.imag() * y.imag(),
682 x.real() * y.imag() + x.imag() * y.real());
693template <
class RealType1,
class RealType2>
694inline complex<std::common_type_t<RealType1, RealType2>> operator*(
695 const std::complex<RealType1>& x,
const complex<RealType2>& y) {
696 return complex<std::common_type_t<RealType1, RealType2>>(
697 x.real() * y.real() - x.imag() * y.imag(),
698 x.real() * y.imag() + x.imag() * y.real());
705template <
class RealType1,
class RealType2>
706KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
707operator*(
const RealType1& x,
const complex<RealType2>& y)
noexcept {
708 return complex<std::common_type_t<RealType1, RealType2>>(x * y.real(),
716template <
class RealType1,
class RealType2>
717KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
718operator*(
const complex<RealType1>& y,
const RealType2& x)
noexcept {
719 return complex<std::common_type_t<RealType1, RealType2>>(x * y.real(),
724template <
class RealType>
725KOKKOS_INLINE_FUNCTION RealType imag(
const complex<RealType>& x)
noexcept {
729template <
class ArithmeticType>
730KOKKOS_INLINE_FUNCTION
constexpr Impl::promote_t<ArithmeticType> imag(
732 return ArithmeticType();
736template <
class RealType>
737KOKKOS_INLINE_FUNCTION RealType real(
const complex<RealType>& x)
noexcept {
741template <
class ArithmeticType>
742KOKKOS_INLINE_FUNCTION
constexpr Impl::promote_t<ArithmeticType> real(
749KOKKOS_INLINE_FUNCTION complex<T> polar(
const T& r,
const T& theta = T()) {
750 KOKKOS_EXPECTS(r >= 0);
751 return complex<T>(r * cos(theta), r * sin(theta));
755template <
class RealType>
756KOKKOS_INLINE_FUNCTION RealType abs(
const complex<RealType>& x) {
757 return hypot(x.real(), x.imag());
762KOKKOS_INLINE_FUNCTION complex<T> pow(
const complex<T>& x,
const T& y) {
764 T theta = atan2(x.imag(), x.real());
765 return polar(pow(r, y), y * theta);
769KOKKOS_INLINE_FUNCTION complex<T> pow(
const T& x,
const complex<T>& y) {
770 return pow(complex<T>(x), y);
774KOKKOS_INLINE_FUNCTION complex<T> pow(
const complex<T>& x,
775 const complex<T>& y) {
776 return x == T() ? T() : exp(y * log(x));
779template <
class T,
class U,
class = std::enable_if_t<std::is_arithmetic_v<T>>>
780KOKKOS_INLINE_FUNCTION complex<Impl::promote_2_t<T, U>> pow(
781 const T& x,
const complex<U>& y) {
782 using type = Impl::promote_2_t<T, U>;
783 return pow(type(x), complex<type>(y));
786template <
class T,
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
787KOKKOS_INLINE_FUNCTION complex<Impl::promote_2_t<T, U>> pow(
const complex<T>& x,
789 using type = Impl::promote_2_t<T, U>;
790 return pow(complex<type>(x), type(y));
793template <
class T,
class U>
794KOKKOS_INLINE_FUNCTION complex<Impl::promote_2_t<T, U>> pow(
795 const complex<T>& x,
const complex<U>& y) {
796 using type = Impl::promote_2_t<T, U>;
797 return pow(complex<type>(x), complex<type>(y));
802template <
class RealType>
804 const complex<RealType>& x) {
805 RealType r = x.real();
806 RealType i = x.imag();
808 if (r == RealType()) {
809 RealType t = sqrt(fabs(i) / 2);
812 RealType t = sqrt(2 * (abs(x) + fabs(r)));
815 : Kokkos::complex<RealType>(fabs(i) / t,
816 i < RealType() ? -u : u);
821template <
class RealType>
822KOKKOS_INLINE_FUNCTION complex<RealType> conj(
823 const complex<RealType>& x)
noexcept {
824 return complex<RealType>(real(x), -imag(x));
827template <
class ArithmeticType>
828KOKKOS_INLINE_FUNCTION
constexpr complex<Impl::promote_t<ArithmeticType>> conj(
830 using type = Impl::promote_t<ArithmeticType>;
831 return complex<type>(x, -type());
835template <
class RealType>
836KOKKOS_INLINE_FUNCTION complex<RealType> exp(
const complex<RealType>& x) {
837 return exp(x.real()) * complex<RealType>(cos(x.imag()), sin(x.imag()));
841template <
class RealType>
843 const complex<RealType>& x) {
844 RealType phi = atan2(x.imag(), x.real());
849template <
class RealType>
851 const complex<RealType>& x) {
852 return log(x) / log(RealType(10));
856template <
class RealType>
858 const complex<RealType>& x) {
860 cos(x.real()) * sinh(x.imag()));
864template <
class RealType>
866 const complex<RealType>& x) {
868 -sin(x.real()) * sinh(x.imag()));
872template <
class RealType>
874 const complex<RealType>& x) {
875 return sin(x) / cos(x);
879template <
class RealType>
881 const complex<RealType>& x) {
883 cosh(x.real()) * sin(x.imag()));
887template <
class RealType>
889 const complex<RealType>& x) {
891 sinh(x.real()) * sin(x.imag()));
895template <
class RealType>
897 const complex<RealType>& x) {
898 return sinh(x) / cosh(x);
902template <
class RealType>
904 const complex<RealType>& x) {
905 return log(x + sqrt(x * x + RealType(1.0)));
909template <
class RealType>
911 const complex<RealType>& x) {
912 return RealType(2.0) * log(sqrt(RealType(0.5) * (x + RealType(1.0))) +
913 sqrt(RealType(0.5) * (x - RealType(1.0))));
917template <
class RealType>
919 const complex<RealType>& x) {
920 const RealType i2 = x.imag() * x.imag();
921 const RealType r = RealType(1.0) - i2 - x.real() * x.real();
923 RealType p = RealType(1.0) + x.real();
924 RealType m = RealType(1.0) - x.real();
929 RealType phi = atan2(RealType(2.0) * x.imag(), r);
931 RealType(0.5) * phi);
935template <
class RealType>
937 const complex<RealType>& x) {
944template <
class RealType>
946 const complex<RealType>& x) {
948 RealType pi_2 = acos(RealType(0.0));
953template <
class RealType>
955 const complex<RealType>& x) {
956 const RealType r2 = x.real() * x.real();
957 const RealType i = RealType(1.0) - r2 - x.imag() * x.imag();
959 RealType p = x.imag() + RealType(1.0);
960 RealType m = x.imag() - RealType(1.0);
966 RealType(0.5) * atan2(RealType(2.0) * x.real(), i),
967 RealType(0.25) * log(p / m));
973template <
class RealType>
974inline complex<RealType> exp(
const std::complex<RealType>& c) {
975 return complex<RealType>(std::exp(c.real()) * std::cos(c.imag()),
976 std::exp(c.real()) * std::sin(c.imag()));
980template <
class RealType1,
class RealType2>
981KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
982operator/(
const complex<RealType1>& x,
983 const RealType2& y)
noexcept(
noexcept(RealType1{} / RealType2{})) {
984 return complex<std::common_type_t<RealType1, RealType2>>(real(x) / y,
989template <
class RealType1,
class RealType2>
990KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
991operator/(
const complex<RealType1>& x,
992 const complex<RealType2>& y)
noexcept(
noexcept(RealType1{} /
997 using common_real_type = std::common_type_t<RealType1, RealType2>;
998 const common_real_type s = fabs(real(y)) + fabs(imag(y));
1004 return complex<common_real_type>(real(x) / s, imag(x) / s);
1006 const complex<common_real_type> x_scaled(real(x) / s, imag(x) / s);
1007 const complex<common_real_type> y_conj_scaled(real(y) / s, -imag(y) / s);
1008 const RealType1 y_scaled_abs =
1009 real(y_conj_scaled) * real(y_conj_scaled) +
1010 imag(y_conj_scaled) * imag(y_conj_scaled);
1011 complex<common_real_type> result = x_scaled * y_conj_scaled;
1012 result /= y_scaled_abs;
1018template <
class RealType1,
class RealType2>
1019KOKKOS_INLINE_FUNCTION complex<std::common_type_t<RealType1, RealType2>>
1020operator/(
const RealType1& x,
1021 const complex<RealType2>& y)
noexcept(
noexcept(RealType1{} /
1023 return complex<std::common_type_t<RealType1, RealType2>>(x) / y;
1026template <
class RealType>
1027std::ostream& operator<<(std::ostream& os,
const complex<RealType>& x) {
1028 const std::complex<RealType> x_std(Kokkos::real(x), Kokkos::imag(x));
1033template <
class RealType>
1034std::istream& operator>>(std::istream& is, complex<RealType>& x) {
1035 std::complex<RealType> x_std;
1042struct reduction_identity<Kokkos::complex<T>> {
1043 using t_red_ident = reduction_identity<T>;
1056#ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_COMPLEX
1057#undef KOKKOS_IMPL_PUBLIC_INCLUDE
1058#undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_COMPLEX
A thread safe view to a bitset.
Partial reimplementation of std::complex that works as the result of a Kokkos::parallel_reduce.
KOKKOS_INLINE_FUNCTION constexpr RealType imag() const noexcept
The imaginary part of this complex number.
KOKKOS_INLINE_FUNCTION constexpr RealType & real() noexcept
The real part of this complex number.
complex & operator=(const std::complex< RealType > &src) noexcept
Assignment operator from std::complex.
KOKKOS_DEFAULTED_FUNCTION complex(const complex &) noexcept=default
Copy constructor.
KOKKOS_INLINE_FUNCTION constexpr void real(RealType v) noexcept
Set the real part of this complex number.
KOKKOS_INLINE_FUNCTION complex(const RealType &re, const RealType &im) noexcept
Constructor that takes the real and imaginary parts.
KOKKOS_INLINE_FUNCTION constexpr RealType & imag() noexcept
The imaginary part of this complex number.
KOKKOS_INLINE_FUNCTION constexpr RealType real() const noexcept
The real part of this complex number.
KOKKOS_INLINE_FUNCTION complex & operator=(const RealType &val) noexcept
Assignment operator (from a real number).
KOKKOS_INLINE_FUNCTION constexpr void imag(RealType v) noexcept
Set the imaginary part of this complex number.
KOKKOS_DEFAULTED_FUNCTION complex()=default
Default constructor (initializes both real and imaginary parts to zero).
KOKKOS_INLINE_FUNCTION complex(const RealType &val) noexcept
Constructor that takes just the real part, and sets the imaginary part to zero.
KOKKOS_INLINE_FUNCTION complex(const std::complex< RealType > &src) noexcept
Conversion constructor from std::complex.
KOKKOS_INLINE_FUNCTION complex(const complex< RType > &other) noexcept
Conversion constructor from compatible RType.