36#ifndef _GLIBCXX_COMPLEX
37#define _GLIBCXX_COMPLEX 1
40#pragma GCC system_header
43#pragma GCC diagnostic push
44#pragma GCC diagnostic ignored "-Wc++11-extensions"
56#pragma clang diagnostic push
57#pragma clang diagnostic ignored "-Wc99-extensions"
60#define __glibcxx_want_constexpr_complex
61#define __glibcxx_want_complex_udls
64namespace std _GLIBCXX_VISIBILITY(default)
66_GLIBCXX_BEGIN_NAMESPACE_VERSION
77 template<
typename _Tp>
class complex;
78 template<>
class complex<float>;
79 template<>
class complex<double>;
80 template<>
class complex<long double>;
83 template<
typename _Tp> _Tp
abs(
const complex<_Tp>&);
85 template<
typename _Tp> _Tp
arg(
const complex<_Tp>&);
87 template<
typename _Tp> _Tp _GLIBCXX20_CONSTEXPR
norm(
const complex<_Tp>&);
90 template<
typename _Tp>
91 _GLIBCXX20_CONSTEXPR complex<_Tp>
conj(
const complex<_Tp>&);
93 template<
typename _Tp> complex<_Tp>
polar(
const _Tp&,
const _Tp& = 0);
97 template<
typename _Tp> complex<_Tp>
cos(
const complex<_Tp>&);
99 template<
typename _Tp> complex<_Tp>
cosh(
const complex<_Tp>&);
101 template<
typename _Tp> complex<_Tp>
exp(
const complex<_Tp>&);
103 template<
typename _Tp> complex<_Tp>
log(
const complex<_Tp>&);
105 template<
typename _Tp> complex<_Tp>
log10(
const complex<_Tp>&);
107 template<
typename _Tp> complex<_Tp>
pow(
const complex<_Tp>&,
int);
109 template<
typename _Tp> complex<_Tp>
pow(
const complex<_Tp>&,
const _Tp&);
111 template<
typename _Tp> complex<_Tp>
pow(
const complex<_Tp>&,
112 const complex<_Tp>&);
114 template<
typename _Tp> complex<_Tp>
pow(
const _Tp&,
const complex<_Tp>&);
116 template<
typename _Tp> complex<_Tp>
sin(
const complex<_Tp>&);
118 template<
typename _Tp> complex<_Tp>
sinh(
const complex<_Tp>&);
120 template<
typename _Tp> complex<_Tp>
sqrt(
const complex<_Tp>&);
122 template<
typename _Tp> complex<_Tp>
tan(
const complex<_Tp>&);
124 template<
typename _Tp> complex<_Tp>
tanh(
const complex<_Tp>&);
136 template<
typename _Tp>
145 _GLIBCXX_CONSTEXPR
complex(
const _Tp& __r = _Tp(),
const _Tp& __i = _Tp())
146 : _M_real(__r), _M_imag(__i) { }
149#if __cplusplus >= 201103L
154 template<
typename _Up>
155#if __cplusplus > 202002L
156 explicit(!
requires(_Up __u) { _Tp{__u}; })
159 : _M_real(_Tp(__z.real())), _M_imag(_Tp(__z.imag())) { }
161#if __cplusplus >= 201103L
164 _GLIBCXX_ABI_TAG_CXX11
166 real()
const {
return _M_real; }
168 _GLIBCXX_ABI_TAG_CXX11
170 imag()
const {
return _M_imag; }
174 real() {
return _M_real; }
178 real()
const {
return _M_real; }
182 imag() {
return _M_imag; }
186 imag()
const {
return _M_imag; }
191 _GLIBCXX20_CONSTEXPR
void
192 real(_Tp __val) { _M_real = __val; }
194 _GLIBCXX20_CONSTEXPR
void
195 imag(_Tp __val) { _M_imag = __val; }
198 _GLIBCXX20_CONSTEXPR complex<_Tp>&
operator=(
const _Tp&);
202 _GLIBCXX20_CONSTEXPR complex<_Tp>&
224#if __cplusplus >= 201103L
229 template<
typename _Up>
232 template<
typename _Up>
235 template<
typename _Up>
238 template<
typename _Up>
241 template<
typename _Up>
244 _GLIBCXX_CONSTEXPR
complex __rep()
const
252 template<
typename _Tp>
253 _GLIBCXX20_CONSTEXPR complex<_Tp>&
262 template<
typename _Tp>
272 template<
typename _Tp>
281 template<
typename _Tp>
282 template<
typename _Up>
286 _M_real = __z.real();
287 _M_imag = __z.imag();
292 template<
typename _Tp>
293 template<
typename _Up>
297 _M_real += __z.real();
298 _M_imag += __z.imag();
303 template<
typename _Tp>
304 template<
typename _Up>
308 _M_real -= __z.real();
309 _M_imag -= __z.imag();
315 template<
typename _Tp>
316 template<
typename _Up>
320 const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
321 _M_imag = _M_real * __z.imag() + _M_imag * __z.real();
328 template<
typename _Tp>
329 template<
typename _Up>
333 const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag();
335 _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n;
343 template<
typename _Tp>
352 template<
typename _Tp>
353 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
361 template<
typename _Tp>
362 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
373 template<
typename _Tp>
374 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
382 template<
typename _Tp>
383 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
391 template<
typename _Tp>
392 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
403 template<
typename _Tp>
404 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
412 template<
typename _Tp>
413 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
421 template<
typename _Tp>
422 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
433 template<
typename _Tp>
434 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
442 template<
typename _Tp>
443 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
451 template<
typename _Tp>
452 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
462 template<
typename _Tp>
463 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
468 template<
typename _Tp>
469 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
475 template<
typename _Tp>
476 inline _GLIBCXX_CONSTEXPR
bool
478 {
return __x.real() == __y.real() && __x.imag() == __y.imag(); }
480 template<
typename _Tp>
481 inline _GLIBCXX_CONSTEXPR
bool
483 {
return __x.real() == __y && __x.imag() == _Tp(); }
485#if !(__cpp_impl_three_way_comparison >= 201907L)
486 template<
typename _Tp>
487 inline _GLIBCXX_CONSTEXPR
bool
488 operator==(
const _Tp& __x,
const complex<_Tp>& __y)
489 {
return __x == __y.real() && _Tp() == __y.imag(); }
494 template<
typename _Tp>
495 inline _GLIBCXX_CONSTEXPR
bool
496 operator!=(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
497 {
return __x.real() != __y.real() || __x.imag() != __y.imag(); }
499 template<
typename _Tp>
500 inline _GLIBCXX_CONSTEXPR
bool
501 operator!=(
const complex<_Tp>& __x,
const _Tp& __y)
502 {
return __x.real() != __y || __x.imag() != _Tp(); }
504 template<
typename _Tp>
505 inline _GLIBCXX_CONSTEXPR
bool
506 operator!=(
const _Tp& __x,
const complex<_Tp>& __y)
507 {
return __x != __y.real() || _Tp() != __y.imag(); }
512 template<
typename _Tp,
typename _CharT,
class _Traits>
513 basic_istream<_CharT, _Traits>&
520 if (_Traits::eq(__ch, __is.
widen(
'(')))
523 if (__is >> __u >> __ch)
525 const _CharT __rparen = __is.
widen(
')');
526 if (_Traits::eq(__ch, __rparen))
531 else if (_Traits::eq(__ch, __is.
widen(
',')))
534 if (__is >> __v >> __ch)
536 if (_Traits::eq(__ch, __rparen))
566 template<
typename _Tp,
typename _CharT,
class _Traits>
567 basic_ostream<_CharT, _Traits>&
568 operator<<(basic_ostream<_CharT, _Traits>& __os,
const complex<_Tp>& __x)
570 basic_ostringstream<_CharT, _Traits> __s;
571 __s.
flags(__os.flags());
572 __s.imbue(__os.getloc());
573 __s.precision(__os.precision());
574 __s <<
'(' << __x.real() <<
',' << __x.imag() <<
')';
575 return __os << __s.str();
579#if __cplusplus >= 201103L
580 template<
typename _Tp>
582 real(
const complex<_Tp>& __z)
583 {
return __z.real(); }
585 template<
typename _Tp>
587 imag(
const complex<_Tp>& __z)
588 {
return __z.imag(); }
590 template<
typename _Tp>
592 real(complex<_Tp>& __z)
593 {
return __z.real(); }
595 template<
typename _Tp>
597 real(
const complex<_Tp>& __z)
598 {
return __z.real(); }
600 template<
typename _Tp>
602 imag(complex<_Tp>& __z)
603 {
return __z.imag(); }
605 template<
typename _Tp>
607 imag(
const complex<_Tp>& __z)
608 {
return __z.imag(); }
611#if _GLIBCXX_USE_C99_COMPLEX
612#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
614 __complex_abs(__complex__ _Float16 __z)
615 {
return _Float16(__builtin_cabsf(__z)); }
618 __complex_arg(__complex__ _Float16 __z)
619 {
return _Float16(__builtin_cargf(__z)); }
621 inline __complex__ _Float16
622 __complex_cos(__complex__ _Float16 __z)
623 {
return static_cast<__complex__ _Float16
>(__builtin_ccosf(__z)); }
625 inline __complex__ _Float16
626 __complex_cosh(__complex__ _Float16 __z)
627 {
return static_cast<__complex__ _Float16
>(__builtin_ccoshf(__z)); }
629 inline __complex__ _Float16
630 __complex_exp(__complex__ _Float16 __z)
631 {
return static_cast<__complex__ _Float16
>(__builtin_cexpf(__z)); }
633 inline __complex__ _Float16
634 __complex_log(__complex__ _Float16 __z)
635 {
return static_cast<__complex__ _Float16
>(__builtin_clogf(__z)); }
637 inline __complex__ _Float16
638 __complex_sin(__complex__ _Float16 __z)
639 {
return static_cast<__complex__ _Float16
>(__builtin_csinf(__z)); }
641 inline __complex__ _Float16
642 __complex_sinh(__complex__ _Float16 __z)
643 {
return static_cast<__complex__ _Float16
>(__builtin_csinhf(__z)); }
645 inline __complex__ _Float16
646 __complex_sqrt(__complex__ _Float16 __z)
647 {
return static_cast<__complex__ _Float16
>(__builtin_csqrtf(__z)); }
649 inline __complex__ _Float16
650 __complex_tan(__complex__ _Float16 __z)
651 {
return static_cast<__complex__ _Float16
>(__builtin_ctanf(__z)); }
653 inline __complex__ _Float16
654 __complex_tanh(__complex__ _Float16 __z)
655 {
return static_cast<__complex__ _Float16
>(__builtin_ctanhf(__z)); }
657 inline __complex__ _Float16
658 __complex_pow(__complex__ _Float16 __x, __complex__ _Float16 __y)
659 {
return static_cast<__complex__ _Float16
>(__builtin_cpowf(__x, __y)); }
662#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
664 __complex_abs(__complex__ _Float32 __z) {
return __builtin_cabsf(__z); }
667 __complex_arg(__complex__ _Float32 __z) {
return __builtin_cargf(__z); }
669 inline __complex__ _Float32
670 __complex_cos(__complex__ _Float32 __z) {
return __builtin_ccosf(__z); }
672 inline __complex__ _Float32
673 __complex_cosh(__complex__ _Float32 __z) {
return __builtin_ccoshf(__z); }
675 inline __complex__ _Float32
676 __complex_exp(__complex__ _Float32 __z) {
return __builtin_cexpf(__z); }
678 inline __complex__ _Float32
679 __complex_log(__complex__ _Float32 __z) {
return __builtin_clogf(__z); }
681 inline __complex__ _Float32
682 __complex_sin(__complex__ _Float32 __z) {
return __builtin_csinf(__z); }
684 inline __complex__ _Float32
685 __complex_sinh(__complex__ _Float32 __z) {
return __builtin_csinhf(__z); }
687 inline __complex__ _Float32
688 __complex_sqrt(__complex__ _Float32 __z) {
return __builtin_csqrtf(__z); }
690 inline __complex__ _Float32
691 __complex_tan(__complex__ _Float32 __z) {
return __builtin_ctanf(__z); }
693 inline __complex__ _Float32
694 __complex_tanh(__complex__ _Float32 __z) {
return __builtin_ctanhf(__z); }
696 inline __complex__ _Float32
697 __complex_pow(__complex__ _Float32 __x, __complex__ _Float32 __y)
698 {
return __builtin_cpowf(__x, __y); }
701#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
703 __complex_abs(__complex__ _Float64 __z) {
return __builtin_cabs(__z); }
706 __complex_arg(__complex__ _Float64 __z) {
return __builtin_carg(__z); }
708 inline __complex__ _Float64
709 __complex_cos(__complex__ _Float64 __z) {
return __builtin_ccos(__z); }
711 inline __complex__ _Float64
712 __complex_cosh(__complex__ _Float64 __z) {
return __builtin_ccosh(__z); }
714 inline __complex__ _Float64
715 __complex_exp(__complex__ _Float64 __z) {
return __builtin_cexp(__z); }
717 inline __complex__ _Float64
718 __complex_log(__complex__ _Float64 __z) {
return __builtin_clog(__z); }
720 inline __complex__ _Float64
721 __complex_sin(__complex__ _Float64 __z) {
return __builtin_csin(__z); }
723 inline __complex__ _Float64
724 __complex_sinh(__complex__ _Float64 __z) {
return __builtin_csinh(__z); }
726 inline __complex__ _Float64
727 __complex_sqrt(__complex__ _Float64 __z) {
return __builtin_csqrt(__z); }
729 inline __complex__ _Float64
730 __complex_tan(__complex__ _Float64 __z) {
return __builtin_ctan(__z); }
732 inline __complex__ _Float64
733 __complex_tanh(__complex__ _Float64 __z) {
return __builtin_ctanh(__z); }
735 inline __complex__ _Float64
736 __complex_pow(__complex__ _Float64 __x, __complex__ _Float64 __y)
737 {
return __builtin_cpow(__x, __y); }
740#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
742 __complex_abs(__complex__ _Float128 __z) {
return __builtin_cabsl(__z); }
745 __complex_arg(__complex__ _Float128 __z) {
return __builtin_cargl(__z); }
747 inline __complex__ _Float128
748 __complex_cos(__complex__ _Float128 __z) {
return __builtin_ccosl(__z); }
750 inline __complex__ _Float128
751 __complex_cosh(__complex__ _Float128 __z) {
return __builtin_ccoshl(__z); }
753 inline __complex__ _Float128
754 __complex_exp(__complex__ _Float128 __z) {
return __builtin_cexpl(__z); }
756 inline __complex__ _Float128
757 __complex_log(__complex__ _Float128 __z) {
return __builtin_clogl(__z); }
759 inline __complex__ _Float128
760 __complex_sin(__complex__ _Float128 __z) {
return __builtin_csinl(__z); }
762 inline __complex__ _Float128
763 __complex_sinh(__complex__ _Float128 __z) {
return __builtin_csinhl(__z); }
765 inline __complex__ _Float128
766 __complex_sqrt(__complex__ _Float128 __z) {
return __builtin_csqrtl(__z); }
768 inline __complex__ _Float128
769 __complex_tan(__complex__ _Float128 __z) {
return __builtin_ctanl(__z); }
771 inline __complex__ _Float128
772 __complex_tanh(__complex__ _Float128 __z) {
return __builtin_ctanhl(__z); }
774 inline __complex__ _Float128
775 __complex_pow(__complex__ _Float128 __x, __complex__ _Float128 __y)
776 {
return __builtin_cpowl(__x, __y); }
777#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
779 __complex_abs(__complex__ _Float128 __z) {
return __builtin_cabsf128(__z); }
782 __complex_arg(__complex__ _Float128 __z) {
return __builtin_cargf128(__z); }
784 inline __complex__ _Float128
785 __complex_cos(__complex__ _Float128 __z) {
return __builtin_ccosf128(__z); }
787 inline __complex__ _Float128
788 __complex_cosh(__complex__ _Float128 __z) {
return __builtin_ccoshf128(__z); }
790 inline __complex__ _Float128
791 __complex_exp(__complex__ _Float128 __z) {
return __builtin_cexpf128(__z); }
793 inline __complex__ _Float128
794 __complex_log(__complex__ _Float128 __z) {
return __builtin_clogf128(__z); }
796 inline __complex__ _Float128
797 __complex_sin(__complex__ _Float128 __z) {
return __builtin_csinf128(__z); }
799 inline __complex__ _Float128
800 __complex_sinh(__complex__ _Float128 __z) {
return __builtin_csinhf128(__z); }
802 inline __complex__ _Float128
803 __complex_sqrt(__complex__ _Float128 __z) {
return __builtin_csqrtf128(__z); }
805 inline __complex__ _Float128
806 __complex_tan(__complex__ _Float128 __z) {
return __builtin_ctanf128(__z); }
808 inline __complex__ _Float128
809 __complex_tanh(__complex__ _Float128 __z) {
return __builtin_ctanhf128(__z); }
811 inline __complex__ _Float128
812 __complex_pow(__complex__ _Float128 __x, __complex__ _Float128 __y)
813 {
return __builtin_cpowf128(__x, __y); }
816#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
817 inline __gnu_cxx::__bfloat16_t
818 __complex_abs(__complex__
decltype(0.0bf16) __z)
819 {
return __gnu_cxx::__bfloat16_t(__builtin_cabsf(__z)); }
821 inline __gnu_cxx::__bfloat16_t
822 __complex_arg(__complex__
decltype(0.0bf16) __z)
823 {
return __gnu_cxx::__bfloat16_t(__builtin_cargf(__z)); }
825 inline __complex__
decltype(0.0bf16)
826 __complex_cos(__complex__
decltype(0.0bf16) __z)
827 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_ccosf(__z)); }
829 inline __complex__
decltype(0.0bf16)
830 __complex_cosh(__complex__
decltype(0.0bf16) __z)
831 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_ccoshf(__z)); }
833 inline __complex__
decltype(0.0bf16)
834 __complex_exp(__complex__
decltype(0.0bf16) __z)
835 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_cexpf(__z)); }
837 inline __complex__
decltype(0.0bf16)
838 __complex_log(__complex__
decltype(0.0bf16) __z)
839 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_clogf(__z)); }
841 inline __complex__
decltype(0.0bf16)
842 __complex_sin(__complex__
decltype(0.0bf16) __z)
843 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_csinf(__z)); }
845 inline __complex__
decltype(0.0bf16)
846 __complex_sinh(__complex__
decltype(0.0bf16) __z)
847 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_csinhf(__z)); }
849 inline __complex__
decltype(0.0bf16)
850 __complex_sqrt(__complex__
decltype(0.0bf16) __z)
851 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_csqrtf(__z)); }
853 inline __complex__
decltype(0.0bf16)
854 __complex_tan(__complex__
decltype(0.0bf16) __z)
855 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_ctanf(__z)); }
857 inline __complex__
decltype(0.0bf16)
858 __complex_tanh(__complex__
decltype(0.0bf16) __z)
859 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_ctanhf(__z)); }
861 inline __complex__
decltype(0.0bf16)
862 __complex_pow(__complex__
decltype(0.0bf16) __x,
863 __complex__
decltype(0.0bf16) __y)
864 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_cpowf(__x,
870 template<
typename _Tp>
872 __complex_abs(
const complex<_Tp>& __z)
874 _Tp __x = __z.real();
875 _Tp __y = __z.imag();
881 return __s *
sqrt(__x * __x + __y * __y);
884#if _GLIBCXX_USE_C99_COMPLEX
886 __complex_abs(__complex__
float __z) {
return __builtin_cabsf(__z); }
889 __complex_abs(__complex__
double __z) {
return __builtin_cabs(__z); }
892 __complex_abs(
const __complex__
long double& __z)
893 {
return __builtin_cabsl(__z); }
895 template<
typename _Tp>
897 abs(
const complex<_Tp>& __z) {
return __complex_abs(__z.__rep()); }
899 template<
typename _Tp>
906 template<
typename _Tp>
908 __complex_arg(
const complex<_Tp>& __z)
909 {
return atan2(__z.imag(), __z.real()); }
911#if _GLIBCXX_USE_C99_COMPLEX
913 __complex_arg(__complex__
float __z) {
return __builtin_cargf(__z); }
916 __complex_arg(__complex__
double __z) {
return __builtin_carg(__z); }
919 __complex_arg(
const __complex__
long double& __z)
920 {
return __builtin_cargl(__z); }
922 template<
typename _Tp>
924 arg(
const complex<_Tp>& __z) {
return __complex_arg(__z.__rep()); }
926 template<
typename _Tp>
939 template<
typename _Tp>
940 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
942 const _Tp __x = __z.real();
943 const _Tp __y = __z.imag();
944 return __x * __x + __y * __y;
949 struct _Norm_helper<true>
951 template<
typename _Tp>
952 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
956 const _Tp __x = __z.real();
957 const _Tp __y = __z.imag();
958 return __x * __x + __y * __y;
962 template<
typename _Tp>
963 inline _GLIBCXX20_CONSTEXPR _Tp
966 return _Norm_helper<__is_floating<_Tp>::__value
967 && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
970 template<
typename _Tp>
972 polar(
const _Tp& __rho,
const _Tp& __theta)
974 __glibcxx_assert( __rho >= 0 );
978 template<
typename _Tp>
979 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
986 template<
typename _Tp>
988 __complex_cos(
const complex<_Tp>& __z)
990 const _Tp __x = __z.real();
991 const _Tp __y = __z.imag();
992 return complex<_Tp>(cos(__x) * cosh(__y), -sin(__x) * sinh(__y));
995#if _GLIBCXX_USE_C99_COMPLEX
996 inline __complex__
float
997 __complex_cos(__complex__
float __z) {
return __builtin_ccosf(__z); }
999 inline __complex__
double
1000 __complex_cos(__complex__
double __z) {
return __builtin_ccos(__z); }
1002 inline __complex__
long double
1003 __complex_cos(
const __complex__
long double& __z)
1004 {
return __builtin_ccosl(__z); }
1006 template<
typename _Tp>
1008 cos(
const complex<_Tp>& __z) {
return __complex_cos(__z.__rep()); }
1010 template<
typename _Tp>
1016 template<
typename _Tp>
1018 __complex_cosh(
const complex<_Tp>& __z)
1020 const _Tp __x = __z.real();
1021 const _Tp __y = __z.imag();
1022 return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y));
1025#if _GLIBCXX_USE_C99_COMPLEX
1026 inline __complex__
float
1027 __complex_cosh(__complex__
float __z) {
return __builtin_ccoshf(__z); }
1029 inline __complex__
double
1030 __complex_cosh(__complex__
double __z) {
return __builtin_ccosh(__z); }
1032 inline __complex__
long double
1033 __complex_cosh(
const __complex__
long double& __z)
1034 {
return __builtin_ccoshl(__z); }
1036 template<
typename _Tp>
1038 cosh(
const complex<_Tp>& __z) {
return __complex_cosh(__z.__rep()); }
1040 template<
typename _Tp>
1046 template<
typename _Tp>
1048 __complex_exp(
const complex<_Tp>& __z)
1049 {
return std::polar<_Tp>(exp(__z.real()), __z.imag()); }
1051#if _GLIBCXX_USE_C99_COMPLEX
1052 inline __complex__
float
1053 __complex_exp(__complex__
float __z) {
return __builtin_cexpf(__z); }
1055 inline __complex__
double
1056 __complex_exp(__complex__
double __z) {
return __builtin_cexp(__z); }
1058 inline __complex__
long double
1059 __complex_exp(
const __complex__
long double& __z)
1060 {
return __builtin_cexpl(__z); }
1062 template<
typename _Tp>
1064 exp(
const complex<_Tp>& __z) {
return __complex_exp(__z.__rep()); }
1066 template<
typename _Tp>
1073 template<
typename _Tp>
1075 __complex_log(
const complex<_Tp>& __z)
1078#if _GLIBCXX_USE_C99_COMPLEX
1079 inline __complex__
float
1080 __complex_log(__complex__
float __z) {
return __builtin_clogf(__z); }
1082 inline __complex__
double
1083 __complex_log(__complex__
double __z) {
return __builtin_clog(__z); }
1085 inline __complex__
long double
1086 __complex_log(
const __complex__
long double& __z)
1087 {
return __builtin_clogl(__z); }
1089 template<
typename _Tp>
1091 log(
const complex<_Tp>& __z) {
return __complex_log(__z.__rep()); }
1093 template<
typename _Tp>
1098 template<
typename _Tp>
1104 template<
typename _Tp>
1106 __complex_sin(
const complex<_Tp>& __z)
1108 const _Tp __x = __z.real();
1109 const _Tp __y = __z.imag();
1110 return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y));
1113#if _GLIBCXX_USE_C99_COMPLEX
1114 inline __complex__
float
1115 __complex_sin(__complex__
float __z) {
return __builtin_csinf(__z); }
1117 inline __complex__
double
1118 __complex_sin(__complex__
double __z) {
return __builtin_csin(__z); }
1120 inline __complex__
long double
1121 __complex_sin(
const __complex__
long double& __z)
1122 {
return __builtin_csinl(__z); }
1124 template<
typename _Tp>
1126 sin(
const complex<_Tp>& __z) {
return __complex_sin(__z.__rep()); }
1128 template<
typename _Tp>
1134 template<
typename _Tp>
1136 __complex_sinh(
const complex<_Tp>& __z)
1138 const _Tp __x = __z.real();
1139 const _Tp __y = __z.imag();
1140 return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y));
1143#if _GLIBCXX_USE_C99_COMPLEX
1144 inline __complex__
float
1145 __complex_sinh(__complex__
float __z) {
return __builtin_csinhf(__z); }
1147 inline __complex__
double
1148 __complex_sinh(__complex__
double __z) {
return __builtin_csinh(__z); }
1150 inline __complex__
long double
1151 __complex_sinh(
const __complex__
long double& __z)
1152 {
return __builtin_csinhl(__z); }
1154 template<
typename _Tp>
1156 sinh(
const complex<_Tp>& __z) {
return __complex_sinh(__z.__rep()); }
1158 template<
typename _Tp>
1165 template<
typename _Tp>
1167 __complex_sqrt(
const complex<_Tp>& __z)
1169 _Tp __x = __z.real();
1170 _Tp __y = __z.imag();
1174 _Tp __t = sqrt(abs(__y) / 2);
1175 return complex<_Tp>(__t, __y < _Tp() ? -__t : __t);
1182 ? complex<_Tp>(__u, __y / __t)
1183 : complex<_Tp>(
abs(__y) / __t, __y < _Tp() ? -__u : __u);
1187#if _GLIBCXX_USE_C99_COMPLEX
1188 inline __complex__
float
1189 __complex_sqrt(__complex__
float __z) {
return __builtin_csqrtf(__z); }
1191 inline __complex__
double
1192 __complex_sqrt(__complex__
double __z) {
return __builtin_csqrt(__z); }
1194 inline __complex__
long double
1195 __complex_sqrt(
const __complex__
long double& __z)
1196 {
return __builtin_csqrtl(__z); }
1198 template<
typename _Tp>
1200 sqrt(
const complex<_Tp>& __z) {
return __complex_sqrt(__z.__rep()); }
1202 template<
typename _Tp>
1209 template<
typename _Tp>
1211 __complex_tan(
const complex<_Tp>& __z)
1214#if _GLIBCXX_USE_C99_COMPLEX
1215 inline __complex__
float
1216 __complex_tan(__complex__
float __z) {
return __builtin_ctanf(__z); }
1218 inline __complex__
double
1219 __complex_tan(__complex__
double __z) {
return __builtin_ctan(__z); }
1221 inline __complex__
long double
1222 __complex_tan(
const __complex__
long double& __z)
1223 {
return __builtin_ctanl(__z); }
1225 template<
typename _Tp>
1227 tan(
const complex<_Tp>& __z) {
return __complex_tan(__z.__rep()); }
1229 template<
typename _Tp>
1237 template<
typename _Tp>
1239 __complex_tanh(
const complex<_Tp>& __z)
1242#if _GLIBCXX_USE_C99_COMPLEX
1243 inline __complex__
float
1244 __complex_tanh(__complex__
float __z) {
return __builtin_ctanhf(__z); }
1246 inline __complex__
double
1247 __complex_tanh(__complex__
double __z) {
return __builtin_ctanh(__z); }
1249 inline __complex__
long double
1250 __complex_tanh(
const __complex__
long double& __z)
1251 {
return __builtin_ctanhl(__z); }
1253 template<
typename _Tp>
1255 tanh(
const complex<_Tp>& __z) {
return __complex_tanh(__z.__rep()); }
1257 template<
typename _Tp>
1266 template<
typename _Tp>
1268 __complex_pow_unsigned(complex<_Tp> __x,
unsigned __n)
1270 complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1);
1288 template<
typename _Tp>
1293 ?
complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(
unsigned)__n)
1294 : std::__complex_pow_unsigned(__z, __n);
1297 template<
typename _Tp>
1301#if ! _GLIBCXX_USE_C99_COMPLEX
1305 if (__x.imag() == _Tp() && __x.real() > _Tp())
1306 return pow(__x.real(), __y);
1309 return std::polar<_Tp>(
exp(__y * __t.real()), __y * __t.imag());
1312 template<
typename _Tp>
1314 __complex_pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1315 {
return __x == _Tp() ? _Tp() :
std::exp(__y *
std::log(__x)); }
1317#if _GLIBCXX_USE_C99_COMPLEX
1318 inline __complex__
float
1319 __complex_pow(__complex__
float __x, __complex__
float __y)
1320 {
return __builtin_cpowf(__x, __y); }
1322 inline __complex__
double
1323 __complex_pow(__complex__
double __x, __complex__
double __y)
1324 {
return __builtin_cpow(__x, __y); }
1326 inline __complex__
long double
1327 __complex_pow(
const __complex__
long double& __x,
1328 const __complex__
long double& __y)
1329 {
return __builtin_cpowl(__x, __y); }
1331 template<
typename _Tp>
1333 pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1334 {
return __complex_pow(__x.__rep(), __y.__rep()); }
1336 template<
typename _Tp>
1339 {
return __complex_pow(__x, __y); }
1342 template<
typename _Tp>
1346 return __x > _Tp() ? std::polar<_Tp>(
pow(__x, __y.real()),
1347 __y.imag() *
log(__x))
1358 typedef __complex__
float _ComplexT;
1360 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1362 _GLIBCXX_CONSTEXPR
complex(
float __r = 0.0f,
float __i = 0.0f)
1363#if __cplusplus >= 201103L
1364 : _M_value{ __r, __i } { }
1367 __real__ _M_value = __r;
1368 __imag__ _M_value = __i;
1372#if __cplusplus >= 201103L
1376#if __cplusplus > 202002L
1377 template<
typename _Up>
1378 explicit(!
requires(_Up __u) { value_type{__u}; })
1386#if __cplusplus >= 201103L
1389 __attribute ((__abi_tag__ (
"cxx11")))
1391 real()
const {
return __real__ _M_value; }
1393 __attribute ((__abi_tag__ (
"cxx11")))
1395 imag()
const {
return __imag__ _M_value; }
1398 real() {
return __real__ _M_value; }
1401 real()
const {
return __real__ _M_value; }
1404 imag() {
return __imag__ _M_value; }
1407 imag()
const {
return __imag__ _M_value; }
1412 _GLIBCXX20_CONSTEXPR
void
1413 real(
float __val) { __real__ _M_value = __val; }
1415 _GLIBCXX20_CONSTEXPR
void
1416 imag(
float __val) { __imag__ _M_value = __val; }
1455#if __cplusplus >= 201103L
1459 template<
typename _Tp>
1463 __real__ _M_value = __z.real();
1464 __imag__ _M_value = __z.imag();
1468 template<
typename _Tp>
1472 _M_value += __z.__rep();
1480 _M_value -= __z.__rep();
1488 const _ComplexT __t = __z.__rep();
1497 const _ComplexT __t = __z.__rep();
1502 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1515 typedef __complex__
double _ComplexT;
1517 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1519 _GLIBCXX_CONSTEXPR
complex(
double __r = 0.0,
double __i = 0.0)
1520#if __cplusplus >= 201103L
1521 : _M_value{ __r, __i } { }
1524 __real__ _M_value = __r;
1525 __imag__ _M_value = __i;
1529#if __cplusplus >= 201103L
1533#if __cplusplus > 202002L
1534 template<
typename _Up>
1535 explicit(!
requires(_Up __u) { value_type{__u}; })
1540 : _M_value(__z.__rep()) { }
1545#if __cplusplus >= 201103L
1548 __attribute ((__abi_tag__ (
"cxx11")))
1550 real()
const {
return __real__ _M_value; }
1552 __attribute ((__abi_tag__ (
"cxx11")))
1554 imag()
const {
return __imag__ _M_value; }
1557 real() {
return __real__ _M_value; }
1560 real()
const {
return __real__ _M_value; }
1563 imag() {
return __imag__ _M_value; }
1566 imag()
const {
return __imag__ _M_value; }
1571 _GLIBCXX20_CONSTEXPR
void
1572 real(
double __val) { __real__ _M_value = __val; }
1574 _GLIBCXX20_CONSTEXPR
void
1575 imag(
double __val) { __imag__ _M_value = __val; }
1613#if __cplusplus >= 201103L
1617 template<
typename _Tp>
1621 _M_value = __z.__rep();
1625 template<
typename _Tp>
1629 _M_value += __z.__rep();
1633 template<
typename _Tp>
1637 _M_value -= __z.__rep();
1641 template<
typename _Tp>
1645 const _ComplexT __t = __z.__rep();
1650 template<
typename _Tp>
1654 const _ComplexT __t = __z.__rep();
1659 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1672 typedef __complex__
long double _ComplexT;
1674 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1676 _GLIBCXX_CONSTEXPR
complex(
long double __r = 0.0L,
1677 long double __i = 0.0L)
1678#if __cplusplus >= 201103L
1679 : _M_value{ __r, __i } { }
1682 __real__ _M_value = __r;
1683 __imag__ _M_value = __i;
1687#if __cplusplus >= 201103L
1691#if __cplusplus > 202002L
1692 template<
typename _Up>
1693 explicit(!
requires(_Up __u) { value_type{__u}; })
1698 : _M_value(__z.__rep()) { }
1701 : _M_value(__z.__rep()) { }
1704#if __cplusplus >= 201103L
1707 __attribute ((__abi_tag__ (
"cxx11")))
1708 constexpr long double
1709 real()
const {
return __real__ _M_value; }
1711 __attribute ((__abi_tag__ (
"cxx11")))
1712 constexpr long double
1713 imag()
const {
return __imag__ _M_value; }
1716 real() {
return __real__ _M_value; }
1719 real()
const {
return __real__ _M_value; }
1722 imag() {
return __imag__ _M_value; }
1725 imag()
const {
return __imag__ _M_value; }
1730 _GLIBCXX20_CONSTEXPR
void
1731 real(
long double __val) { __real__ _M_value = __val; }
1733 _GLIBCXX20_CONSTEXPR
void
1734 imag(
long double __val) { __imag__ _M_value = __val; }
1772#if __cplusplus >= 201103L
1776 template<
typename _Tp>
1780 _M_value = __z.__rep();
1784 template<
typename _Tp>
1788 _M_value += __z.__rep();
1792 template<
typename _Tp>
1796 _M_value -= __z.__rep();
1800 template<
typename _Tp>
1804 const _ComplexT __t = __z.__rep();
1809 template<
typename _Tp>
1813 const _ComplexT __t = __z.__rep();
1818 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1824#if __cplusplus > 202002L
1825 template<
typename _Tp>
1826 struct __complex_type
1829#ifdef __STDCPP_FLOAT16_T__
1831 struct __complex_type<_Float16>
1832 {
typedef __complex__ _Float16 type; };
1835#ifdef __STDCPP_FLOAT32_T__
1837 struct __complex_type<_Float32>
1838 {
typedef __complex__ _Float32 type; };
1841#ifdef __STDCPP_FLOAT64_T__
1843 struct __complex_type<_Float64>
1844 {
typedef __complex__ _Float64 type; };
1847#ifdef __STDCPP_FLOAT128_T__
1849 struct __complex_type<_Float128>
1850 {
typedef __complex__ _Float128 type; };
1853#ifdef __STDCPP_BFLOAT16_T__
1855 struct __complex_type<
__gnu_cxx::__bfloat16_t>
1856 {
typedef __complex__
decltype(0.0bf16) type; };
1859 template<
typename _Tp>
1860 requires requires {
typename __complex_type<_Tp>::type; }
1865 typedef typename std::__complex_type<_Tp>::type _ComplexT;
1867 constexpr complex(_ComplexT __z) : _M_value(__z) { }
1869 constexpr complex(_Tp __r = _Tp(), _Tp __i = _Tp())
1870 : _M_value{ __r, __i } { }
1872 template<
typename _Up>
1873 explicit(!
requires(_Up __u) {
value_type{__u}; })
1874 constexpr complex(
const complex<_Up>& __z)
1878 real()
const {
return __real__ _M_value; }
1881 imag()
const {
return __imag__ _M_value; }
1884 real(_Tp __val) { __real__ _M_value = __val; }
1887 imag(_Tp __val) { __imag__ _M_value = __val; }
1926 constexpr complex(
const complex&) =
default;
1929 template<
typename _Up>
1933 __real__ _M_value = __z.real();
1934 __imag__ _M_value = __z.imag();
1938 template<
typename _Up>
1942 _M_value += __z.__rep();
1950 _M_value -= __z.__rep();
1958 const _ComplexT __t = __z.__rep();
1967 const _ComplexT __t = __z.__rep();
1972 constexpr _ComplexT __rep()
const {
return _M_value; }
1979#if __cplusplus <= 202002L
1982 inline _GLIBCXX_CONSTEXPR
1984 : _M_value(__z.__rep()) { }
1986 inline _GLIBCXX_CONSTEXPR
1988 : _M_value(__z.__rep()) { }
1990 inline _GLIBCXX_CONSTEXPR
1992 : _M_value(__z.__rep()) { }
1998#if _GLIBCXX_EXTERN_TEMPLATE
2006#ifdef _GLIBCXX_USE_WCHAR_T
2018_GLIBCXX_END_NAMESPACE_VERSION
2021#if __cplusplus >= 201103L
2023namespace std _GLIBCXX_VISIBILITY(
default)
2025_GLIBCXX_BEGIN_NAMESPACE_VERSION
2038 template<
typename _Tp>
2043 const _Tp __pi_2 = (_Tp) 1.5707963267948966192313216916397514L;
2047#if _GLIBCXX_USE_C99_COMPLEX_ARC
2048#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2049 inline __complex__ _Float16
2050 __complex_acos(__complex__ _Float16 __z)
2051 {
return static_cast<__complex__ _Float16
>(__builtin_cacosf(__z)); }
2053 inline __complex__ _Float16
2054 __complex_asin(__complex__ _Float16 __z)
2055 {
return static_cast<__complex__ _Float16
>(__builtin_casinf(__z)); }
2057 inline __complex__ _Float16
2058 __complex_atan(__complex__ _Float16 __z)
2059 {
return static_cast<__complex__ _Float16
>(__builtin_catanf(__z)); }
2061 inline __complex__ _Float16
2062 __complex_acosh(__complex__ _Float16 __z)
2063 {
return static_cast<__complex__ _Float16
>(__builtin_cacoshf(__z)); }
2065 inline __complex__ _Float16
2066 __complex_asinh(__complex__ _Float16 __z)
2067 {
return static_cast<__complex__ _Float16
>(__builtin_casinhf(__z)); }
2069 inline __complex__ _Float16
2070 __complex_atanh(__complex__ _Float16 __z)
2071 {
return static_cast<__complex__ _Float16
>(__builtin_catanhf(__z)); }
2074#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2075 inline __complex__ _Float32
2076 __complex_acos(__complex__ _Float32 __z)
2077 {
return __builtin_cacosf(__z); }
2079 inline __complex__ _Float32
2080 __complex_asin(__complex__ _Float32 __z)
2081 {
return __builtin_casinf(__z); }
2083 inline __complex__ _Float32
2084 __complex_atan(__complex__ _Float32 __z)
2085 {
return __builtin_catanf(__z); }
2087 inline __complex__ _Float32
2088 __complex_acosh(__complex__ _Float32 __z)
2089 {
return __builtin_cacoshf(__z); }
2091 inline __complex__ _Float32
2092 __complex_asinh(__complex__ _Float32 __z)
2093 {
return __builtin_casinhf(__z); }
2095 inline __complex__ _Float32
2096 __complex_atanh(__complex__ _Float32 __z)
2097 {
return __builtin_catanhf(__z); }
2100#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
2101 inline __complex__ _Float64
2102 __complex_acos(__complex__ _Float64 __z)
2103 {
return __builtin_cacos(__z); }
2105 inline __complex__ _Float64
2106 __complex_asin(__complex__ _Float64 __z)
2107 {
return __builtin_casin(__z); }
2109 inline __complex__ _Float64
2110 __complex_atan(__complex__ _Float64 __z)
2111 {
return __builtin_catan(__z); }
2113 inline __complex__ _Float64
2114 __complex_acosh(__complex__ _Float64 __z)
2115 {
return __builtin_cacosh(__z); }
2117 inline __complex__ _Float64
2118 __complex_asinh(__complex__ _Float64 __z)
2119 {
return __builtin_casinh(__z); }
2121 inline __complex__ _Float64
2122 __complex_atanh(__complex__ _Float64 __z)
2123 {
return __builtin_catanh(__z); }
2126#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
2127 inline __complex__ _Float128
2128 __complex_acos(__complex__ _Float128 __z)
2129 {
return __builtin_cacosl(__z); }
2131 inline __complex__ _Float128
2132 __complex_asin(__complex__ _Float128 __z)
2133 {
return __builtin_casinl(__z); }
2135 inline __complex__ _Float128
2136 __complex_atan(__complex__ _Float128 __z)
2137 {
return __builtin_catanl(__z); }
2139 inline __complex__ _Float128
2140 __complex_acosh(__complex__ _Float128 __z)
2141 {
return __builtin_cacoshl(__z); }
2143 inline __complex__ _Float128
2144 __complex_asinh(__complex__ _Float128 __z)
2145 {
return __builtin_casinhl(__z); }
2147 inline __complex__ _Float128
2148 __complex_atanh(__complex__ _Float128 __z)
2149 {
return __builtin_catanhl(__z); }
2150#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
2151 inline __complex__ _Float128
2152 __complex_acos(__complex__ _Float128 __z)
2153 {
return __builtin_cacosf128(__z); }
2155 inline __complex__ _Float128
2156 __complex_asin(__complex__ _Float128 __z)
2157 {
return __builtin_casinf128(__z); }
2159 inline __complex__ _Float128
2160 __complex_atan(__complex__ _Float128 __z)
2161 {
return __builtin_catanf128(__z); }
2163 inline __complex__ _Float128
2164 __complex_acosh(__complex__ _Float128 __z)
2165 {
return __builtin_cacoshf128(__z); }
2167 inline __complex__ _Float128
2168 __complex_asinh(__complex__ _Float128 __z)
2169 {
return __builtin_casinhf128(__z); }
2171 inline __complex__ _Float128
2172 __complex_atanh(__complex__ _Float128 __z)
2173 {
return __builtin_catanhf128(__z); }
2176#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2177 inline __complex__
decltype(0.0bf16)
2178 __complex_acos(__complex__
decltype(0.0bf16) __z)
2179 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_cacosf(__z)); }
2181 inline __complex__
decltype(0.0bf16)
2182 __complex_asin(__complex__
decltype(0.0bf16) __z)
2183 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_casinf(__z)); }
2185 inline __complex__
decltype(0.0bf16)
2186 __complex_atan(__complex__
decltype(0.0bf16) __z)
2187 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_catanf(__z)); }
2189 inline __complex__
decltype(0.0bf16)
2190 __complex_acosh(__complex__
decltype(0.0bf16) __z)
2191 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_cacoshf(__z)); }
2193 inline __complex__
decltype(0.0bf16)
2194 __complex_asinh(__complex__
decltype(0.0bf16) __z)
2195 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_casinhf(__z)); }
2197 inline __complex__
decltype(0.0bf16)
2198 __complex_atanh(__complex__
decltype(0.0bf16) __z)
2199 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_catanhf(__z)); }
2203#if _GLIBCXX_USE_C99_COMPLEX_ARC
2204 inline __complex__
float
2205 __complex_acos(__complex__
float __z)
2206 {
return __builtin_cacosf(__z); }
2208 inline __complex__
double
2209 __complex_acos(__complex__
double __z)
2210 {
return __builtin_cacos(__z); }
2212 inline __complex__
long double
2213 __complex_acos(
const __complex__
long double& __z)
2214 {
return __builtin_cacosl(__z); }
2216 template<
typename _Tp>
2219 {
return __complex_acos(__z.__rep()); }
2224 template<
typename _Tp>
2227 {
return __complex_acos(__z); }
2230 template<
typename _Tp>
2235 __t = std::asinh(__t);
2239#if _GLIBCXX_USE_C99_COMPLEX_ARC
2240 inline __complex__
float
2241 __complex_asin(__complex__
float __z)
2242 {
return __builtin_casinf(__z); }
2244 inline __complex__
double
2245 __complex_asin(__complex__
double __z)
2246 {
return __builtin_casin(__z); }
2248 inline __complex__
long double
2249 __complex_asin(
const __complex__
long double& __z)
2250 {
return __builtin_casinl(__z); }
2252 template<
typename _Tp>
2255 {
return __complex_asin(__z.__rep()); }
2260 template<
typename _Tp>
2263 {
return __complex_asin(__z); }
2266 template<
typename _Tp>
2270 const _Tp __r2 = __z.real() * __z.real();
2271 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
2273 _Tp __num = __z.imag() + _Tp(1.0);
2274 _Tp __den = __z.imag() - _Tp(1.0);
2276 __num = __r2 + __num * __num;
2277 __den = __r2 + __den * __den;
2280 _Tp(0.25) *
log(__num / __den));
2283#if _GLIBCXX_USE_C99_COMPLEX_ARC
2284 inline __complex__
float
2285 __complex_atan(__complex__
float __z)
2286 {
return __builtin_catanf(__z); }
2288 inline __complex__
double
2289 __complex_atan(__complex__
double __z)
2290 {
return __builtin_catan(__z); }
2292 inline __complex__
long double
2293 __complex_atan(
const __complex__
long double& __z)
2294 {
return __builtin_catanl(__z); }
2296 template<
typename _Tp>
2299 {
return __complex_atan(__z.__rep()); }
2304 template<
typename _Tp>
2307 {
return __complex_atan(__z); }
2310 template<
typename _Tp>
2316 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
2319#if _GLIBCXX_USE_C99_COMPLEX_ARC
2320 inline __complex__
float
2321 __complex_acosh(__complex__
float __z)
2322 {
return __builtin_cacoshf(__z); }
2324 inline __complex__
double
2325 __complex_acosh(__complex__
double __z)
2326 {
return __builtin_cacosh(__z); }
2328 inline __complex__
long double
2329 __complex_acosh(
const __complex__
long double& __z)
2330 {
return __builtin_cacoshl(__z); }
2332 template<
typename _Tp>
2335 {
return __complex_acosh(__z.__rep()); }
2340 template<
typename _Tp>
2343 {
return __complex_acosh(__z); }
2346 template<
typename _Tp>
2351 * (__z.real() + __z.imag()) + _Tp(1.0),
2352 _Tp(2.0) * __z.real() * __z.imag());
2358#if _GLIBCXX_USE_C99_COMPLEX_ARC
2359 inline __complex__
float
2360 __complex_asinh(__complex__
float __z)
2361 {
return __builtin_casinhf(__z); }
2363 inline __complex__
double
2364 __complex_asinh(__complex__
double __z)
2365 {
return __builtin_casinh(__z); }
2367 inline __complex__
long double
2368 __complex_asinh(
const __complex__
long double& __z)
2369 {
return __builtin_casinhl(__z); }
2371 template<
typename _Tp>
2374 {
return __complex_asinh(__z.__rep()); }
2379 template<
typename _Tp>
2382 {
return __complex_asinh(__z); }
2385 template<
typename _Tp>
2389 const _Tp __i2 = __z.imag() * __z.imag();
2390 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
2392 _Tp __num = _Tp(1.0) + __z.real();
2393 _Tp __den = _Tp(1.0) - __z.real();
2395 __num = __i2 + __num * __num;
2396 __den = __i2 + __den * __den;
2399 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
2402#if _GLIBCXX_USE_C99_COMPLEX_ARC
2403 inline __complex__
float
2404 __complex_atanh(__complex__
float __z)
2405 {
return __builtin_catanhf(__z); }
2407 inline __complex__
double
2408 __complex_atanh(__complex__
double __z)
2409 {
return __builtin_catanh(__z); }
2411 inline __complex__
long double
2412 __complex_atanh(
const __complex__
long double& __z)
2413 {
return __builtin_catanhl(__z); }
2415 template<
typename _Tp>
2418 {
return __complex_atanh(__z.__rep()); }
2423 template<
typename _Tp>
2426 {
return __complex_atanh(__z); }
2429 template<
typename _Tp>
2438 template<
typename _Tp>
2439 inline typename __gnu_cxx::__promote<_Tp>::__type
2442 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
2443#if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
2444 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
2451 template<
typename _Tp>
2452 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
2456 template<
typename _Tp>
2457 _GLIBCXX20_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
2460 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
2461 return __type(__x) * __type(__x);
2464 template<
typename _Tp>
2465 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
2469 template<
typename _Tp,
typename _Up>
2473 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
2477 template<
typename _Tp,
typename _Up>
2481 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
2485 template<
typename _Tp,
typename _Up>
2489 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
2496 template<
typename _Tp>
2500 template<
typename _Tp>
2505#if _GLIBCXX_USE_C99_COMPLEX
2506 inline complex<float>
2507 __complex_proj(
const complex<float>& __z)
2508 {
return __builtin_cprojf(__z.__rep()); }
2510 inline complex<double>
2511 __complex_proj(
const complex<double>& __z)
2512 {
return __builtin_cproj(__z.__rep()); }
2514 inline complex<long double>
2515 __complex_proj(
const complex<long double>& __z)
2516 {
return __builtin_cprojl(__z.__rep()); }
2518#if __cplusplus > 202002L
2519#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2520 inline __complex__ _Float16
2521 __complex_proj(__complex__ _Float16 __z)
2522 {
return static_cast<__complex__ _Float16
>(__builtin_cprojf(__z)); }
2525#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2526 inline __complex__ _Float32
2527 __complex_proj(__complex__ _Float32 __z)
2528 {
return __builtin_cprojf(__z); }
2531#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
2532 inline __complex__ _Float64
2533 __complex_proj(__complex__ _Float64 __z)
2534 {
return __builtin_cproj(__z); }
2537#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
2538 inline __complex__ _Float128
2539 __complex_proj(__complex__ _Float128 __z)
2540 {
return __builtin_cprojl(__z); }
2541#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
2542 inline __complex__ _Float128
2543 __complex_proj(__complex__ _Float128 __z)
2544 {
return __builtin_cprojf128(__z); }
2547#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2548 inline __complex__
decltype(0.0bf16)
2549 __complex_proj(__complex__
decltype(0.0bf16) __z)
2550 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_cprojf(__z)); }
2553 template<
typename _Tp>
2554 requires requires {
typename __complex_type<_Tp>::type; }
2556 __complex_proj(
const complex<_Tp>& __z)
2557 {
return __complex_proj(__z.__rep()); }
2560#elif defined _GLIBCXX_USE_C99_MATH_FUNCS
2561 inline complex<float>
2562 __complex_proj(
const complex<float>& __z)
2564 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
2565 return complex<float>(__builtin_inff(),
2566 __builtin_copysignf(0.0f, __z.imag()));
2570 inline complex<double>
2571 __complex_proj(
const complex<double>& __z)
2573 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
2574 return complex<double>(__builtin_inf(),
2575 __builtin_copysign(0.0, __z.imag()));
2579 inline complex<long double>
2580 __complex_proj(
const complex<long double>& __z)
2582 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
2583 return complex<long double>(__builtin_infl(),
2584 __builtin_copysignl(0.0l, __z.imag()));
2589 template<
typename _Tp>
2592 {
return __complex_proj(__z); }
2595 template<
typename _Tp>
2599 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
2603 template<
typename _Tp>
2604 inline _GLIBCXX20_CONSTEXPR
2608 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
2612#ifdef __cpp_lib_complex_udls
2614inline namespace literals {
2615inline namespace complex_literals {
2616#pragma GCC diagnostic push
2617#pragma GCC diagnostic ignored "-Wliteral-suffix"
2620 operator""if(
long double __num)
2624 operator""if(
unsigned long long __num)
2628 operator""i(
long double __num)
2632 operator""i(
unsigned long long __num)
2636 operator""il(
long double __num)
2640 operator""il(
unsigned long long __num)
2643#pragma GCC diagnostic pop
2649_GLIBCXX_END_NAMESPACE_VERSION
2654#ifdef _GLIBCXX_CLANG
2655#pragma clang diagnostic pop
2658#pragma GCC diagnostic pop
complex< _Tp > log10(const complex< _Tp > &)
Return complex base 10 logarithm of z.
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
constexpr complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
constexpr complex< _Tp > & operator*=(const _Tp &)
Multiply this complex number by a scalar.
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
complex< _Tp > tan(const complex< _Tp > &)
Return complex tangent of z.
complex< _Tp > polar(const _Tp &, const _Tp &=0)
Return complex with magnitude rho and angle theta.
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
complex< _Tp > cosh(const complex< _Tp > &)
Return complex hyperbolic cosine of z.
_Tp arg(const complex< _Tp > &)
Return phase angle of z.
constexpr complex< _Tp > & operator=(const _Tp &)
Assign a scalar to this complex number.
complex< _Tp > tanh(const complex< _Tp > &)
Return complex hyperbolic tangent of z.
constexpr complex< _Tp > conj(const complex< _Tp > &)
Return complex conjugate of z.
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
constexpr complex< _Tp > operator/(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x divided by y.
complex< _Tp > sinh(const complex< _Tp > &)
Return complex hyperbolic sine of z.
_Tp constexpr norm(const complex< _Tp > &)
Return z magnitude squared.
constexpr complex< _Tp > & operator/=(const _Tp &)
Divide this complex number by a scalar.
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
basic_ostream< char > ostream
Base class for char output streams.
basic_istream< char > istream
Base class for char input streams.
basic_ostream< wchar_t > wostream
Base class for wchar_t output streams.
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
ISO C++ entities toplevel namespace is std.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
GNU extensions for public use.
_Tp value_type
Value typedef.
constexpr complex(const _Tp &__r=_Tp(), const _Tp &__i=_Tp())
Default constructor. First parameter is x, second parameter is y. Unspecified parameters default to 0...
constexpr complex(const complex< _Up > &__z)
Converting constructor.
constexpr complex< _Tp > & operator-=(const _Tp &__t)
Subtract a scalar from this complex number.
constexpr complex< _Tp > & operator+=(const _Tp &__t)
Add a scalar to this complex number.
void setstate(iostate __state)
Sets additional flags in the error state.
char_type widen(char __c) const
Widens characters.
Template class basic_istream.
__istream_type & putback(char_type __c)
Unextracting a single character.
fmtflags flags() const
Access to format flags.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...