36#ifndef _GLIBCXX_COMPLEX
37#define _GLIBCXX_COMPLEX 1
39#pragma GCC system_header
50#if __cplusplus > 201703L
51# define __cpp_lib_constexpr_complex 201711L
54namespace std _GLIBCXX_VISIBILITY(default)
56_GLIBCXX_BEGIN_NAMESPACE_VERSION
67 template<
typename _Tp>
class complex;
68 template<>
class complex<float>;
69 template<>
class complex<double>;
70 template<>
class complex<long double>;
73 template<
typename _Tp> _Tp
abs(
const complex<_Tp>&);
75 template<
typename _Tp> _Tp
arg(
const complex<_Tp>&);
77 template<
typename _Tp> _Tp _GLIBCXX20_CONSTEXPR
norm(
const complex<_Tp>&);
80 template<
typename _Tp>
81 _GLIBCXX20_CONSTEXPR complex<_Tp>
conj(
const complex<_Tp>&);
83 template<
typename _Tp> complex<_Tp>
polar(
const _Tp&,
const _Tp& = 0);
87 template<
typename _Tp> complex<_Tp>
cos(
const complex<_Tp>&);
89 template<
typename _Tp> complex<_Tp>
cosh(
const complex<_Tp>&);
91 template<
typename _Tp> complex<_Tp>
exp(
const complex<_Tp>&);
93 template<
typename _Tp> complex<_Tp>
log(
const complex<_Tp>&);
95 template<
typename _Tp> complex<_Tp>
log10(
const complex<_Tp>&);
97 template<
typename _Tp> complex<_Tp>
pow(
const complex<_Tp>&,
int);
99 template<
typename _Tp> complex<_Tp>
pow(
const complex<_Tp>&,
const _Tp&);
101 template<
typename _Tp> complex<_Tp>
pow(
const complex<_Tp>&,
102 const complex<_Tp>&);
104 template<
typename _Tp> complex<_Tp>
pow(
const _Tp&,
const complex<_Tp>&);
106 template<
typename _Tp> complex<_Tp>
sin(
const complex<_Tp>&);
108 template<
typename _Tp> complex<_Tp>
sinh(
const complex<_Tp>&);
110 template<
typename _Tp> complex<_Tp>
sqrt(
const complex<_Tp>&);
112 template<
typename _Tp> complex<_Tp>
tan(
const complex<_Tp>&);
114 template<
typename _Tp> complex<_Tp>
tanh(
const complex<_Tp>&);
126 template<
typename _Tp>
135 _GLIBCXX_CONSTEXPR
complex(
const _Tp& __r = _Tp(),
const _Tp& __i = _Tp())
136 : _M_real(__r), _M_imag(__i) { }
139#if __cplusplus >= 201103L
144 template<
typename _Up>
145#if __cplusplus > 202002L
146 explicit(!
requires(_Up __u) { _Tp{__u}; })
149 : _M_real(_Tp(__z.real())), _M_imag(_Tp(__z.imag())) { }
151#if __cplusplus >= 201103L
154 _GLIBCXX_ABI_TAG_CXX11
156 real()
const {
return _M_real; }
158 _GLIBCXX_ABI_TAG_CXX11
160 imag()
const {
return _M_imag; }
164 real() {
return _M_real; }
168 real()
const {
return _M_real; }
172 imag() {
return _M_imag; }
176 imag()
const {
return _M_imag; }
181 _GLIBCXX20_CONSTEXPR
void
182 real(_Tp __val) { _M_real = __val; }
184 _GLIBCXX20_CONSTEXPR
void
185 imag(_Tp __val) { _M_imag = __val; }
188 _GLIBCXX20_CONSTEXPR complex<_Tp>&
operator=(
const _Tp&);
192 _GLIBCXX20_CONSTEXPR complex<_Tp>&
214#if __cplusplus >= 201103L
219 template<
typename _Up>
222 template<
typename _Up>
225 template<
typename _Up>
228 template<
typename _Up>
231 template<
typename _Up>
234 _GLIBCXX_CONSTEXPR
complex __rep()
const
242 template<
typename _Tp>
243 _GLIBCXX20_CONSTEXPR complex<_Tp>&
252 template<
typename _Tp>
262 template<
typename _Tp>
271 template<
typename _Tp>
272 template<
typename _Up>
276 _M_real = __z.real();
277 _M_imag = __z.imag();
282 template<
typename _Tp>
283 template<
typename _Up>
287 _M_real += __z.real();
288 _M_imag += __z.imag();
293 template<
typename _Tp>
294 template<
typename _Up>
298 _M_real -= __z.real();
299 _M_imag -= __z.imag();
305 template<
typename _Tp>
306 template<
typename _Up>
310 const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
311 _M_imag = _M_real * __z.imag() + _M_imag * __z.real();
318 template<
typename _Tp>
319 template<
typename _Up>
323 const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag();
325 _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n;
333 template<
typename _Tp>
342 template<
typename _Tp>
343 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
351 template<
typename _Tp>
352 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
363 template<
typename _Tp>
364 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
372 template<
typename _Tp>
373 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
381 template<
typename _Tp>
382 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
393 template<
typename _Tp>
394 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
402 template<
typename _Tp>
403 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
411 template<
typename _Tp>
412 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
423 template<
typename _Tp>
424 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
432 template<
typename _Tp>
433 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
441 template<
typename _Tp>
442 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
452 template<
typename _Tp>
453 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
458 template<
typename _Tp>
459 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
465 template<
typename _Tp>
466 inline _GLIBCXX_CONSTEXPR
bool
468 {
return __x.real() == __y.real() && __x.imag() == __y.imag(); }
470 template<
typename _Tp>
471 inline _GLIBCXX_CONSTEXPR
bool
473 {
return __x.real() == __y && __x.imag() == _Tp(); }
475#if !(__cpp_impl_three_way_comparison >= 201907L)
476 template<
typename _Tp>
477 inline _GLIBCXX_CONSTEXPR
bool
478 operator==(
const _Tp& __x,
const complex<_Tp>& __y)
479 {
return __x == __y.real() && _Tp() == __y.imag(); }
484 template<
typename _Tp>
485 inline _GLIBCXX_CONSTEXPR
bool
486 operator!=(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
487 {
return __x.real() != __y.real() || __x.imag() != __y.imag(); }
489 template<
typename _Tp>
490 inline _GLIBCXX_CONSTEXPR
bool
491 operator!=(
const complex<_Tp>& __x,
const _Tp& __y)
492 {
return __x.real() != __y || __x.imag() != _Tp(); }
494 template<
typename _Tp>
495 inline _GLIBCXX_CONSTEXPR
bool
496 operator!=(
const _Tp& __x,
const complex<_Tp>& __y)
497 {
return __x != __y.real() || _Tp() != __y.imag(); }
502 template<
typename _Tp,
typename _CharT,
class _Traits>
503 basic_istream<_CharT, _Traits>&
510 if (_Traits::eq(__ch, __is.
widen(
'(')))
513 if (__is >> __u >> __ch)
515 const _CharT __rparen = __is.
widen(
')');
516 if (_Traits::eq(__ch, __rparen))
521 else if (_Traits::eq(__ch, __is.
widen(
',')))
524 if (__is >> __v >> __ch)
526 if (_Traits::eq(__ch, __rparen))
556 template<
typename _Tp,
typename _CharT,
class _Traits>
557 basic_ostream<_CharT, _Traits>&
558 operator<<(basic_ostream<_CharT, _Traits>& __os,
const complex<_Tp>& __x)
560 basic_ostringstream<_CharT, _Traits> __s;
561 __s.flags(__os.flags());
562 __s.imbue(__os.getloc());
563 __s.precision(__os.precision());
564 __s <<
'(' << __x.real() <<
',' << __x.imag() <<
')';
565 return __os << __s.str();
569#if __cplusplus >= 201103L
570 template<
typename _Tp>
572 real(
const complex<_Tp>& __z)
573 {
return __z.real(); }
575 template<
typename _Tp>
577 imag(
const complex<_Tp>& __z)
578 {
return __z.imag(); }
580 template<
typename _Tp>
582 real(complex<_Tp>& __z)
583 {
return __z.real(); }
585 template<
typename _Tp>
587 real(
const complex<_Tp>& __z)
588 {
return __z.real(); }
590 template<
typename _Tp>
592 imag(complex<_Tp>& __z)
593 {
return __z.imag(); }
595 template<
typename _Tp>
597 imag(
const complex<_Tp>& __z)
598 {
return __z.imag(); }
601#if _GLIBCXX_USE_C99_COMPLEX
602#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
604 __complex_abs(__complex__ _Float16 __z)
605 {
return _Float16(__builtin_cabsf(__z)); }
608 __complex_arg(__complex__ _Float16 __z)
609 {
return _Float16(__builtin_cargf(__z)); }
611 inline __complex__ _Float16
612 __complex_cos(__complex__ _Float16 __z)
613 {
return static_cast<__complex__ _Float16
>(__builtin_ccosf(__z)); }
615 inline __complex__ _Float16
616 __complex_cosh(__complex__ _Float16 __z)
617 {
return static_cast<__complex__ _Float16
>(__builtin_ccoshf(__z)); }
619 inline __complex__ _Float16
620 __complex_exp(__complex__ _Float16 __z)
621 {
return static_cast<__complex__ _Float16
>(__builtin_cexpf(__z)); }
623 inline __complex__ _Float16
624 __complex_log(__complex__ _Float16 __z)
625 {
return static_cast<__complex__ _Float16
>(__builtin_clogf(__z)); }
627 inline __complex__ _Float16
628 __complex_sin(__complex__ _Float16 __z)
629 {
return static_cast<__complex__ _Float16
>(__builtin_csinf(__z)); }
631 inline __complex__ _Float16
632 __complex_sinh(__complex__ _Float16 __z)
633 {
return static_cast<__complex__ _Float16
>(__builtin_csinhf(__z)); }
635 inline __complex__ _Float16
636 __complex_sqrt(__complex__ _Float16 __z)
637 {
return static_cast<__complex__ _Float16
>(__builtin_csqrtf(__z)); }
639 inline __complex__ _Float16
640 __complex_tan(__complex__ _Float16 __z)
641 {
return static_cast<__complex__ _Float16
>(__builtin_ctanf(__z)); }
643 inline __complex__ _Float16
644 __complex_tanh(__complex__ _Float16 __z)
645 {
return static_cast<__complex__ _Float16
>(__builtin_ctanhf(__z)); }
647 inline __complex__ _Float16
648 __complex_pow(__complex__ _Float16 __x, __complex__ _Float16 __y)
649 {
return static_cast<__complex__ _Float16
>(__builtin_cpowf(__x, __y)); }
652#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
654 __complex_abs(__complex__ _Float32 __z) {
return __builtin_cabsf(__z); }
657 __complex_arg(__complex__ _Float32 __z) {
return __builtin_cargf(__z); }
659 inline __complex__ _Float32
660 __complex_cos(__complex__ _Float32 __z) {
return __builtin_ccosf(__z); }
662 inline __complex__ _Float32
663 __complex_cosh(__complex__ _Float32 __z) {
return __builtin_ccoshf(__z); }
665 inline __complex__ _Float32
666 __complex_exp(__complex__ _Float32 __z) {
return __builtin_cexpf(__z); }
668 inline __complex__ _Float32
669 __complex_log(__complex__ _Float32 __z) {
return __builtin_clogf(__z); }
671 inline __complex__ _Float32
672 __complex_sin(__complex__ _Float32 __z) {
return __builtin_csinf(__z); }
674 inline __complex__ _Float32
675 __complex_sinh(__complex__ _Float32 __z) {
return __builtin_csinhf(__z); }
677 inline __complex__ _Float32
678 __complex_sqrt(__complex__ _Float32 __z) {
return __builtin_csqrtf(__z); }
680 inline __complex__ _Float32
681 __complex_tan(__complex__ _Float32 __z) {
return __builtin_ctanf(__z); }
683 inline __complex__ _Float32
684 __complex_tanh(__complex__ _Float32 __z) {
return __builtin_ctanhf(__z); }
686 inline __complex__ _Float32
687 __complex_pow(__complex__ _Float32 __x, __complex__ _Float32 __y)
688 {
return __builtin_cpowf(__x, __y); }
691#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
693 __complex_abs(__complex__ _Float64 __z) {
return __builtin_cabs(__z); }
696 __complex_arg(__complex__ _Float64 __z) {
return __builtin_carg(__z); }
698 inline __complex__ _Float64
699 __complex_cos(__complex__ _Float64 __z) {
return __builtin_ccos(__z); }
701 inline __complex__ _Float64
702 __complex_cosh(__complex__ _Float64 __z) {
return __builtin_ccosh(__z); }
704 inline __complex__ _Float64
705 __complex_exp(__complex__ _Float64 __z) {
return __builtin_cexp(__z); }
707 inline __complex__ _Float64
708 __complex_log(__complex__ _Float64 __z) {
return __builtin_clog(__z); }
710 inline __complex__ _Float64
711 __complex_sin(__complex__ _Float64 __z) {
return __builtin_csin(__z); }
713 inline __complex__ _Float64
714 __complex_sinh(__complex__ _Float64 __z) {
return __builtin_csinh(__z); }
716 inline __complex__ _Float64
717 __complex_sqrt(__complex__ _Float64 __z) {
return __builtin_csqrt(__z); }
719 inline __complex__ _Float64
720 __complex_tan(__complex__ _Float64 __z) {
return __builtin_ctan(__z); }
722 inline __complex__ _Float64
723 __complex_tanh(__complex__ _Float64 __z) {
return __builtin_ctanh(__z); }
725 inline __complex__ _Float64
726 __complex_pow(__complex__ _Float64 __x, __complex__ _Float64 __y)
727 {
return __builtin_cpow(__x, __y); }
730#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
732 __complex_abs(__complex__ _Float128 __z) {
return __builtin_cabsl(__z); }
735 __complex_arg(__complex__ _Float128 __z) {
return __builtin_cargl(__z); }
737 inline __complex__ _Float128
738 __complex_cos(__complex__ _Float128 __z) {
return __builtin_ccosl(__z); }
740 inline __complex__ _Float128
741 __complex_cosh(__complex__ _Float128 __z) {
return __builtin_ccoshl(__z); }
743 inline __complex__ _Float128
744 __complex_exp(__complex__ _Float128 __z) {
return __builtin_cexpl(__z); }
746 inline __complex__ _Float128
747 __complex_log(__complex__ _Float128 __z) {
return __builtin_clogl(__z); }
749 inline __complex__ _Float128
750 __complex_sin(__complex__ _Float128 __z) {
return __builtin_csinl(__z); }
752 inline __complex__ _Float128
753 __complex_sinh(__complex__ _Float128 __z) {
return __builtin_csinhl(__z); }
755 inline __complex__ _Float128
756 __complex_sqrt(__complex__ _Float128 __z) {
return __builtin_csqrtl(__z); }
758 inline __complex__ _Float128
759 __complex_tan(__complex__ _Float128 __z) {
return __builtin_ctanl(__z); }
761 inline __complex__ _Float128
762 __complex_tanh(__complex__ _Float128 __z) {
return __builtin_ctanhl(__z); }
764 inline __complex__ _Float128
765 __complex_pow(__complex__ _Float128 __x, __complex__ _Float128 __y)
766 {
return __builtin_cpowl(__x, __y); }
767#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
769 __complex_abs(__complex__ _Float128 __z) {
return __builtin_cabsf128(__z); }
772 __complex_arg(__complex__ _Float128 __z) {
return __builtin_cargf128(__z); }
774 inline __complex__ _Float128
775 __complex_cos(__complex__ _Float128 __z) {
return __builtin_ccosf128(__z); }
777 inline __complex__ _Float128
778 __complex_cosh(__complex__ _Float128 __z) {
return __builtin_ccoshf128(__z); }
780 inline __complex__ _Float128
781 __complex_exp(__complex__ _Float128 __z) {
return __builtin_cexpf128(__z); }
783 inline __complex__ _Float128
784 __complex_log(__complex__ _Float128 __z) {
return __builtin_clogf128(__z); }
786 inline __complex__ _Float128
787 __complex_sin(__complex__ _Float128 __z) {
return __builtin_csinf128(__z); }
789 inline __complex__ _Float128
790 __complex_sinh(__complex__ _Float128 __z) {
return __builtin_csinhf128(__z); }
792 inline __complex__ _Float128
793 __complex_sqrt(__complex__ _Float128 __z) {
return __builtin_csqrtf128(__z); }
795 inline __complex__ _Float128
796 __complex_tan(__complex__ _Float128 __z) {
return __builtin_ctanf128(__z); }
798 inline __complex__ _Float128
799 __complex_tanh(__complex__ _Float128 __z) {
return __builtin_ctanhf128(__z); }
801 inline __complex__ _Float128
802 __complex_pow(__complex__ _Float128 __x, __complex__ _Float128 __y)
803 {
return __builtin_cpowf128(__x, __y); }
806#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
807 inline __gnu_cxx::__bfloat16_t
808 __complex_abs(__complex__
decltype(0.0bf16) __z)
809 {
return __gnu_cxx::__bfloat16_t(__builtin_cabsf(__z)); }
811 inline __gnu_cxx::__bfloat16_t
812 __complex_arg(__complex__
decltype(0.0bf16) __z)
813 {
return __gnu_cxx::__bfloat16_t(__builtin_cargf(__z)); }
815 inline __complex__
decltype(0.0bf16)
816 __complex_cos(__complex__
decltype(0.0bf16) __z)
817 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_ccosf(__z)); }
819 inline __complex__
decltype(0.0bf16)
820 __complex_cosh(__complex__
decltype(0.0bf16) __z)
821 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_ccoshf(__z)); }
823 inline __complex__
decltype(0.0bf16)
824 __complex_exp(__complex__
decltype(0.0bf16) __z)
825 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_cexpf(__z)); }
827 inline __complex__
decltype(0.0bf16)
828 __complex_log(__complex__
decltype(0.0bf16) __z)
829 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_clogf(__z)); }
831 inline __complex__
decltype(0.0bf16)
832 __complex_sin(__complex__
decltype(0.0bf16) __z)
833 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_csinf(__z)); }
835 inline __complex__
decltype(0.0bf16)
836 __complex_sinh(__complex__
decltype(0.0bf16) __z)
837 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_csinhf(__z)); }
839 inline __complex__
decltype(0.0bf16)
840 __complex_sqrt(__complex__
decltype(0.0bf16) __z)
841 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_csqrtf(__z)); }
843 inline __complex__
decltype(0.0bf16)
844 __complex_tan(__complex__
decltype(0.0bf16) __z)
845 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_ctanf(__z)); }
847 inline __complex__
decltype(0.0bf16)
848 __complex_tanh(__complex__
decltype(0.0bf16) __z)
849 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_ctanhf(__z)); }
851 inline __complex__
decltype(0.0bf16)
852 __complex_pow(__complex__
decltype(0.0bf16) __x,
853 __complex__
decltype(0.0bf16) __y)
854 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_cpowf(__x,
860 template<
typename _Tp>
862 __complex_abs(
const complex<_Tp>& __z)
864 _Tp __x = __z.real();
865 _Tp __y = __z.imag();
871 return __s *
sqrt(__x * __x + __y * __y);
874#if _GLIBCXX_USE_C99_COMPLEX
876 __complex_abs(__complex__
float __z) {
return __builtin_cabsf(__z); }
879 __complex_abs(__complex__
double __z) {
return __builtin_cabs(__z); }
882 __complex_abs(
const __complex__
long double& __z)
883 {
return __builtin_cabsl(__z); }
885 template<
typename _Tp>
887 abs(
const complex<_Tp>& __z) {
return __complex_abs(__z.__rep()); }
889 template<
typename _Tp>
896 template<
typename _Tp>
898 __complex_arg(
const complex<_Tp>& __z)
899 {
return atan2(__z.imag(), __z.real()); }
901#if _GLIBCXX_USE_C99_COMPLEX
903 __complex_arg(__complex__
float __z) {
return __builtin_cargf(__z); }
906 __complex_arg(__complex__
double __z) {
return __builtin_carg(__z); }
909 __complex_arg(
const __complex__
long double& __z)
910 {
return __builtin_cargl(__z); }
912 template<
typename _Tp>
914 arg(
const complex<_Tp>& __z) {
return __complex_arg(__z.__rep()); }
916 template<
typename _Tp>
929 template<
typename _Tp>
930 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
932 const _Tp __x = __z.real();
933 const _Tp __y = __z.imag();
934 return __x * __x + __y * __y;
939 struct _Norm_helper<true>
941 template<
typename _Tp>
942 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
946 const _Tp __x = __z.real();
947 const _Tp __y = __z.imag();
948 return __x * __x + __y * __y;
952 template<
typename _Tp>
953 inline _GLIBCXX20_CONSTEXPR _Tp
956 return _Norm_helper<__is_floating<_Tp>::__value
957 && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
960 template<
typename _Tp>
962 polar(
const _Tp& __rho,
const _Tp& __theta)
964 __glibcxx_assert( __rho >= 0 );
968 template<
typename _Tp>
969 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
976 template<
typename _Tp>
978 __complex_cos(
const complex<_Tp>& __z)
980 const _Tp __x = __z.real();
981 const _Tp __y = __z.imag();
985#if _GLIBCXX_USE_C99_COMPLEX
986 inline __complex__
float
987 __complex_cos(__complex__
float __z) {
return __builtin_ccosf(__z); }
989 inline __complex__
double
990 __complex_cos(__complex__
double __z) {
return __builtin_ccos(__z); }
992 inline __complex__
long double
993 __complex_cos(
const __complex__
long double& __z)
994 {
return __builtin_ccosl(__z); }
996 template<
typename _Tp>
998 cos(
const complex<_Tp>& __z) {
return __complex_cos(__z.__rep()); }
1000 template<
typename _Tp>
1006 template<
typename _Tp>
1008 __complex_cosh(
const complex<_Tp>& __z)
1010 const _Tp __x = __z.real();
1011 const _Tp __y = __z.imag();
1015#if _GLIBCXX_USE_C99_COMPLEX
1016 inline __complex__
float
1017 __complex_cosh(__complex__
float __z) {
return __builtin_ccoshf(__z); }
1019 inline __complex__
double
1020 __complex_cosh(__complex__
double __z) {
return __builtin_ccosh(__z); }
1022 inline __complex__
long double
1023 __complex_cosh(
const __complex__
long double& __z)
1024 {
return __builtin_ccoshl(__z); }
1026 template<
typename _Tp>
1028 cosh(
const complex<_Tp>& __z) {
return __complex_cosh(__z.__rep()); }
1030 template<
typename _Tp>
1036 template<
typename _Tp>
1038 __complex_exp(
const complex<_Tp>& __z)
1039 {
return std::polar<_Tp>(
exp(__z.real()), __z.imag()); }
1041#if _GLIBCXX_USE_C99_COMPLEX
1042 inline __complex__
float
1043 __complex_exp(__complex__
float __z) {
return __builtin_cexpf(__z); }
1045 inline __complex__
double
1046 __complex_exp(__complex__
double __z) {
return __builtin_cexp(__z); }
1048 inline __complex__
long double
1049 __complex_exp(
const __complex__
long double& __z)
1050 {
return __builtin_cexpl(__z); }
1052 template<
typename _Tp>
1054 exp(
const complex<_Tp>& __z) {
return __complex_exp(__z.__rep()); }
1056 template<
typename _Tp>
1063 template<
typename _Tp>
1065 __complex_log(
const complex<_Tp>& __z)
1068#if _GLIBCXX_USE_C99_COMPLEX
1069 inline __complex__
float
1070 __complex_log(__complex__
float __z) {
return __builtin_clogf(__z); }
1072 inline __complex__
double
1073 __complex_log(__complex__
double __z) {
return __builtin_clog(__z); }
1075 inline __complex__
long double
1076 __complex_log(
const __complex__
long double& __z)
1077 {
return __builtin_clogl(__z); }
1079 template<
typename _Tp>
1081 log(
const complex<_Tp>& __z) {
return __complex_log(__z.__rep()); }
1083 template<
typename _Tp>
1088 template<
typename _Tp>
1094 template<
typename _Tp>
1096 __complex_sin(
const complex<_Tp>& __z)
1098 const _Tp __x = __z.real();
1099 const _Tp __y = __z.imag();
1103#if _GLIBCXX_USE_C99_COMPLEX
1104 inline __complex__
float
1105 __complex_sin(__complex__
float __z) {
return __builtin_csinf(__z); }
1107 inline __complex__
double
1108 __complex_sin(__complex__
double __z) {
return __builtin_csin(__z); }
1110 inline __complex__
long double
1111 __complex_sin(
const __complex__
long double& __z)
1112 {
return __builtin_csinl(__z); }
1114 template<
typename _Tp>
1116 sin(
const complex<_Tp>& __z) {
return __complex_sin(__z.__rep()); }
1118 template<
typename _Tp>
1124 template<
typename _Tp>
1126 __complex_sinh(
const complex<_Tp>& __z)
1128 const _Tp __x = __z.real();
1129 const _Tp __y = __z.imag();
1133#if _GLIBCXX_USE_C99_COMPLEX
1134 inline __complex__
float
1135 __complex_sinh(__complex__
float __z) {
return __builtin_csinhf(__z); }
1137 inline __complex__
double
1138 __complex_sinh(__complex__
double __z) {
return __builtin_csinh(__z); }
1140 inline __complex__
long double
1141 __complex_sinh(
const __complex__
long double& __z)
1142 {
return __builtin_csinhl(__z); }
1144 template<
typename _Tp>
1146 sinh(
const complex<_Tp>& __z) {
return __complex_sinh(__z.__rep()); }
1148 template<
typename _Tp>
1155 template<
typename _Tp>
1157 __complex_sqrt(
const complex<_Tp>& __z)
1159 _Tp __x = __z.real();
1160 _Tp __y = __z.imag();
1165 return complex<_Tp>(__t, __y < _Tp() ? -__t : __t);
1172 ? complex<_Tp>(__u, __y / __t)
1173 : complex<_Tp>(
abs(__y) / __t, __y < _Tp() ? -__u : __u);
1177#if _GLIBCXX_USE_C99_COMPLEX
1178 inline __complex__
float
1179 __complex_sqrt(__complex__
float __z) {
return __builtin_csqrtf(__z); }
1181 inline __complex__
double
1182 __complex_sqrt(__complex__
double __z) {
return __builtin_csqrt(__z); }
1184 inline __complex__
long double
1185 __complex_sqrt(
const __complex__
long double& __z)
1186 {
return __builtin_csqrtl(__z); }
1188 template<
typename _Tp>
1190 sqrt(
const complex<_Tp>& __z) {
return __complex_sqrt(__z.__rep()); }
1192 template<
typename _Tp>
1199 template<
typename _Tp>
1201 __complex_tan(
const complex<_Tp>& __z)
1204#if _GLIBCXX_USE_C99_COMPLEX
1205 inline __complex__
float
1206 __complex_tan(__complex__
float __z) {
return __builtin_ctanf(__z); }
1208 inline __complex__
double
1209 __complex_tan(__complex__
double __z) {
return __builtin_ctan(__z); }
1211 inline __complex__
long double
1212 __complex_tan(
const __complex__
long double& __z)
1213 {
return __builtin_ctanl(__z); }
1215 template<
typename _Tp>
1217 tan(
const complex<_Tp>& __z) {
return __complex_tan(__z.__rep()); }
1219 template<
typename _Tp>
1227 template<
typename _Tp>
1229 __complex_tanh(
const complex<_Tp>& __z)
1232#if _GLIBCXX_USE_C99_COMPLEX
1233 inline __complex__
float
1234 __complex_tanh(__complex__
float __z) {
return __builtin_ctanhf(__z); }
1236 inline __complex__
double
1237 __complex_tanh(__complex__
double __z) {
return __builtin_ctanh(__z); }
1239 inline __complex__
long double
1240 __complex_tanh(
const __complex__
long double& __z)
1241 {
return __builtin_ctanhl(__z); }
1243 template<
typename _Tp>
1245 tanh(
const complex<_Tp>& __z) {
return __complex_tanh(__z.__rep()); }
1247 template<
typename _Tp>
1256 template<
typename _Tp>
1258 __complex_pow_unsigned(complex<_Tp> __x,
unsigned __n)
1260 complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1);
1278 template<
typename _Tp>
1283 ?
complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(
unsigned)__n)
1284 : std::__complex_pow_unsigned(__z, __n);
1287 template<
typename _Tp>
1291#if ! _GLIBCXX_USE_C99_COMPLEX
1295 if (__x.imag() == _Tp() && __x.real() > _Tp())
1296 return pow(__x.real(), __y);
1299 return std::polar<_Tp>(
exp(__y * __t.real()), __y * __t.imag());
1302 template<
typename _Tp>
1304 __complex_pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1305 {
return __x == _Tp() ? _Tp() :
std::
exp(__y *
std::
log(__x)); }
1307#if _GLIBCXX_USE_C99_COMPLEX
1308 inline __complex__
float
1309 __complex_pow(__complex__
float __x, __complex__
float __y)
1310 {
return __builtin_cpowf(__x, __y); }
1312 inline __complex__
double
1313 __complex_pow(__complex__
double __x, __complex__
double __y)
1314 {
return __builtin_cpow(__x, __y); }
1316 inline __complex__
long double
1317 __complex_pow(
const __complex__
long double& __x,
1318 const __complex__
long double& __y)
1319 {
return __builtin_cpowl(__x, __y); }
1321 template<
typename _Tp>
1323 pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1324 {
return __complex_pow(__x.__rep(), __y.__rep()); }
1326 template<
typename _Tp>
1329 {
return __complex_pow(__x, __y); }
1332 template<
typename _Tp>
1336 return __x > _Tp() ? std::polar<_Tp>(
pow(__x, __y.real()),
1337 __y.imag() *
log(__x))
1348 typedef __complex__
float _ComplexT;
1350 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1352 _GLIBCXX_CONSTEXPR
complex(
float __r = 0.0f,
float __i = 0.0f)
1353#if __cplusplus >= 201103L
1354 : _M_value{ __r, __i } { }
1357 __real__ _M_value = __r;
1358 __imag__ _M_value = __i;
1362#if __cplusplus > 202002L
1363 template<
typename _Up>
1364 explicit(!
requires(_Up __u) { value_type{__u}; })
1372#if __cplusplus >= 201103L
1375 __attribute ((__abi_tag__ (
"cxx11")))
1377 real()
const {
return __real__ _M_value; }
1379 __attribute ((__abi_tag__ (
"cxx11")))
1381 imag()
const {
return __imag__ _M_value; }
1384 real() {
return __real__ _M_value; }
1387 real()
const {
return __real__ _M_value; }
1390 imag() {
return __imag__ _M_value; }
1393 imag()
const {
return __imag__ _M_value; }
1398 _GLIBCXX20_CONSTEXPR
void
1399 real(
float __val) { __real__ _M_value = __val; }
1401 _GLIBCXX20_CONSTEXPR
void
1402 imag(
float __val) { __imag__ _M_value = __val; }
1441#if __cplusplus >= 201103L
1445 template<
typename _Tp>
1449 __real__ _M_value = __z.real();
1450 __imag__ _M_value = __z.imag();
1454 template<
typename _Tp>
1458 _M_value += __z.__rep();
1466 _M_value -= __z.__rep();
1474 const _ComplexT __t = __z.__rep();
1483 const _ComplexT __t = __z.__rep();
1488 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1501 typedef __complex__
double _ComplexT;
1503 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1505 _GLIBCXX_CONSTEXPR
complex(
double __r = 0.0,
double __i = 0.0)
1506#if __cplusplus >= 201103L
1507 : _M_value{ __r, __i } { }
1510 __real__ _M_value = __r;
1511 __imag__ _M_value = __i;
1515#if __cplusplus > 202002L
1516 template<
typename _Up>
1517 explicit(!
requires(_Up __u) { value_type{__u}; })
1522 : _M_value(__z.__rep()) { }
1527#if __cplusplus >= 201103L
1530 __attribute ((__abi_tag__ (
"cxx11")))
1532 real()
const {
return __real__ _M_value; }
1534 __attribute ((__abi_tag__ (
"cxx11")))
1536 imag()
const {
return __imag__ _M_value; }
1539 real() {
return __real__ _M_value; }
1542 real()
const {
return __real__ _M_value; }
1545 imag() {
return __imag__ _M_value; }
1548 imag()
const {
return __imag__ _M_value; }
1553 _GLIBCXX20_CONSTEXPR
void
1554 real(
double __val) { __real__ _M_value = __val; }
1556 _GLIBCXX20_CONSTEXPR
void
1557 imag(
double __val) { __imag__ _M_value = __val; }
1595#if __cplusplus >= 201103L
1599 template<
typename _Tp>
1603 _M_value = __z.__rep();
1607 template<
typename _Tp>
1611 _M_value += __z.__rep();
1615 template<
typename _Tp>
1619 _M_value -= __z.__rep();
1623 template<
typename _Tp>
1627 const _ComplexT __t = __z.__rep();
1632 template<
typename _Tp>
1636 const _ComplexT __t = __z.__rep();
1641 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1654 typedef __complex__
long double _ComplexT;
1656 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1658 _GLIBCXX_CONSTEXPR
complex(
long double __r = 0.0L,
1659 long double __i = 0.0L)
1660#if __cplusplus >= 201103L
1661 : _M_value{ __r, __i } { }
1664 __real__ _M_value = __r;
1665 __imag__ _M_value = __i;
1669#if __cplusplus > 202002L
1670 template<
typename _Up>
1671 explicit(!
requires(_Up __u) { value_type{__u}; })
1676 : _M_value(__z.__rep()) { }
1679 : _M_value(__z.__rep()) { }
1682#if __cplusplus >= 201103L
1685 __attribute ((__abi_tag__ (
"cxx11")))
1686 constexpr long double
1687 real()
const {
return __real__ _M_value; }
1689 __attribute ((__abi_tag__ (
"cxx11")))
1690 constexpr long double
1691 imag()
const {
return __imag__ _M_value; }
1694 real() {
return __real__ _M_value; }
1697 real()
const {
return __real__ _M_value; }
1700 imag() {
return __imag__ _M_value; }
1703 imag()
const {
return __imag__ _M_value; }
1708 _GLIBCXX20_CONSTEXPR
void
1709 real(
long double __val) { __real__ _M_value = __val; }
1711 _GLIBCXX20_CONSTEXPR
void
1712 imag(
long double __val) { __imag__ _M_value = __val; }
1750#if __cplusplus >= 201103L
1754 template<
typename _Tp>
1758 _M_value = __z.__rep();
1762 template<
typename _Tp>
1766 _M_value += __z.__rep();
1770 template<
typename _Tp>
1774 _M_value -= __z.__rep();
1778 template<
typename _Tp>
1782 const _ComplexT __t = __z.__rep();
1787 template<
typename _Tp>
1791 const _ComplexT __t = __z.__rep();
1796 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1802#if __cplusplus > 202002L
1803 template<
typename _Tp>
1804 struct __complex_type
1807#ifdef __STDCPP_FLOAT16_T__
1809 struct __complex_type<_Float16>
1810 {
typedef __complex__ _Float16 type; };
1813#ifdef __STDCPP_FLOAT32_T__
1815 struct __complex_type<_Float32>
1816 {
typedef __complex__ _Float32 type; };
1819#ifdef __STDCPP_FLOAT64_T__
1821 struct __complex_type<_Float64>
1822 {
typedef __complex__ _Float64 type; };
1825#ifdef __STDCPP_FLOAT128_T__
1827 struct __complex_type<_Float128>
1828 {
typedef __complex__ _Float128 type; };
1831#ifdef __STDCPP_BFLOAT16_T__
1833 struct __complex_type<
__gnu_cxx::__bfloat16_t>
1834 {
typedef __complex__
decltype(0.0bf16) type; };
1837 template<
typename _Tp>
1838 requires requires {
typename __complex_type<_Tp>::type; }
1843 typedef typename std::__complex_type<_Tp>::type _ComplexT;
1845 constexpr complex(_ComplexT __z) : _M_value(__z) { }
1847 constexpr complex(_Tp __r = _Tp(), _Tp __i = _Tp())
1848 : _M_value{ __r, __i } { }
1850 template<
typename _Up>
1851 explicit(!
requires(_Up __u) {
value_type{__u}; })
1852 constexpr complex(
const complex<_Up>& __z)
1856 real()
const {
return __real__ _M_value; }
1859 imag()
const {
return __imag__ _M_value; }
1862 real(_Tp __val) { __real__ _M_value = __val; }
1865 imag(_Tp __val) { __imag__ _M_value = __val; }
1906 template<
typename _Up>
1910 __real__ _M_value = __z.real();
1911 __imag__ _M_value = __z.imag();
1915 template<
typename _Up>
1919 _M_value += __z.__rep();
1927 _M_value -= __z.__rep();
1935 const _ComplexT __t = __z.__rep();
1944 const _ComplexT __t = __z.__rep();
1949 constexpr _ComplexT __rep()
const {
return _M_value; }
1956#if __cplusplus <= 202002L
1959 inline _GLIBCXX_CONSTEXPR
1961 : _M_value(__z.__rep()) { }
1963 inline _GLIBCXX_CONSTEXPR
1965 : _M_value(__z.__rep()) { }
1967 inline _GLIBCXX_CONSTEXPR
1969 : _M_value(__z.__rep()) { }
1975#if _GLIBCXX_EXTERN_TEMPLATE
1983#ifdef _GLIBCXX_USE_WCHAR_T
1995_GLIBCXX_END_NAMESPACE_VERSION
1998#if __cplusplus >= 201103L
2000namespace std _GLIBCXX_VISIBILITY(
default)
2002_GLIBCXX_BEGIN_NAMESPACE_VERSION
2015 template<
typename _Tp>
2020 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
2024#if _GLIBCXX_USE_C99_COMPLEX_TR1
2025#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2026 inline __complex__ _Float16
2027 __complex_acos(__complex__ _Float16 __z)
2028 {
return static_cast<__complex__ _Float16
>(__builtin_cacosf(__z)); }
2030 inline __complex__ _Float16
2031 __complex_asin(__complex__ _Float16 __z)
2032 {
return static_cast<__complex__ _Float16
>(__builtin_casinf(__z)); }
2034 inline __complex__ _Float16
2035 __complex_atan(__complex__ _Float16 __z)
2036 {
return static_cast<__complex__ _Float16
>(__builtin_catanf(__z)); }
2038 inline __complex__ _Float16
2039 __complex_acosh(__complex__ _Float16 __z)
2040 {
return static_cast<__complex__ _Float16
>(__builtin_cacoshf(__z)); }
2042 inline __complex__ _Float16
2043 __complex_asinh(__complex__ _Float16 __z)
2044 {
return static_cast<__complex__ _Float16
>(__builtin_casinhf(__z)); }
2046 inline __complex__ _Float16
2047 __complex_atanh(__complex__ _Float16 __z)
2048 {
return static_cast<__complex__ _Float16
>(__builtin_catanhf(__z)); }
2051#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2052 inline __complex__ _Float32
2053 __complex_acos(__complex__ _Float32 __z)
2054 {
return __builtin_cacosf(__z); }
2056 inline __complex__ _Float32
2057 __complex_asin(__complex__ _Float32 __z)
2058 {
return __builtin_casinf(__z); }
2060 inline __complex__ _Float32
2061 __complex_atan(__complex__ _Float32 __z)
2062 {
return __builtin_catanf(__z); }
2064 inline __complex__ _Float32
2065 __complex_acosh(__complex__ _Float32 __z)
2066 {
return __builtin_cacoshf(__z); }
2068 inline __complex__ _Float32
2069 __complex_asinh(__complex__ _Float32 __z)
2070 {
return __builtin_casinhf(__z); }
2072 inline __complex__ _Float32
2073 __complex_atanh(__complex__ _Float32 __z)
2074 {
return __builtin_catanhf(__z); }
2077#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
2078 inline __complex__ _Float64
2079 __complex_acos(__complex__ _Float64 __z)
2080 {
return __builtin_cacos(__z); }
2082 inline __complex__ _Float64
2083 __complex_asin(__complex__ _Float64 __z)
2084 {
return __builtin_casin(__z); }
2086 inline __complex__ _Float64
2087 __complex_atan(__complex__ _Float64 __z)
2088 {
return __builtin_catan(__z); }
2090 inline __complex__ _Float64
2091 __complex_acosh(__complex__ _Float64 __z)
2092 {
return __builtin_cacosh(__z); }
2094 inline __complex__ _Float64
2095 __complex_asinh(__complex__ _Float64 __z)
2096 {
return __builtin_casinh(__z); }
2098 inline __complex__ _Float64
2099 __complex_atanh(__complex__ _Float64 __z)
2100 {
return __builtin_catanh(__z); }
2103#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
2104 inline __complex__ _Float128
2105 __complex_acos(__complex__ _Float128 __z)
2106 {
return __builtin_cacosl(__z); }
2108 inline __complex__ _Float128
2109 __complex_asin(__complex__ _Float128 __z)
2110 {
return __builtin_casinl(__z); }
2112 inline __complex__ _Float128
2113 __complex_atan(__complex__ _Float128 __z)
2114 {
return __builtin_catanl(__z); }
2116 inline __complex__ _Float128
2117 __complex_acosh(__complex__ _Float128 __z)
2118 {
return __builtin_cacoshl(__z); }
2120 inline __complex__ _Float128
2121 __complex_asinh(__complex__ _Float128 __z)
2122 {
return __builtin_casinhl(__z); }
2124 inline __complex__ _Float128
2125 __complex_atanh(__complex__ _Float128 __z)
2126 {
return __builtin_catanhl(__z); }
2127#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
2128 inline __complex__ _Float128
2129 __complex_acos(__complex__ _Float128 __z)
2130 {
return __builtin_cacosf128(__z); }
2132 inline __complex__ _Float128
2133 __complex_asin(__complex__ _Float128 __z)
2134 {
return __builtin_casinf128(__z); }
2136 inline __complex__ _Float128
2137 __complex_atan(__complex__ _Float128 __z)
2138 {
return __builtin_catanf128(__z); }
2140 inline __complex__ _Float128
2141 __complex_acosh(__complex__ _Float128 __z)
2142 {
return __builtin_cacoshf128(__z); }
2144 inline __complex__ _Float128
2145 __complex_asinh(__complex__ _Float128 __z)
2146 {
return __builtin_casinhf128(__z); }
2148 inline __complex__ _Float128
2149 __complex_atanh(__complex__ _Float128 __z)
2150 {
return __builtin_catanhf128(__z); }
2153#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2154 inline __complex__
decltype(0.0bf16)
2155 __complex_acos(__complex__
decltype(0.0bf16) __z)
2156 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_cacosf(__z)); }
2158 inline __complex__
decltype(0.0bf16)
2159 __complex_asin(__complex__
decltype(0.0bf16) __z)
2160 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_casinf(__z)); }
2162 inline __complex__
decltype(0.0bf16)
2163 __complex_atan(__complex__
decltype(0.0bf16) __z)
2164 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_catanf(__z)); }
2166 inline __complex__
decltype(0.0bf16)
2167 __complex_acosh(__complex__
decltype(0.0bf16) __z)
2168 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_cacoshf(__z)); }
2170 inline __complex__
decltype(0.0bf16)
2171 __complex_asinh(__complex__
decltype(0.0bf16) __z)
2172 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_casinhf(__z)); }
2174 inline __complex__
decltype(0.0bf16)
2175 __complex_atanh(__complex__
decltype(0.0bf16) __z)
2176 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_catanhf(__z)); }
2180#if _GLIBCXX_USE_C99_COMPLEX_TR1
2181 inline __complex__
float
2182 __complex_acos(__complex__
float __z)
2183 {
return __builtin_cacosf(__z); }
2185 inline __complex__
double
2186 __complex_acos(__complex__
double __z)
2187 {
return __builtin_cacos(__z); }
2189 inline __complex__
long double
2190 __complex_acos(
const __complex__
long double& __z)
2191 {
return __builtin_cacosl(__z); }
2193 template<
typename _Tp>
2196 {
return __complex_acos(__z.__rep()); }
2201 template<
typename _Tp>
2204 {
return __complex_acos(__z); }
2207 template<
typename _Tp>
2216#if _GLIBCXX_USE_C99_COMPLEX_TR1
2217 inline __complex__
float
2218 __complex_asin(__complex__
float __z)
2219 {
return __builtin_casinf(__z); }
2221 inline __complex__
double
2222 __complex_asin(__complex__
double __z)
2223 {
return __builtin_casin(__z); }
2225 inline __complex__
long double
2226 __complex_asin(
const __complex__
long double& __z)
2227 {
return __builtin_casinl(__z); }
2229 template<
typename _Tp>
2232 {
return __complex_asin(__z.__rep()); }
2237 template<
typename _Tp>
2240 {
return __complex_asin(__z); }
2243 template<
typename _Tp>
2247 const _Tp __r2 = __z.real() * __z.real();
2248 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
2250 _Tp __num = __z.imag() + _Tp(1.0);
2251 _Tp __den = __z.imag() - _Tp(1.0);
2253 __num = __r2 + __num * __num;
2254 __den = __r2 + __den * __den;
2257 _Tp(0.25) *
log(__num / __den));
2260#if _GLIBCXX_USE_C99_COMPLEX_TR1
2261 inline __complex__
float
2262 __complex_atan(__complex__
float __z)
2263 {
return __builtin_catanf(__z); }
2265 inline __complex__
double
2266 __complex_atan(__complex__
double __z)
2267 {
return __builtin_catan(__z); }
2269 inline __complex__
long double
2270 __complex_atan(
const __complex__
long double& __z)
2271 {
return __builtin_catanl(__z); }
2273 template<
typename _Tp>
2276 {
return __complex_atan(__z.__rep()); }
2281 template<
typename _Tp>
2284 {
return __complex_atan(__z); }
2287 template<
typename _Tp>
2293 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
2296#if _GLIBCXX_USE_C99_COMPLEX_TR1
2297 inline __complex__
float
2298 __complex_acosh(__complex__
float __z)
2299 {
return __builtin_cacoshf(__z); }
2301 inline __complex__
double
2302 __complex_acosh(__complex__
double __z)
2303 {
return __builtin_cacosh(__z); }
2305 inline __complex__
long double
2306 __complex_acosh(
const __complex__
long double& __z)
2307 {
return __builtin_cacoshl(__z); }
2309 template<
typename _Tp>
2312 {
return __complex_acosh(__z.__rep()); }
2317 template<
typename _Tp>
2320 {
return __complex_acosh(__z); }
2323 template<
typename _Tp>
2328 * (__z.real() + __z.imag()) + _Tp(1.0),
2329 _Tp(2.0) * __z.real() * __z.imag());
2335#if _GLIBCXX_USE_C99_COMPLEX_TR1
2336 inline __complex__
float
2337 __complex_asinh(__complex__
float __z)
2338 {
return __builtin_casinhf(__z); }
2340 inline __complex__
double
2341 __complex_asinh(__complex__
double __z)
2342 {
return __builtin_casinh(__z); }
2344 inline __complex__
long double
2345 __complex_asinh(
const __complex__
long double& __z)
2346 {
return __builtin_casinhl(__z); }
2348 template<
typename _Tp>
2351 {
return __complex_asinh(__z.__rep()); }
2356 template<
typename _Tp>
2359 {
return __complex_asinh(__z); }
2362 template<
typename _Tp>
2366 const _Tp __i2 = __z.imag() * __z.imag();
2367 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
2369 _Tp __num = _Tp(1.0) + __z.real();
2370 _Tp __den = _Tp(1.0) - __z.real();
2372 __num = __i2 + __num * __num;
2373 __den = __i2 + __den * __den;
2376 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
2379#if _GLIBCXX_USE_C99_COMPLEX_TR1
2380 inline __complex__
float
2381 __complex_atanh(__complex__
float __z)
2382 {
return __builtin_catanhf(__z); }
2384 inline __complex__
double
2385 __complex_atanh(__complex__
double __z)
2386 {
return __builtin_catanh(__z); }
2388 inline __complex__
long double
2389 __complex_atanh(
const __complex__
long double& __z)
2390 {
return __builtin_catanhl(__z); }
2392 template<
typename _Tp>
2395 {
return __complex_atanh(__z.__rep()); }
2400 template<
typename _Tp>
2403 {
return __complex_atanh(__z); }
2406 template<
typename _Tp>
2415 template<
typename _Tp>
2416 inline typename __gnu_cxx::__promote<_Tp>::__type
2419 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
2420#if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
2421 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
2428 template<
typename _Tp>
2429 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
2433 template<
typename _Tp>
2434 _GLIBCXX20_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
2437 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
2438 return __type(__x) * __type(__x);
2441 template<
typename _Tp>
2442 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
2446 template<
typename _Tp,
typename _Up>
2450 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
2454 template<
typename _Tp,
typename _Up>
2458 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
2462 template<
typename _Tp,
typename _Up>
2466 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
2473 template<
typename _Tp>
2477 template<
typename _Tp>
2482#if _GLIBCXX_USE_C99_COMPLEX
2483 inline complex<float>
2484 __complex_proj(
const complex<float>& __z)
2485 {
return __builtin_cprojf(__z.__rep()); }
2487 inline complex<double>
2488 __complex_proj(
const complex<double>& __z)
2489 {
return __builtin_cproj(__z.__rep()); }
2491 inline complex<long double>
2492 __complex_proj(
const complex<long double>& __z)
2493 {
return __builtin_cprojl(__z.__rep()); }
2495#if __cplusplus > 202002L
2496#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2497 inline __complex__ _Float16
2498 __complex_proj(__complex__ _Float16 __z)
2499 {
return static_cast<__complex__ _Float16
>(__builtin_cprojf(__z)); }
2502#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2503 inline __complex__ _Float32
2504 __complex_proj(__complex__ _Float32 __z)
2505 {
return __builtin_cprojf(__z); }
2508#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
2509 inline __complex__ _Float64
2510 __complex_proj(__complex__ _Float64 __z)
2511 {
return __builtin_cproj(__z); }
2514#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
2515 inline __complex__ _Float128
2516 __complex_proj(__complex__ _Float128 __z)
2517 {
return __builtin_cprojl(__z); }
2518#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
2519 inline __complex__ _Float128
2520 __complex_proj(__complex__ _Float128 __z)
2521 {
return __builtin_cprojf128(__z); }
2524#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2525 inline __complex__
decltype(0.0bf16)
2526 __complex_proj(__complex__
decltype(0.0bf16) __z)
2527 {
return static_cast<__complex__ decltype(0.0bf16)
>(__builtin_cprojf(__z)); }
2530 template<
typename _Tp>
2531 requires requires {
typename __complex_type<_Tp>::type; }
2533 __complex_proj(
const complex<_Tp>& __z)
2534 {
return __complex_proj(__z.__rep()); }
2537#elif defined _GLIBCXX_USE_C99_MATH_TR1
2538 inline complex<float>
2539 __complex_proj(
const complex<float>& __z)
2541 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
2542 return complex<float>(__builtin_inff(),
2543 __builtin_copysignf(0.0f, __z.imag()));
2547 inline complex<double>
2548 __complex_proj(
const complex<double>& __z)
2550 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
2551 return complex<double>(__builtin_inf(),
2552 __builtin_copysign(0.0, __z.imag()));
2556 inline complex<long double>
2557 __complex_proj(
const complex<long double>& __z)
2559 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
2560 return complex<long double>(__builtin_infl(),
2561 __builtin_copysignl(0.0l, __z.imag()));
2566 template<
typename _Tp>
2569 {
return __complex_proj(__z); }
2572 template<
typename _Tp>
2576 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
2580 template<
typename _Tp>
2581 inline _GLIBCXX20_CONSTEXPR
2585 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
2589#if __cplusplus > 201103L
2591inline namespace literals {
2592inline namespace complex_literals {
2593#pragma GCC diagnostic push
2594#pragma GCC diagnostic ignored "-Wliteral-suffix"
2595#define __cpp_lib_complex_udls 201309L
2598 operator""if(
long double __num)
2602 operator""if(
unsigned long long __num)
2606 operator""i(
long double __num)
2610 operator""i(
unsigned long long __num)
2614 operator""il(
long double __num)
2618 operator""il(
unsigned long long __num)
2621#pragma GCC diagnostic pop
2627_GLIBCXX_END_NAMESPACE_VERSION
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.
_Tp fabs(const std::complex< _Tp > &)
fabs(__z) [8.1.8].
std::complex< _Tp > asinh(const std::complex< _Tp > &)
asinh(__z) [8.1.6].
std::complex< _Tp > atan(const std::complex< _Tp > &)
atan(__z) [8.1.4].
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.
std::complex< _Tp > atanh(const std::complex< _Tp > &)
atanh(__z) [8.1.7].
std::complex< _Tp > acosh(const std::complex< _Tp > &)
acosh(__z) [8.1.5].
__gnu_cxx::__promote< _Tp >::__type arg(_Tp __x)
Additional overloads [8.1.9].
std::complex< _Tp > acos(const std::complex< _Tp > &)
acos(__z) [8.1.2].
std::complex< _Tp > asin(const std::complex< _Tp > &)
asin(__z) [8.1.3].
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.
26.2.3 complex specializations complex<float> specialization
26.2.3 complex specializations complex<double> specialization
26.2.3 complex specializations complex<long double> specialization
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.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...