44 #ifndef KOKKOS_COMPLEX_HPP 45 #define KOKKOS_COMPLEX_HPP 48 #include <Kokkos_MathematicalFunctions.hpp> 49 #include <Kokkos_NumericTraits.hpp> 50 #include <impl/Kokkos_Error.hpp> 52 #include <type_traits> 64 template <
class RealType>
66 #ifdef KOKKOS_ENABLE_COMPLEX_ALIGN 67 alignas(2 *
sizeof(RealType))
79 KOKKOS_DEFAULTED_FUNCTION
83 KOKKOS_DEFAULTED_FUNCTION
86 KOKKOS_DEFAULTED_FUNCTION
90 template <class RType,
91 typename std::enable_if<std::is_convertible<RType, RealType>::value,
97 : re_(other.real()), im_(other.imag()) {}
104 KOKKOS_INLINE_FUNCTION
105 complex(
const std::complex<RealType>& src) noexcept
112 : re_(
reinterpret_cast<const RealType (&)[2]
>(src)[0]),
113 im_(
reinterpret_cast<const RealType (&)[2]
>(src)[1]) {}
121 operator std::complex<RealType>()
const noexcept {
122 return std::complex<RealType>(re_, im_);
127 KOKKOS_INLINE_FUNCTION
complex(
const RealType& val) noexcept
128 : re_(val), im_(static_cast<RealType>(0)) {}
131 KOKKOS_INLINE_FUNCTION
132 complex(
const RealType& re,
const RealType& im) noexcept : re_(re), im_(im) {}
152 KOKKOS_INLINE_FUNCTION
153 KOKKOS_CONSTEXPR_14 RealType&
imag() noexcept {
return im_; }
156 KOKKOS_INLINE_FUNCTION
157 KOKKOS_CONSTEXPR_14 RealType&
real() noexcept {
return re_; }
160 KOKKOS_INLINE_FUNCTION
161 constexpr RealType
imag() const noexcept {
return im_; }
164 KOKKOS_INLINE_FUNCTION
165 constexpr RealType
real() const noexcept {
return re_; }
168 KOKKOS_INLINE_FUNCTION
170 void imag(RealType v) noexcept { im_ = v; }
173 KOKKOS_INLINE_FUNCTION
175 void real(RealType v) noexcept { re_ = v; }
177 KOKKOS_CONSTEXPR_14 KOKKOS_INLINE_FUNCTION
complex& operator+=(
184 KOKKOS_CONSTEXPR_14 KOKKOS_INLINE_FUNCTION complex& operator+=(
185 const RealType& src) noexcept {
190 KOKKOS_CONSTEXPR_14 KOKKOS_INLINE_FUNCTION complex& operator-=(
191 const complex<RealType>& src) noexcept {
197 KOKKOS_CONSTEXPR_14 KOKKOS_INLINE_FUNCTION complex& operator-=(
198 const RealType& src) noexcept {
203 KOKKOS_CONSTEXPR_14 KOKKOS_INLINE_FUNCTION complex& operator*=(
204 const complex<RealType>& src) noexcept {
205 const RealType realPart = re_ * src.re_ - im_ * src.im_;
206 const RealType imagPart = re_ * src.im_ + im_ * src.re_;
212 KOKKOS_CONSTEXPR_14 KOKKOS_INLINE_FUNCTION complex& operator*=(
213 const RealType& src) noexcept {
220 KOKKOS_CONSTEXPR_14 KOKKOS_INLINE_FUNCTION complex& operator/=(
221 const complex<RealType>& y) noexcept(noexcept(RealType{} / RealType{})) {
222 using Kokkos::Experimental::fabs;
226 const RealType s = fabs(y.real()) + fabs(y.imag());
232 if (s == RealType(0)) {
236 const complex x_scaled(this->re_ / s, this->im_ / s);
237 const complex y_conj_scaled(y.re_ / s, -(y.im_) / s);
238 const RealType y_scaled_abs =
239 y_conj_scaled.re_ * y_conj_scaled.re_ +
240 y_conj_scaled.im_ * y_conj_scaled.im_;
241 *
this = x_scaled * y_conj_scaled;
242 *
this /= y_scaled_abs;
248 KOKKOS_INLINE_FUNCTION complex& operator/=(
249 const std::complex<RealType>& y) noexcept(noexcept(RealType{} /
251 using Kokkos::Experimental::fabs;
255 const RealType s = fabs(y.real()) + fabs(y.imag());
260 if (s == RealType(0)) {
264 const complex x_scaled(this->re_ / s, this->im_ / s);
265 const complex y_conj_scaled(y.re_ / s, -(y.im_) / s);
266 const RealType y_scaled_abs =
267 y_conj_scaled.re_ * y_conj_scaled.re_ +
268 y_conj_scaled.im_ * y_conj_scaled.im_;
269 *
this = x_scaled * y_conj_scaled;
270 *
this /= y_scaled_abs;
275 KOKKOS_CONSTEXPR_14 KOKKOS_INLINE_FUNCTION complex& operator/=(
276 const RealType& src) noexcept(noexcept(RealType{} / RealType{})) {
288 template <
class RType,
289 typename std::enable_if<std::is_convertible<RType, RealType>::value,
295 : re_(src.re_), im_(src.im_) {}
317 template <
class Complex,
318 typename std::enable_if<std::is_same<Complex, complex>::value,
320 KOKKOS_INLINE_FUNCTION
void operator=(
const Complex& src)
volatile noexcept {
340 template <
class Complex,
341 typename std::enable_if<std::is_same<Complex, complex>::value,
344 const volatile Complex& src)
volatile noexcept {
363 template <
class Complex,
364 typename std::enable_if<std::is_same<Complex, complex>::value,
367 const volatile Complex& src) noexcept {
377 KOKKOS_INLINE_FUNCTION
void operator=(
const volatile RealType& val) noexcept {
386 const RealType& val)
volatile noexcept {
395 const volatile RealType& val)
volatile noexcept {
402 KOKKOS_INLINE_FUNCTION
403 volatile RealType&
imag() volatile noexcept {
return im_; }
406 KOKKOS_INLINE_FUNCTION
407 volatile RealType&
real() volatile noexcept {
return re_; }
410 KOKKOS_INLINE_FUNCTION
411 RealType
imag() const volatile noexcept {
return im_; }
414 KOKKOS_INLINE_FUNCTION
415 RealType
real() const volatile noexcept {
return re_; }
417 KOKKOS_INLINE_FUNCTION
void operator+=(
423 KOKKOS_INLINE_FUNCTION
void operator+=(
424 const volatile RealType& src)
volatile noexcept {
428 KOKKOS_INLINE_FUNCTION
void operator*=(
429 const volatile complex<RealType>& src)
volatile noexcept {
430 const RealType realPart = re_ * src.re_ - im_ * src.im_;
431 const RealType imagPart = re_ * src.im_ + im_ * src.re_;
437 KOKKOS_INLINE_FUNCTION
void operator*=(
438 const volatile RealType& src)
volatile noexcept {
454 template <
class RealType1,
class RealType2>
455 KOKKOS_INLINE_FUNCTION
bool operator==(complex<RealType1>
const& x,
456 complex<RealType2>
const& y) noexcept {
457 using common_type =
typename std::common_type<RealType1, RealType2>::type;
458 return common_type(x.real()) == common_type(y.real()) &&
459 common_type(x.imag()) == common_type(y.imag());
465 template <
class RealType1,
class RealType2>
466 inline bool operator==(std::complex<RealType1>
const& x,
467 complex<RealType2>
const& y) noexcept {
468 using common_type =
typename std::common_type<RealType1, RealType2>::type;
469 return common_type(x.real()) == common_type(y.real()) &&
470 common_type(x.imag()) == common_type(y.imag());
474 template <
class RealType1,
class RealType2>
475 inline bool operator==(complex<RealType1>
const& x,
476 std::complex<RealType2>
const& y) noexcept {
477 using common_type =
typename std::common_type<RealType1, RealType2>::type;
478 return common_type(x.real()) == common_type(y.real()) &&
479 common_type(x.imag()) == common_type(y.imag());
484 class RealType1,
class RealType2,
486 typename std::enable_if<std::is_convertible<RealType2, RealType1>::value,
488 KOKKOS_INLINE_FUNCTION
bool operator==(complex<RealType1>
const& x,
489 RealType2
const& y) noexcept {
490 using common_type =
typename std::common_type<RealType1, RealType2>::type;
491 return common_type(x.real()) == common_type(y) &&
492 common_type(x.imag()) == common_type(0);
497 class RealType1,
class RealType2,
499 typename std::enable_if<std::is_convertible<RealType1, RealType2>::value,
501 KOKKOS_INLINE_FUNCTION
bool operator==(RealType1
const& x,
502 complex<RealType2>
const& y) noexcept {
503 using common_type =
typename std::common_type<RealType1, RealType2>::type;
504 return common_type(x) == common_type(y.real()) &&
505 common_type(0) == common_type(y.imag());
509 template <
class RealType1,
class RealType2>
510 KOKKOS_INLINE_FUNCTION
bool operator!=(complex<RealType1>
const& x,
511 complex<RealType2>
const& y) noexcept {
512 using common_type =
typename std::common_type<RealType1, RealType2>::type;
513 return common_type(x.real()) != common_type(y.real()) ||
514 common_type(x.imag()) != common_type(y.imag());
518 template <
class RealType1,
class RealType2>
519 inline bool operator!=(std::complex<RealType1>
const& x,
520 complex<RealType2>
const& y) noexcept {
521 using common_type =
typename std::common_type<RealType1, RealType2>::type;
522 return common_type(x.real()) != common_type(y.real()) ||
523 common_type(x.imag()) != common_type(y.imag());
527 template <
class RealType1,
class RealType2>
528 inline bool operator!=(complex<RealType1>
const& x,
529 std::complex<RealType2>
const& y) noexcept {
530 using common_type =
typename std::common_type<RealType1, RealType2>::type;
531 return common_type(x.real()) != common_type(y.real()) ||
532 common_type(x.imag()) != common_type(y.imag());
537 class RealType1,
class RealType2,
539 typename std::enable_if<std::is_convertible<RealType2, RealType1>::value,
541 KOKKOS_INLINE_FUNCTION
bool operator!=(complex<RealType1>
const& x,
542 RealType2
const& y) noexcept {
543 using common_type =
typename std::common_type<RealType1, RealType2>::type;
544 return common_type(x.real()) != common_type(y) ||
545 common_type(x.imag()) != common_type(0);
550 class RealType1,
class RealType2,
552 typename std::enable_if<std::is_convertible<RealType1, RealType2>::value,
554 KOKKOS_INLINE_FUNCTION
bool operator!=(RealType1
const& x,
555 complex<RealType2>
const& y) noexcept {
556 using common_type =
typename std::common_type<RealType1, RealType2>::type;
557 return common_type(x) != common_type(y.real()) ||
558 common_type(0) != common_type(y.imag());
565 template <
class RealType1,
class RealType2>
566 KOKKOS_INLINE_FUNCTION
567 complex<typename std::common_type<RealType1, RealType2>::type>
568 operator+(
const complex<RealType1>& x,
569 const complex<RealType2>& y) noexcept {
570 return complex<typename std::common_type<RealType1, RealType2>::type>(
571 x.real() + y.real(), x.imag() + y.imag());
575 template <
class RealType1,
class RealType2>
576 KOKKOS_INLINE_FUNCTION
577 complex<typename std::common_type<RealType1, RealType2>::type>
578 operator+(
const complex<RealType1>& x,
const RealType2& y) noexcept {
579 return complex<typename std::common_type<RealType1, RealType2>::type>(
580 x.real() + y, x.imag());
584 template <
class RealType1,
class RealType2>
585 KOKKOS_INLINE_FUNCTION
586 complex<typename std::common_type<RealType1, RealType2>::type>
587 operator+(
const RealType1& x,
const complex<RealType2>& y) noexcept {
588 return complex<typename std::common_type<RealType1, RealType2>::type>(
589 x + y.real(), y.imag());
593 template <
class RealType>
594 KOKKOS_INLINE_FUNCTION complex<RealType> operator+(
595 const complex<RealType>& x) noexcept {
596 return complex<RealType>{+x.real(), +x.imag()};
600 template <
class RealType1,
class RealType2>
601 KOKKOS_INLINE_FUNCTION
602 complex<typename std::common_type<RealType1, RealType2>::type>
603 operator-(
const complex<RealType1>& x,
604 const complex<RealType2>& y) noexcept {
605 return complex<typename std::common_type<RealType1, RealType2>::type>(
606 x.real() - y.real(), x.imag() - y.imag());
610 template <
class RealType1,
class RealType2>
611 KOKKOS_INLINE_FUNCTION
612 complex<typename std::common_type<RealType1, RealType2>::type>
613 operator-(
const complex<RealType1>& x,
const RealType2& y) noexcept {
614 return complex<typename std::common_type<RealType1, RealType2>::type>(
615 x.real() - y, x.imag());
619 template <
class RealType1,
class RealType2>
620 KOKKOS_INLINE_FUNCTION
621 complex<typename std::common_type<RealType1, RealType2>::type>
622 operator-(
const RealType1& x,
const complex<RealType2>& y) noexcept {
623 return complex<typename std::common_type<RealType1, RealType2>::type>(
624 x - y.real(), -y.imag());
628 template <
class RealType>
629 KOKKOS_INLINE_FUNCTION complex<RealType> operator-(
630 const complex<RealType>& x) noexcept {
631 return complex<RealType>(-x.real(), -x.imag());
635 template <
class RealType1,
class RealType2>
636 KOKKOS_INLINE_FUNCTION
637 complex<typename std::common_type<RealType1, RealType2>::type>
638 operator*(
const complex<RealType1>& x,
639 const complex<RealType2>& y) noexcept {
640 return complex<typename std::common_type<RealType1, RealType2>::type>(
641 x.real() * y.real() - x.imag() * y.imag(),
642 x.real() * y.imag() + x.imag() * y.real());
653 template <
class RealType1,
class RealType2>
654 inline complex<typename std::common_type<RealType1, RealType2>::type> operator*(
655 const std::complex<RealType1>& x,
const complex<RealType2>& y) {
656 return complex<typename std::common_type<RealType1, RealType2>::type>(
657 x.real() * y.real() - x.imag() * y.imag(),
658 x.real() * y.imag() + x.imag() * y.real());
665 template <
class RealType1,
class RealType2>
666 KOKKOS_INLINE_FUNCTION
667 complex<typename std::common_type<RealType1, RealType2>::type>
668 operator*(
const RealType1& x,
const complex<RealType2>& y) noexcept {
669 return complex<typename std::common_type<RealType1, RealType2>::type>(
670 x * y.real(), x * y.imag());
677 template <
class RealType1,
class RealType2>
678 KOKKOS_INLINE_FUNCTION
679 complex<typename std::common_type<RealType1, RealType2>::type>
680 operator*(
const complex<RealType1>& y,
const RealType2& x) noexcept {
681 return complex<typename std::common_type<RealType1, RealType2>::type>(
682 x * y.real(), x * y.imag());
686 template <
class RealType>
687 KOKKOS_INLINE_FUNCTION RealType imag(
const complex<RealType>& x) noexcept {
692 template <
class RealType>
693 KOKKOS_INLINE_FUNCTION RealType real(
const complex<RealType>& x) noexcept {
699 KOKKOS_INLINE_FUNCTION complex<T> polar(
const T& r,
const T& theta = T()) {
700 using Kokkos::Experimental::cos;
701 using Kokkos::Experimental::sin;
702 KOKKOS_EXPECTS(r >= 0);
703 return complex<T>(r * cos(theta), r * sin(theta));
707 template <
class RealType>
708 KOKKOS_INLINE_FUNCTION RealType abs(
const complex<RealType>& x) {
709 using Kokkos::Experimental::hypot;
710 return hypot(x.real(), x.imag());
715 KOKKOS_INLINE_FUNCTION complex<T> pow(
const complex<T>& x,
const T& y) {
716 using Kokkos::Experimental::atan2;
717 using Kokkos::Experimental::pow;
719 T theta = atan2(x.imag(), x.real());
720 return polar(pow(r, y), y * theta);
724 KOKKOS_INLINE_FUNCTION complex<T> pow(
const T& x,
const complex<T>& y) {
725 return pow(complex<T>(x), y);
729 KOKKOS_INLINE_FUNCTION complex<T> pow(
const complex<T>& x,
730 const complex<T>& y) {
731 using Kokkos::Experimental::log;
733 return x == T() ? T() : exp(y * log(x));
738 template <class T, bool = std::is_integral<T>::value>
743 struct promote<T, false> {};
745 struct promote<long double> {
746 using type =
long double;
749 struct promote<double> {
753 struct promote<float> {
757 using promote_t =
typename promote<T>::type;
758 template <
class T,
class U>
760 using type = decltype(promote_t<T>() + promote_t<U>());
762 template <
class T,
class U>
763 using promote_2_t =
typename promote_2<T, U>::type;
766 template <
class T,
class U,
767 class = std::enable_if_t<std::is_arithmetic<T>::value>>
768 KOKKOS_INLINE_FUNCTION complex<Impl::promote_2_t<T, U>> pow(
769 const T& x,
const complex<U>& y) {
770 using type = Impl::promote_2_t<T, U>;
771 return pow(type(x), complex<type>(y));
774 template <
class T,
class U,
775 class = std::enable_if_t<std::is_arithmetic<U>::value>>
776 KOKKOS_INLINE_FUNCTION complex<Impl::promote_2_t<T, U>> pow(
const complex<T>& x,
778 using type = Impl::promote_2_t<T, U>;
779 return pow(complex<type>(x), type(y));
782 template <
class T,
class U>
783 KOKKOS_INLINE_FUNCTION complex<Impl::promote_2_t<T, U>> pow(
784 const complex<T>& x,
const complex<U>& y) {
785 using type = Impl::promote_2_t<T, U>;
786 return pow(complex<type>(x), complex<type>(y));
791 template <
class RealType>
793 const complex<RealType>& x) {
794 using Kokkos::Experimental::fabs;
795 using Kokkos::Experimental::sqrt;
797 RealType r = x.real();
798 RealType i = x.imag();
800 if (r == RealType()) {
801 RealType t = sqrt(fabs(i) / 2);
804 RealType t = sqrt(2 * (abs(x) + fabs(r)));
808 i < RealType() ? -u : u);
813 template <
class RealType>
814 KOKKOS_INLINE_FUNCTION complex<RealType> conj(
815 const complex<RealType>& x) noexcept {
816 return complex<RealType>(real(x), -imag(x));
820 template <
class RealType>
821 KOKKOS_INLINE_FUNCTION complex<RealType> exp(
const complex<RealType>& x) {
822 using Kokkos::Experimental::cos;
823 using Kokkos::Experimental::exp;
824 using Kokkos::Experimental::sin;
825 return exp(x.real()) * complex<RealType>(cos(x.imag()), sin(x.imag()));
829 template <
class RealType>
831 const complex<RealType>& x) {
832 using Kokkos::Experimental::atan2;
833 using Kokkos::Experimental::log;
834 RealType phi = atan2(x.imag(), x.real());
839 template <
class RealType>
841 const complex<RealType>& x) {
842 using Kokkos::Experimental::cos;
843 using Kokkos::Experimental::cosh;
844 using Kokkos::Experimental::sin;
845 using Kokkos::Experimental::sinh;
847 cos(x.real()) * sinh(x.imag()));
851 template <
class RealType>
853 const complex<RealType>& x) {
854 using Kokkos::Experimental::cos;
855 using Kokkos::Experimental::cosh;
856 using Kokkos::Experimental::sin;
857 using Kokkos::Experimental::sinh;
859 -sin(x.real()) * sinh(x.imag()));
863 template <
class RealType>
865 const complex<RealType>& x) {
866 return sin(x) / cos(x);
870 template <
class RealType>
872 const complex<RealType>& x) {
873 using Kokkos::Experimental::cos;
874 using Kokkos::Experimental::cosh;
875 using Kokkos::Experimental::sin;
876 using Kokkos::Experimental::sinh;
878 cosh(x.real()) * sin(x.imag()));
882 template <
class RealType>
884 const complex<RealType>& x) {
885 using Kokkos::Experimental::cos;
886 using Kokkos::Experimental::cosh;
887 using Kokkos::Experimental::sin;
888 using Kokkos::Experimental::sinh;
890 sinh(x.real()) * sin(x.imag()));
894 template <
class RealType>
896 const complex<RealType>& x) {
897 return sinh(x) / cosh(x);
901 template <
class RealType>
903 const complex<RealType>& x) {
904 return log(x + sqrt(x * x + RealType(1.0)));
908 template <
class RealType>
910 const complex<RealType>& x) {
911 return RealType(2.0) * log(sqrt(RealType(0.5) * (x + RealType(1.0))) +
912 sqrt(RealType(0.5) * (x - RealType(1.0))));
916 template <
class RealType>
918 const complex<RealType>& x) {
919 using Kokkos::Experimental::atan2;
920 using Kokkos::Experimental::log;
922 const RealType i2 = x.imag() * x.imag();
923 const RealType r = RealType(1.0) - i2 - x.real() * x.real();
925 RealType p = RealType(1.0) + x.real();
926 RealType m = RealType(1.0) - x.real();
931 RealType phi = atan2(RealType(2.0) * x.imag(), r);
933 RealType(0.5) * phi);
937 template <
class RealType>
939 const complex<RealType>& x) {
946 template <
class RealType>
948 const complex<RealType>& x) {
949 using Kokkos::Experimental::acos;
951 RealType pi_2 = acos(RealType(0.0));
956 template <
class RealType>
958 const complex<RealType>& x) {
959 using Kokkos::Experimental::atan2;
960 using Kokkos::Experimental::log;
961 const RealType r2 = x.real() * x.real();
962 const RealType i = RealType(1.0) - r2 - x.imag() * x.imag();
964 RealType p = x.imag() + RealType(1.0);
965 RealType m = x.imag() - RealType(1.0);
971 RealType(0.5) * atan2(RealType(2.0) * x.real(), i),
972 RealType(0.25) * log(p / m));
978 template <
class RealType>
979 inline complex<RealType> exp(
const std::complex<RealType>& c) {
980 return complex<RealType>(std::exp(c.real()) * std::cos(c.imag()),
981 std::exp(c.real()) * std::sin(c.imag()));
985 template <
class RealType1,
class RealType2>
986 KOKKOS_INLINE_FUNCTION
987 complex<typename std::common_type<RealType1, RealType2>::type>
988 operator/(
const complex<RealType1>& x,
989 const RealType2& y) noexcept(noexcept(RealType1{} /
991 return complex<typename std::common_type<RealType1, RealType2>::type>(
992 real(x) / y, imag(x) / y);
996 template <
class RealType1,
class RealType2>
997 KOKKOS_INLINE_FUNCTION
998 complex<typename std::common_type<RealType1, RealType2>::type>
999 operator/(
const complex<RealType1>& x,
1000 const complex<RealType2>& y) noexcept(noexcept(RealType1{} /
1002 using Kokkos::Experimental::fabs;
1006 using common_real_type =
1007 typename std::common_type<RealType1, RealType2>::type;
1008 const common_real_type s = fabs(real(y)) + fabs(imag(y));
1014 return complex<common_real_type>(real(x) / s, imag(x) / s);
1016 const complex<common_real_type> x_scaled(real(x) / s, imag(x) / s);
1017 const complex<common_real_type> y_conj_scaled(real(y) / s, -imag(y) / s);
1018 const RealType1 y_scaled_abs =
1019 real(y_conj_scaled) * real(y_conj_scaled) +
1020 imag(y_conj_scaled) * imag(y_conj_scaled);
1021 complex<common_real_type> result = x_scaled * y_conj_scaled;
1022 result /= y_scaled_abs;
1028 template <
class RealType1,
class RealType2>
1029 KOKKOS_INLINE_FUNCTION
1030 complex<typename std::common_type<RealType1, RealType2>::type>
1031 operator/(
const RealType1& x,
1032 const complex<RealType2>& y) noexcept(noexcept(RealType1{} /
1034 return complex<typename std::common_type<RealType1, RealType2>::type>(x) / y;
1037 template <
class RealType>
1038 std::ostream& operator<<(std::ostream& os, const complex<RealType>& x) {
1039 const std::complex<RealType> x_std(Kokkos::real(x), Kokkos::imag(x));
1044 template <
class RealType>
1045 std::istream& operator>>(std::istream& is, complex<RealType>& x) {
1046 std::complex<RealType> x_std;
1053 struct reduction_identity<
Kokkos::complex<T>> {
1054 using t_red_ident = reduction_identity<T>;
1067 #endif // KOKKOS_COMPLEX_HPP KOKKOS_INLINE_FUNCTION KOKKOS_CONSTEXPR_14 RealType & real() noexcept
The real part of this complex number.
KOKKOS_INLINE_FUNCTION KOKKOS_CONSTEXPR_14 RealType & imag() noexcept
The imaginary part of this complex number.
Partial reimplementation of std::complex that works as the result of a Kokkos::parallel_reduce.
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 complex(const RealType &val) noexcept
Constructor that takes just the real part, and sets the imaginary part to zero.
complex & operator=(const std::complex< RealType > &src) noexcept
Assignment operator from std::complex.
KOKKOS_INLINE_FUNCTION volatile RealType & imag() volatile noexcept
The imaginary part of this complex number (volatile overload).
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() const noexcept
The imaginary part of this complex number.
KOKKOS_INLINE_FUNCTION RealType imag() const volatile noexcept
The imaginary part of this complex number (volatile overload).
KOKKOS_INLINE_FUNCTION void operator=(const Complex &src) volatile noexcept
Assignment operator, for volatile *this and nonvolatile input.
KOKKOS_INLINE_FUNCTION complex(const std::complex< RealType > &src) noexcept
Conversion constructor from std::complex.
KOKKOS_INLINE_FUNCTION KOKKOS_CONSTEXPR_14 void imag(RealType v) noexcept
Set the imaginary part of this complex number.
KOKKOS_INLINE_FUNCTION volatile complex & operator=(const volatile Complex &src) volatile noexcept
Assignment operator, volatile LHS and volatile RHS.
KOKKOS_INLINE_FUNCTION RealType real() const volatile noexcept
The real part of this complex number (volatile overload).
KOKKOS_INLINE_FUNCTION complex & operator=(const volatile RealType &val) volatile noexcept
Assignment operator volatile LHS and volatile RHS.
KOKKOS_INLINE_FUNCTION complex(const volatile complex< RType > &src) noexcept
Copy constructor from volatile.
RealType value_type
The type of the real or imaginary parts of this complex number.
KOKKOS_INLINE_FUNCTION volatile RealType & real() volatile noexcept
The real part of this complex number (volatile overload).
KOKKOS_INLINE_FUNCTION void operator=(const volatile RealType &val) noexcept
Assignment operator (from a volatile real number).
KOKKOS_INLINE_FUNCTION KOKKOS_CONSTEXPR_14 void real(RealType v) noexcept
Set the real part of this complex number.
KOKKOS_INLINE_FUNCTION complex & operator=(const volatile Complex &src) noexcept
Assignment operator, volatile RHS and non-volatile LHS.
KOKKOS_INLINE_FUNCTION complex & operator=(const RealType &val) volatile noexcept
Assignment operator volatile LHS and non-volatile RHS.