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>
146 : _M_real(__z.real()), _M_imag(__z.imag()) { }
148#if __cplusplus >= 201103L
151 _GLIBCXX_ABI_TAG_CXX11
153 real()
const {
return _M_real; }
155 _GLIBCXX_ABI_TAG_CXX11
157 imag()
const {
return _M_imag; }
161 real() {
return _M_real; }
165 real()
const {
return _M_real; }
169 imag() {
return _M_imag; }
173 imag()
const {
return _M_imag; }
178 _GLIBCXX20_CONSTEXPR
void
179 real(_Tp __val) { _M_real = __val; }
181 _GLIBCXX20_CONSTEXPR
void
182 imag(_Tp __val) { _M_imag = __val; }
185 _GLIBCXX20_CONSTEXPR complex<_Tp>&
operator=(
const _Tp&);
189 _GLIBCXX20_CONSTEXPR complex<_Tp>&
211#if __cplusplus >= 201103L
216 template<
typename _Up>
219 template<
typename _Up>
222 template<
typename _Up>
225 template<
typename _Up>
228 template<
typename _Up>
231 _GLIBCXX_CONSTEXPR
complex __rep()
const
239 template<
typename _Tp>
240 _GLIBCXX20_CONSTEXPR complex<_Tp>&
249 template<
typename _Tp>
259 template<
typename _Tp>
268 template<
typename _Tp>
269 template<
typename _Up>
273 _M_real = __z.real();
274 _M_imag = __z.imag();
279 template<
typename _Tp>
280 template<
typename _Up>
284 _M_real += __z.real();
285 _M_imag += __z.imag();
290 template<
typename _Tp>
291 template<
typename _Up>
295 _M_real -= __z.real();
296 _M_imag -= __z.imag();
302 template<
typename _Tp>
303 template<
typename _Up>
307 const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
308 _M_imag = _M_real * __z.imag() + _M_imag * __z.real();
315 template<
typename _Tp>
316 template<
typename _Up>
320 const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag();
322 _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n;
330 template<
typename _Tp>
339 template<
typename _Tp>
340 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
348 template<
typename _Tp>
349 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
360 template<
typename _Tp>
361 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
369 template<
typename _Tp>
370 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
378 template<
typename _Tp>
379 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
390 template<
typename _Tp>
391 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
399 template<
typename _Tp>
400 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
408 template<
typename _Tp>
409 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
420 template<
typename _Tp>
421 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
429 template<
typename _Tp>
430 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
438 template<
typename _Tp>
439 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
449 template<
typename _Tp>
450 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
455 template<
typename _Tp>
456 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
462 template<
typename _Tp>
463 inline _GLIBCXX_CONSTEXPR
bool
465 {
return __x.real() == __y.real() && __x.imag() == __y.imag(); }
467 template<
typename _Tp>
468 inline _GLIBCXX_CONSTEXPR
bool
470 {
return __x.real() == __y && __x.imag() == _Tp(); }
472#if !(__cpp_impl_three_way_comparison >= 201907L)
473 template<
typename _Tp>
474 inline _GLIBCXX_CONSTEXPR
bool
475 operator==(
const _Tp& __x,
const complex<_Tp>& __y)
476 {
return __x == __y.real() && _Tp() == __y.imag(); }
481 template<
typename _Tp>
482 inline _GLIBCXX_CONSTEXPR
bool
483 operator!=(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
484 {
return __x.real() != __y.real() || __x.imag() != __y.imag(); }
486 template<
typename _Tp>
487 inline _GLIBCXX_CONSTEXPR
bool
488 operator!=(
const complex<_Tp>& __x,
const _Tp& __y)
489 {
return __x.real() != __y || __x.imag() != _Tp(); }
491 template<
typename _Tp>
492 inline _GLIBCXX_CONSTEXPR
bool
493 operator!=(
const _Tp& __x,
const complex<_Tp>& __y)
494 {
return __x != __y.real() || _Tp() != __y.imag(); }
499 template<
typename _Tp,
typename _CharT,
class _Traits>
500 basic_istream<_CharT, _Traits>&
507 if (_Traits::eq(__ch, __is.
widen(
'(')))
510 if (__is >> __u >> __ch)
512 const _CharT __rparen = __is.
widen(
')');
513 if (_Traits::eq(__ch, __rparen))
518 else if (_Traits::eq(__ch, __is.
widen(
',')))
521 if (__is >> __v >> __ch)
523 if (_Traits::eq(__ch, __rparen))
553 template<
typename _Tp,
typename _CharT,
class _Traits>
554 basic_ostream<_CharT, _Traits>&
555 operator<<(basic_ostream<_CharT, _Traits>& __os,
const complex<_Tp>& __x)
557 basic_ostringstream<_CharT, _Traits> __s;
558 __s.
flags(__os.flags());
559 __s.imbue(__os.getloc());
560 __s.precision(__os.precision());
561 __s <<
'(' << __x.real() <<
',' << __x.imag() <<
')';
562 return __os << __s.str();
566#if __cplusplus >= 201103L
567 template<
typename _Tp>
569 real(
const complex<_Tp>& __z)
570 {
return __z.real(); }
572 template<
typename _Tp>
574 imag(
const complex<_Tp>& __z)
575 {
return __z.imag(); }
577 template<
typename _Tp>
579 real(complex<_Tp>& __z)
580 {
return __z.real(); }
582 template<
typename _Tp>
584 real(
const complex<_Tp>& __z)
585 {
return __z.real(); }
587 template<
typename _Tp>
589 imag(complex<_Tp>& __z)
590 {
return __z.imag(); }
592 template<
typename _Tp>
594 imag(
const complex<_Tp>& __z)
595 {
return __z.imag(); }
599 template<
typename _Tp>
601 __complex_abs(
const complex<_Tp>& __z)
603 _Tp __x = __z.real();
604 _Tp __y = __z.imag();
610 return __s *
sqrt(__x * __x + __y * __y);
613#if _GLIBCXX_USE_C99_COMPLEX
615 __complex_abs(__complex__
float __z) {
return __builtin_cabsf(__z); }
618 __complex_abs(__complex__
double __z) {
return __builtin_cabs(__z); }
621 __complex_abs(
const __complex__
long double& __z)
622 {
return __builtin_cabsl(__z); }
624 template<
typename _Tp>
626 abs(
const complex<_Tp>& __z) {
return __complex_abs(__z.__rep()); }
628 template<
typename _Tp>
635 template<
typename _Tp>
637 __complex_arg(
const complex<_Tp>& __z)
638 {
return atan2(__z.imag(), __z.real()); }
640#if _GLIBCXX_USE_C99_COMPLEX
642 __complex_arg(__complex__
float __z) {
return __builtin_cargf(__z); }
645 __complex_arg(__complex__
double __z) {
return __builtin_carg(__z); }
648 __complex_arg(
const __complex__
long double& __z)
649 {
return __builtin_cargl(__z); }
651 template<
typename _Tp>
653 arg(
const complex<_Tp>& __z) {
return __complex_arg(__z.__rep()); }
655 template<
typename _Tp>
668 template<
typename _Tp>
669 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
671 const _Tp __x = __z.real();
672 const _Tp __y = __z.imag();
673 return __x * __x + __y * __y;
678 struct _Norm_helper<true>
680 template<
typename _Tp>
681 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
685 const _Tp __x = __z.real();
686 const _Tp __y = __z.imag();
687 return __x * __x + __y * __y;
691 template<
typename _Tp>
692 inline _GLIBCXX20_CONSTEXPR _Tp
695 return _Norm_helper<__is_floating<_Tp>::__value
696 && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
699 template<
typename _Tp>
701 polar(
const _Tp& __rho,
const _Tp& __theta)
703 __glibcxx_assert( __rho >= 0 );
707 template<
typename _Tp>
708 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
715 template<
typename _Tp>
717 __complex_cos(
const complex<_Tp>& __z)
719 const _Tp __x = __z.real();
720 const _Tp __y = __z.imag();
721 return complex<_Tp>(cos(__x) * cosh(__y), -sin(__x) * sinh(__y));
724#if _GLIBCXX_USE_C99_COMPLEX
725 inline __complex__
float
726 __complex_cos(__complex__
float __z) {
return __builtin_ccosf(__z); }
728 inline __complex__
double
729 __complex_cos(__complex__
double __z) {
return __builtin_ccos(__z); }
731 inline __complex__
long double
732 __complex_cos(
const __complex__
long double& __z)
733 {
return __builtin_ccosl(__z); }
735 template<
typename _Tp>
737 cos(
const complex<_Tp>& __z) {
return __complex_cos(__z.__rep()); }
739 template<
typename _Tp>
745 template<
typename _Tp>
747 __complex_cosh(
const complex<_Tp>& __z)
749 const _Tp __x = __z.real();
750 const _Tp __y = __z.imag();
751 return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y));
754#if _GLIBCXX_USE_C99_COMPLEX
755 inline __complex__
float
756 __complex_cosh(__complex__
float __z) {
return __builtin_ccoshf(__z); }
758 inline __complex__
double
759 __complex_cosh(__complex__
double __z) {
return __builtin_ccosh(__z); }
761 inline __complex__
long double
762 __complex_cosh(
const __complex__
long double& __z)
763 {
return __builtin_ccoshl(__z); }
765 template<
typename _Tp>
767 cosh(
const complex<_Tp>& __z) {
return __complex_cosh(__z.__rep()); }
769 template<
typename _Tp>
775 template<
typename _Tp>
777 __complex_exp(
const complex<_Tp>& __z)
778 {
return std::polar<_Tp>(exp(__z.real()), __z.imag()); }
780#if _GLIBCXX_USE_C99_COMPLEX
781 inline __complex__
float
782 __complex_exp(__complex__
float __z) {
return __builtin_cexpf(__z); }
784 inline __complex__
double
785 __complex_exp(__complex__
double __z) {
return __builtin_cexp(__z); }
787 inline __complex__
long double
788 __complex_exp(
const __complex__
long double& __z)
789 {
return __builtin_cexpl(__z); }
791 template<
typename _Tp>
793 exp(
const complex<_Tp>& __z) {
return __complex_exp(__z.__rep()); }
795 template<
typename _Tp>
802 template<
typename _Tp>
804 __complex_log(
const complex<_Tp>& __z)
807#if _GLIBCXX_USE_C99_COMPLEX
808 inline __complex__
float
809 __complex_log(__complex__
float __z) {
return __builtin_clogf(__z); }
811 inline __complex__
double
812 __complex_log(__complex__
double __z) {
return __builtin_clog(__z); }
814 inline __complex__
long double
815 __complex_log(
const __complex__
long double& __z)
816 {
return __builtin_clogl(__z); }
818 template<
typename _Tp>
820 log(
const complex<_Tp>& __z) {
return __complex_log(__z.__rep()); }
822 template<
typename _Tp>
827 template<
typename _Tp>
833 template<
typename _Tp>
835 __complex_sin(
const complex<_Tp>& __z)
837 const _Tp __x = __z.real();
838 const _Tp __y = __z.imag();
839 return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y));
842#if _GLIBCXX_USE_C99_COMPLEX
843 inline __complex__
float
844 __complex_sin(__complex__
float __z) {
return __builtin_csinf(__z); }
846 inline __complex__
double
847 __complex_sin(__complex__
double __z) {
return __builtin_csin(__z); }
849 inline __complex__
long double
850 __complex_sin(
const __complex__
long double& __z)
851 {
return __builtin_csinl(__z); }
853 template<
typename _Tp>
855 sin(
const complex<_Tp>& __z) {
return __complex_sin(__z.__rep()); }
857 template<
typename _Tp>
863 template<
typename _Tp>
865 __complex_sinh(
const complex<_Tp>& __z)
867 const _Tp __x = __z.real();
868 const _Tp __y = __z.imag();
869 return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y));
872#if _GLIBCXX_USE_C99_COMPLEX
873 inline __complex__
float
874 __complex_sinh(__complex__
float __z) {
return __builtin_csinhf(__z); }
876 inline __complex__
double
877 __complex_sinh(__complex__
double __z) {
return __builtin_csinh(__z); }
879 inline __complex__
long double
880 __complex_sinh(
const __complex__
long double& __z)
881 {
return __builtin_csinhl(__z); }
883 template<
typename _Tp>
885 sinh(
const complex<_Tp>& __z) {
return __complex_sinh(__z.__rep()); }
887 template<
typename _Tp>
894 template<
typename _Tp>
896 __complex_sqrt(
const complex<_Tp>& __z)
898 _Tp __x = __z.real();
899 _Tp __y = __z.imag();
903 _Tp __t = sqrt(abs(__y) / 2);
904 return complex<_Tp>(__t, __y < _Tp() ? -__t : __t);
911 ? complex<_Tp>(__u, __y / __t)
912 : complex<_Tp>(
abs(__y) / __t, __y < _Tp() ? -__u : __u);
916#if _GLIBCXX_USE_C99_COMPLEX
917 inline __complex__
float
918 __complex_sqrt(__complex__
float __z) {
return __builtin_csqrtf(__z); }
920 inline __complex__
double
921 __complex_sqrt(__complex__
double __z) {
return __builtin_csqrt(__z); }
923 inline __complex__
long double
924 __complex_sqrt(
const __complex__
long double& __z)
925 {
return __builtin_csqrtl(__z); }
927 template<
typename _Tp>
929 sqrt(
const complex<_Tp>& __z) {
return __complex_sqrt(__z.__rep()); }
931 template<
typename _Tp>
938 template<
typename _Tp>
940 __complex_tan(
const complex<_Tp>& __z)
943#if _GLIBCXX_USE_C99_COMPLEX
944 inline __complex__
float
945 __complex_tan(__complex__
float __z) {
return __builtin_ctanf(__z); }
947 inline __complex__
double
948 __complex_tan(__complex__
double __z) {
return __builtin_ctan(__z); }
950 inline __complex__
long double
951 __complex_tan(
const __complex__
long double& __z)
952 {
return __builtin_ctanl(__z); }
954 template<
typename _Tp>
956 tan(
const complex<_Tp>& __z) {
return __complex_tan(__z.__rep()); }
958 template<
typename _Tp>
966 template<
typename _Tp>
968 __complex_tanh(
const complex<_Tp>& __z)
971#if _GLIBCXX_USE_C99_COMPLEX
972 inline __complex__
float
973 __complex_tanh(__complex__
float __z) {
return __builtin_ctanhf(__z); }
975 inline __complex__
double
976 __complex_tanh(__complex__
double __z) {
return __builtin_ctanh(__z); }
978 inline __complex__
long double
979 __complex_tanh(
const __complex__
long double& __z)
980 {
return __builtin_ctanhl(__z); }
982 template<
typename _Tp>
984 tanh(
const complex<_Tp>& __z) {
return __complex_tanh(__z.__rep()); }
986 template<
typename _Tp>
995 template<
typename _Tp>
997 __complex_pow_unsigned(complex<_Tp> __x,
unsigned __n)
999 complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1);
1017 template<
typename _Tp>
1022 ?
complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(
unsigned)__n)
1023 : std::__complex_pow_unsigned(__z, __n);
1026 template<
typename _Tp>
1030#if ! _GLIBCXX_USE_C99_COMPLEX
1034 if (__x.imag() == _Tp() && __x.real() > _Tp())
1035 return pow(__x.real(), __y);
1038 return std::polar<_Tp>(
exp(__y * __t.real()), __y * __t.imag());
1041 template<
typename _Tp>
1043 __complex_pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1044 {
return __x == _Tp() ? _Tp() :
std::exp(__y *
std::log(__x)); }
1046#if _GLIBCXX_USE_C99_COMPLEX
1047 inline __complex__
float
1048 __complex_pow(__complex__
float __x, __complex__
float __y)
1049 {
return __builtin_cpowf(__x, __y); }
1051 inline __complex__
double
1052 __complex_pow(__complex__
double __x, __complex__
double __y)
1053 {
return __builtin_cpow(__x, __y); }
1055 inline __complex__
long double
1056 __complex_pow(
const __complex__
long double& __x,
1057 const __complex__
long double& __y)
1058 {
return __builtin_cpowl(__x, __y); }
1060 template<
typename _Tp>
1062 pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1063 {
return __complex_pow(__x.__rep(), __y.__rep()); }
1065 template<
typename _Tp>
1068 {
return __complex_pow(__x, __y); }
1071 template<
typename _Tp>
1075 return __x > _Tp() ? std::polar<_Tp>(
pow(__x, __y.real()),
1076 __y.imag() *
log(__x))
1087 typedef __complex__
float _ComplexT;
1089 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1091 _GLIBCXX_CONSTEXPR
complex(
float __r = 0.0f,
float __i = 0.0f)
1092#if __cplusplus >= 201103L
1093 : _M_value{ __r, __i } { }
1096 __real__ _M_value = __r;
1097 __imag__ _M_value = __i;
1101#if __cplusplus >= 201103L
1108#if __cplusplus >= 201103L
1111 __attribute ((__abi_tag__ (
"cxx11")))
1113 real()
const {
return __real__ _M_value; }
1115 __attribute ((__abi_tag__ (
"cxx11")))
1117 imag()
const {
return __imag__ _M_value; }
1120 real() {
return __real__ _M_value; }
1123 real()
const {
return __real__ _M_value; }
1126 imag() {
return __imag__ _M_value; }
1129 imag()
const {
return __imag__ _M_value; }
1134 _GLIBCXX20_CONSTEXPR
void
1135 real(
float __val) { __real__ _M_value = __val; }
1137 _GLIBCXX20_CONSTEXPR
void
1138 imag(
float __val) { __imag__ _M_value = __val; }
1177#if __cplusplus >= 201103L
1181 template<
typename _Tp>
1185 __real__ _M_value = __z.real();
1186 __imag__ _M_value = __z.imag();
1190 template<
typename _Tp>
1194 _M_value += __z.__rep();
1202 _M_value -= __z.__rep();
1210 const _ComplexT __t = __z.__rep();
1219 const _ComplexT __t = __z.__rep();
1224 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1237 typedef __complex__
double _ComplexT;
1239 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1241 _GLIBCXX_CONSTEXPR
complex(
double __r = 0.0,
double __i = 0.0)
1242#if __cplusplus >= 201103L
1243 : _M_value{ __r, __i } { }
1246 __real__ _M_value = __r;
1247 __imag__ _M_value = __i;
1251#if __cplusplus >= 201103L
1256 : _M_value(__z.__rep()) { }
1260#if __cplusplus >= 201103L
1263 __attribute ((__abi_tag__ (
"cxx11")))
1265 real()
const {
return __real__ _M_value; }
1267 __attribute ((__abi_tag__ (
"cxx11")))
1269 imag()
const {
return __imag__ _M_value; }
1272 real() {
return __real__ _M_value; }
1275 real()
const {
return __real__ _M_value; }
1278 imag() {
return __imag__ _M_value; }
1281 imag()
const {
return __imag__ _M_value; }
1286 _GLIBCXX20_CONSTEXPR
void
1287 real(
double __val) { __real__ _M_value = __val; }
1289 _GLIBCXX20_CONSTEXPR
void
1290 imag(
double __val) { __imag__ _M_value = __val; }
1328#if __cplusplus >= 201103L
1332 template<
typename _Tp>
1336 _M_value = __z.__rep();
1340 template<
typename _Tp>
1344 _M_value += __z.__rep();
1348 template<
typename _Tp>
1352 _M_value -= __z.__rep();
1356 template<
typename _Tp>
1360 const _ComplexT __t = __z.__rep();
1365 template<
typename _Tp>
1369 const _ComplexT __t = __z.__rep();
1374 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1387 typedef __complex__
long double _ComplexT;
1389 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1391 _GLIBCXX_CONSTEXPR
complex(
long double __r = 0.0L,
1392 long double __i = 0.0L)
1393#if __cplusplus >= 201103L
1394 : _M_value{ __r, __i } { }
1397 __real__ _M_value = __r;
1398 __imag__ _M_value = __i;
1402#if __cplusplus >= 201103L
1407 : _M_value(__z.__rep()) { }
1410 : _M_value(__z.__rep()) { }
1412#if __cplusplus >= 201103L
1415 __attribute ((__abi_tag__ (
"cxx11")))
1416 constexpr long double
1417 real()
const {
return __real__ _M_value; }
1419 __attribute ((__abi_tag__ (
"cxx11")))
1420 constexpr long double
1421 imag()
const {
return __imag__ _M_value; }
1424 real() {
return __real__ _M_value; }
1427 real()
const {
return __real__ _M_value; }
1430 imag() {
return __imag__ _M_value; }
1433 imag()
const {
return __imag__ _M_value; }
1438 _GLIBCXX20_CONSTEXPR
void
1439 real(
long double __val) { __real__ _M_value = __val; }
1441 _GLIBCXX20_CONSTEXPR
void
1442 imag(
long double __val) { __imag__ _M_value = __val; }
1480#if __cplusplus >= 201103L
1484 template<
typename _Tp>
1488 _M_value = __z.__rep();
1492 template<
typename _Tp>
1496 _M_value += __z.__rep();
1500 template<
typename _Tp>
1504 _M_value -= __z.__rep();
1508 template<
typename _Tp>
1512 const _ComplexT __t = __z.__rep();
1517 template<
typename _Tp>
1521 const _ComplexT __t = __z.__rep();
1526 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1534 inline _GLIBCXX_CONSTEXPR
1536 : _M_value(__z.__rep()) { }
1538 inline _GLIBCXX_CONSTEXPR
1540 : _M_value(__z.__rep()) { }
1542 inline _GLIBCXX_CONSTEXPR
1544 : _M_value(__z.__rep()) { }
1549#if _GLIBCXX_EXTERN_TEMPLATE
1557#ifdef _GLIBCXX_USE_WCHAR_T
1569_GLIBCXX_END_NAMESPACE_VERSION
1572#if __cplusplus >= 201103L
1574namespace std _GLIBCXX_VISIBILITY(
default)
1576_GLIBCXX_BEGIN_NAMESPACE_VERSION
1589 template<
typename _Tp>
1594 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
1598#if _GLIBCXX_USE_C99_COMPLEX_TR1
1599 inline __complex__
float
1600 __complex_acos(__complex__
float __z)
1601 {
return __builtin_cacosf(__z); }
1603 inline __complex__
double
1604 __complex_acos(__complex__
double __z)
1605 {
return __builtin_cacos(__z); }
1607 inline __complex__
long double
1608 __complex_acos(
const __complex__
long double& __z)
1609 {
return __builtin_cacosl(__z); }
1611 template<
typename _Tp>
1614 {
return __complex_acos(__z.__rep()); }
1619 template<
typename _Tp>
1622 {
return __complex_acos(__z); }
1625 template<
typename _Tp>
1630 __t = std::asinh(__t);
1634#if _GLIBCXX_USE_C99_COMPLEX_TR1
1635 inline __complex__
float
1636 __complex_asin(__complex__
float __z)
1637 {
return __builtin_casinf(__z); }
1639 inline __complex__
double
1640 __complex_asin(__complex__
double __z)
1641 {
return __builtin_casin(__z); }
1643 inline __complex__
long double
1644 __complex_asin(
const __complex__
long double& __z)
1645 {
return __builtin_casinl(__z); }
1647 template<
typename _Tp>
1650 {
return __complex_asin(__z.__rep()); }
1655 template<
typename _Tp>
1658 {
return __complex_asin(__z); }
1661 template<
typename _Tp>
1665 const _Tp __r2 = __z.real() * __z.real();
1666 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
1668 _Tp __num = __z.imag() + _Tp(1.0);
1669 _Tp __den = __z.imag() - _Tp(1.0);
1671 __num = __r2 + __num * __num;
1672 __den = __r2 + __den * __den;
1675 _Tp(0.25) *
log(__num / __den));
1678#if _GLIBCXX_USE_C99_COMPLEX_TR1
1679 inline __complex__
float
1680 __complex_atan(__complex__
float __z)
1681 {
return __builtin_catanf(__z); }
1683 inline __complex__
double
1684 __complex_atan(__complex__
double __z)
1685 {
return __builtin_catan(__z); }
1687 inline __complex__
long double
1688 __complex_atan(
const __complex__
long double& __z)
1689 {
return __builtin_catanl(__z); }
1691 template<
typename _Tp>
1694 {
return __complex_atan(__z.__rep()); }
1699 template<
typename _Tp>
1702 {
return __complex_atan(__z); }
1705 template<
typename _Tp>
1711 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
1714#if _GLIBCXX_USE_C99_COMPLEX_TR1
1715 inline __complex__
float
1716 __complex_acosh(__complex__
float __z)
1717 {
return __builtin_cacoshf(__z); }
1719 inline __complex__
double
1720 __complex_acosh(__complex__
double __z)
1721 {
return __builtin_cacosh(__z); }
1723 inline __complex__
long double
1724 __complex_acosh(
const __complex__
long double& __z)
1725 {
return __builtin_cacoshl(__z); }
1727 template<
typename _Tp>
1730 {
return __complex_acosh(__z.__rep()); }
1735 template<
typename _Tp>
1738 {
return __complex_acosh(__z); }
1741 template<
typename _Tp>
1746 * (__z.real() + __z.imag()) + _Tp(1.0),
1747 _Tp(2.0) * __z.real() * __z.imag());
1753#if _GLIBCXX_USE_C99_COMPLEX_TR1
1754 inline __complex__
float
1755 __complex_asinh(__complex__
float __z)
1756 {
return __builtin_casinhf(__z); }
1758 inline __complex__
double
1759 __complex_asinh(__complex__
double __z)
1760 {
return __builtin_casinh(__z); }
1762 inline __complex__
long double
1763 __complex_asinh(
const __complex__
long double& __z)
1764 {
return __builtin_casinhl(__z); }
1766 template<
typename _Tp>
1769 {
return __complex_asinh(__z.__rep()); }
1774 template<
typename _Tp>
1777 {
return __complex_asinh(__z); }
1780 template<
typename _Tp>
1784 const _Tp __i2 = __z.imag() * __z.imag();
1785 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
1787 _Tp __num = _Tp(1.0) + __z.real();
1788 _Tp __den = _Tp(1.0) - __z.real();
1790 __num = __i2 + __num * __num;
1791 __den = __i2 + __den * __den;
1794 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
1797#if _GLIBCXX_USE_C99_COMPLEX_TR1
1798 inline __complex__
float
1799 __complex_atanh(__complex__
float __z)
1800 {
return __builtin_catanhf(__z); }
1802 inline __complex__
double
1803 __complex_atanh(__complex__
double __z)
1804 {
return __builtin_catanh(__z); }
1806 inline __complex__
long double
1807 __complex_atanh(
const __complex__
long double& __z)
1808 {
return __builtin_catanhl(__z); }
1810 template<
typename _Tp>
1813 {
return __complex_atanh(__z.__rep()); }
1818 template<
typename _Tp>
1821 {
return __complex_atanh(__z); }
1824 template<
typename _Tp>
1833 template<
typename _Tp>
1834 inline typename __gnu_cxx::__promote<_Tp>::__type
1837 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1838#if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
1839 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
1846 template<
typename _Tp>
1847 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1851 template<
typename _Tp>
1852 _GLIBCXX20_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1855 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1856 return __type(__x) * __type(__x);
1859 template<
typename _Tp>
1860 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1864 template<
typename _Tp,
typename _Up>
1868 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1872 template<
typename _Tp,
typename _Up>
1876 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1880 template<
typename _Tp,
typename _Up>
1884 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1891 template<
typename _Tp>
1895 template<
typename _Tp>
1900#if _GLIBCXX_USE_C99_COMPLEX
1901 inline complex<float>
1902 __complex_proj(
const complex<float>& __z)
1903 {
return __builtin_cprojf(__z.__rep()); }
1905 inline complex<double>
1906 __complex_proj(
const complex<double>& __z)
1907 {
return __builtin_cproj(__z.__rep()); }
1909 inline complex<long double>
1910 __complex_proj(
const complex<long double>& __z)
1911 {
return __builtin_cprojl(__z.__rep()); }
1912#elif defined _GLIBCXX_USE_C99_MATH_TR1
1913 inline complex<float>
1914 __complex_proj(
const complex<float>& __z)
1916 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
1917 return complex<float>(__builtin_inff(),
1918 __builtin_copysignf(0.0f, __z.imag()));
1922 inline complex<double>
1923 __complex_proj(
const complex<double>& __z)
1925 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
1926 return complex<double>(__builtin_inf(),
1927 __builtin_copysign(0.0, __z.imag()));
1931 inline complex<long double>
1932 __complex_proj(
const complex<long double>& __z)
1934 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
1935 return complex<long double>(__builtin_infl(),
1936 __builtin_copysignl(0.0l, __z.imag()));
1941 template<
typename _Tp>
1944 {
return __complex_proj(__z); }
1947 template<
typename _Tp>
1951 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1955 template<
typename _Tp>
1956 inline _GLIBCXX20_CONSTEXPR
1960 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1964#if __cplusplus > 201103L
1966inline namespace literals {
1967inline namespace complex_literals {
1968#pragma GCC diagnostic push
1969#pragma GCC diagnostic ignored "-Wliteral-suffix"
1970#define __cpp_lib_complex_udls 201309L
1973 operator""if(
long double __num)
1977 operator""if(
unsigned long long __num)
1981 operator""i(
long double __num)
1985 operator""i(
unsigned long long __num)
1989 operator""il(
long double __num)
1993 operator""il(
unsigned long long __num)
1996#pragma GCC diagnostic pop
2002_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.
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.
_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...