36 #ifndef _GLIBCXX_COMPLEX
37 #define _GLIBCXX_COMPLEX 1
39 #pragma GCC system_header
50 namespace std _GLIBCXX_VISIBILITY(default)
52 _GLIBCXX_BEGIN_NAMESPACE_VERSION
64 template<>
class complex<float>;
65 template<>
class complex<double>;
66 template<>
class complex<long double>;
76 template<
typename _Tp>
122 template<
typename _Tp>
130 _GLIBCXX_CONSTEXPR
complex(
const _Tp& __r = _Tp(),
const _Tp& __i = _Tp())
131 : _M_real(__r), _M_imag(__i) { }
134 #if __cplusplus >= 201103L
139 template<
typename _Up>
141 : _M_real(__z.real()), _M_imag(__z.imag()) { }
143 #if __cplusplus >= 201103L
146 _GLIBCXX_ABI_TAG_CXX11
148 real()
const {
return _M_real; }
150 _GLIBCXX_ABI_TAG_CXX11
152 imag()
const {
return _M_imag; }
156 real() {
return _M_real; }
160 real()
const {
return _M_real; }
164 imag() {
return _M_imag; }
168 imag()
const {
return _M_imag; }
173 _GLIBCXX20_CONSTEXPR
void
174 real(_Tp __val) { _M_real = __val; }
176 _GLIBCXX20_CONSTEXPR
void
177 imag(_Tp __val) { _M_imag = __val; }
180 _GLIBCXX20_CONSTEXPR complex<_Tp>&
operator=(
const _Tp&);
184 _GLIBCXX20_CONSTEXPR complex<_Tp>&
206 #if __cplusplus >= 201103L
211 template<
typename _Up>
214 template<
typename _Up>
217 template<
typename _Up>
220 template<
typename _Up>
223 template<
typename _Up>
226 _GLIBCXX_CONSTEXPR
complex __rep()
const
234 template<
typename _Tp>
235 _GLIBCXX20_CONSTEXPR complex<_Tp>&
244 template<
typename _Tp>
254 template<
typename _Tp>
263 template<
typename _Tp>
264 template<
typename _Up>
268 _M_real = __z.real();
269 _M_imag = __z.imag();
274 template<
typename _Tp>
275 template<
typename _Up>
279 _M_real += __z.real();
280 _M_imag += __z.imag();
285 template<
typename _Tp>
286 template<
typename _Up>
290 _M_real -= __z.real();
291 _M_imag -= __z.imag();
297 template<
typename _Tp>
298 template<
typename _Up>
302 const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
303 _M_imag = _M_real * __z.imag() + _M_imag * __z.real();
310 template<
typename _Tp>
311 template<
typename _Up>
315 const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag();
317 _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n;
325 template<
typename _Tp>
334 template<
typename _Tp>
335 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
343 template<
typename _Tp>
344 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
355 template<
typename _Tp>
356 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
364 template<
typename _Tp>
365 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
373 template<
typename _Tp>
374 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
385 template<
typename _Tp>
386 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
394 template<
typename _Tp>
395 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
403 template<
typename _Tp>
404 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
415 template<
typename _Tp>
416 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
424 template<
typename _Tp>
425 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
433 template<
typename _Tp>
434 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
444 template<
typename _Tp>
445 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
450 template<
typename _Tp>
451 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
457 template<
typename _Tp>
458 inline _GLIBCXX_CONSTEXPR
bool
460 {
return __x.real() == __y.real() && __x.imag() == __y.imag(); }
462 template<
typename _Tp>
463 inline _GLIBCXX_CONSTEXPR
bool
465 {
return __x.real() == __y && __x.imag() == _Tp(); }
467 template<
typename _Tp>
468 inline _GLIBCXX_CONSTEXPR
bool
470 {
return __x == __y.real() && _Tp() == __y.imag(); }
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 template<
typename _Tp>
486 inline _GLIBCXX_CONSTEXPR
bool
488 {
return __x != __y.real() || _Tp() != __y.imag(); }
492 template<
typename _Tp,
typename _CharT,
class _Traits>
493 basic_istream<_CharT, _Traits>&
500 if (_Traits::eq(__ch, __is.
widen(
'(')))
503 if (__is >> __u >> __ch)
505 const _CharT __rparen = __is.
widen(
')');
506 if (_Traits::eq(__ch, __rparen))
511 else if (_Traits::eq(__ch, __is.
widen(
',')))
514 if (__is >> __v >> __ch)
516 if (_Traits::eq(__ch, __rparen))
546 template<
typename _Tp,
typename _CharT,
class _Traits>
547 basic_ostream<_CharT, _Traits>&
548 operator<<(basic_ostream<_CharT, _Traits>& __os,
const complex<_Tp>& __x)
551 __s.
flags(__os.flags());
552 __s.
imbue(__os.getloc());
554 __s <<
'(' << __x.real() <<
',' << __x.imag() <<
')';
555 return __os << __s.
str();
559 #if __cplusplus >= 201103L
560 template<
typename _Tp>
562 real(
const complex<_Tp>& __z)
563 {
return __z.real(); }
565 template<
typename _Tp>
567 imag(
const complex<_Tp>& __z)
568 {
return __z.imag(); }
570 template<
typename _Tp>
572 real(complex<_Tp>& __z)
573 {
return __z.real(); }
575 template<
typename _Tp>
577 real(
const complex<_Tp>& __z)
578 {
return __z.real(); }
580 template<
typename _Tp>
582 imag(complex<_Tp>& __z)
583 {
return __z.imag(); }
585 template<
typename _Tp>
587 imag(
const complex<_Tp>& __z)
588 {
return __z.imag(); }
592 template<
typename _Tp>
594 __complex_abs(
const complex<_Tp>& __z)
596 _Tp __x = __z.real();
597 _Tp __y = __z.imag();
603 return __s *
sqrt(__x * __x + __y * __y);
606 #if _GLIBCXX_USE_C99_COMPLEX
608 __complex_abs(__complex__
float __z) {
return __builtin_cabsf(__z); }
611 __complex_abs(__complex__
double __z) {
return __builtin_cabs(__z); }
614 __complex_abs(
const __complex__
long double& __z)
615 {
return __builtin_cabsl(__z); }
617 template<
typename _Tp>
619 abs(
const complex<_Tp>& __z) {
return __complex_abs(__z.__rep()); }
621 template<
typename _Tp>
628 template<
typename _Tp>
630 __complex_arg(
const complex<_Tp>& __z)
631 {
return atan2(__z.imag(), __z.real()); }
633 #if _GLIBCXX_USE_C99_COMPLEX
635 __complex_arg(__complex__
float __z) {
return __builtin_cargf(__z); }
638 __complex_arg(__complex__
double __z) {
return __builtin_carg(__z); }
641 __complex_arg(
const __complex__
long double& __z)
642 {
return __builtin_cargl(__z); }
644 template<
typename _Tp>
646 arg(
const complex<_Tp>& __z) {
return __complex_arg(__z.__rep()); }
648 template<
typename _Tp>
661 template<
typename _Tp>
662 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
664 const _Tp __x = __z.real();
665 const _Tp __y = __z.imag();
666 return __x * __x + __y * __y;
671 struct _Norm_helper<true>
673 template<
typename _Tp>
674 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
678 const _Tp __x = __z.real();
679 const _Tp __y = __z.imag();
680 return __x * __x + __y * __y;
684 template<
typename _Tp>
685 inline _GLIBCXX20_CONSTEXPR _Tp
688 return _Norm_helper<__is_floating<_Tp>::__value
689 && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
692 template<
typename _Tp>
694 polar(
const _Tp& __rho,
const _Tp& __theta)
696 __glibcxx_assert( __rho >= 0 );
700 template<
typename _Tp>
701 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
708 template<
typename _Tp>
710 __complex_cos(
const complex<_Tp>& __z)
712 const _Tp __x = __z.real();
713 const _Tp __y = __z.imag();
717 #if _GLIBCXX_USE_C99_COMPLEX
718 inline __complex__
float
719 __complex_cos(__complex__
float __z) {
return __builtin_ccosf(__z); }
721 inline __complex__
double
722 __complex_cos(__complex__
double __z) {
return __builtin_ccos(__z); }
724 inline __complex__
long double
725 __complex_cos(
const __complex__
long double& __z)
726 {
return __builtin_ccosl(__z); }
728 template<
typename _Tp>
730 cos(
const complex<_Tp>& __z) {
return __complex_cos(__z.__rep()); }
732 template<
typename _Tp>
738 template<
typename _Tp>
740 __complex_cosh(
const complex<_Tp>& __z)
742 const _Tp __x = __z.real();
743 const _Tp __y = __z.imag();
747 #if _GLIBCXX_USE_C99_COMPLEX
748 inline __complex__
float
749 __complex_cosh(__complex__
float __z) {
return __builtin_ccoshf(__z); }
751 inline __complex__
double
752 __complex_cosh(__complex__
double __z) {
return __builtin_ccosh(__z); }
754 inline __complex__
long double
755 __complex_cosh(
const __complex__
long double& __z)
756 {
return __builtin_ccoshl(__z); }
758 template<
typename _Tp>
760 cosh(
const complex<_Tp>& __z) {
return __complex_cosh(__z.__rep()); }
762 template<
typename _Tp>
768 template<
typename _Tp>
770 __complex_exp(
const complex<_Tp>& __z)
771 {
return std::polar<_Tp>(
exp(__z.real()), __z.imag()); }
773 #if _GLIBCXX_USE_C99_COMPLEX
774 inline __complex__
float
775 __complex_exp(__complex__
float __z) {
return __builtin_cexpf(__z); }
777 inline __complex__
double
778 __complex_exp(__complex__
double __z) {
return __builtin_cexp(__z); }
780 inline __complex__
long double
781 __complex_exp(
const __complex__
long double& __z)
782 {
return __builtin_cexpl(__z); }
784 template<
typename _Tp>
786 exp(
const complex<_Tp>& __z) {
return __complex_exp(__z.__rep()); }
788 template<
typename _Tp>
795 template<
typename _Tp>
797 __complex_log(
const complex<_Tp>& __z)
800 #if _GLIBCXX_USE_C99_COMPLEX
801 inline __complex__
float
802 __complex_log(__complex__
float __z) {
return __builtin_clogf(__z); }
804 inline __complex__
double
805 __complex_log(__complex__
double __z) {
return __builtin_clog(__z); }
807 inline __complex__
long double
808 __complex_log(
const __complex__
long double& __z)
809 {
return __builtin_clogl(__z); }
811 template<
typename _Tp>
813 log(
const complex<_Tp>& __z) {
return __complex_log(__z.__rep()); }
815 template<
typename _Tp>
820 template<
typename _Tp>
826 template<
typename _Tp>
828 __complex_sin(
const complex<_Tp>& __z)
830 const _Tp __x = __z.real();
831 const _Tp __y = __z.imag();
835 #if _GLIBCXX_USE_C99_COMPLEX
836 inline __complex__
float
837 __complex_sin(__complex__
float __z) {
return __builtin_csinf(__z); }
839 inline __complex__
double
840 __complex_sin(__complex__
double __z) {
return __builtin_csin(__z); }
842 inline __complex__
long double
843 __complex_sin(
const __complex__
long double& __z)
844 {
return __builtin_csinl(__z); }
846 template<
typename _Tp>
848 sin(
const complex<_Tp>& __z) {
return __complex_sin(__z.__rep()); }
850 template<
typename _Tp>
856 template<
typename _Tp>
858 __complex_sinh(
const complex<_Tp>& __z)
860 const _Tp __x = __z.real();
861 const _Tp __y = __z.imag();
865 #if _GLIBCXX_USE_C99_COMPLEX
866 inline __complex__
float
867 __complex_sinh(__complex__
float __z) {
return __builtin_csinhf(__z); }
869 inline __complex__
double
870 __complex_sinh(__complex__
double __z) {
return __builtin_csinh(__z); }
872 inline __complex__
long double
873 __complex_sinh(
const __complex__
long double& __z)
874 {
return __builtin_csinhl(__z); }
876 template<
typename _Tp>
878 sinh(
const complex<_Tp>& __z) {
return __complex_sinh(__z.__rep()); }
880 template<
typename _Tp>
887 template<
typename _Tp>
889 __complex_sqrt(
const complex<_Tp>& __z)
891 _Tp __x = __z.real();
892 _Tp __y = __z.imag();
897 return complex<_Tp>(__t, __y < _Tp() ? -__t : __t);
904 ? complex<_Tp>(__u, __y / __t)
905 : complex<_Tp>(
abs(__y) / __t, __y < _Tp() ? -__u : __u);
909 #if _GLIBCXX_USE_C99_COMPLEX
910 inline __complex__
float
911 __complex_sqrt(__complex__
float __z) {
return __builtin_csqrtf(__z); }
913 inline __complex__
double
914 __complex_sqrt(__complex__
double __z) {
return __builtin_csqrt(__z); }
916 inline __complex__
long double
917 __complex_sqrt(
const __complex__
long double& __z)
918 {
return __builtin_csqrtl(__z); }
920 template<
typename _Tp>
922 sqrt(
const complex<_Tp>& __z) {
return __complex_sqrt(__z.__rep()); }
924 template<
typename _Tp>
931 template<
typename _Tp>
933 __complex_tan(
const complex<_Tp>& __z)
936 #if _GLIBCXX_USE_C99_COMPLEX
937 inline __complex__
float
938 __complex_tan(__complex__
float __z) {
return __builtin_ctanf(__z); }
940 inline __complex__
double
941 __complex_tan(__complex__
double __z) {
return __builtin_ctan(__z); }
943 inline __complex__
long double
944 __complex_tan(
const __complex__
long double& __z)
945 {
return __builtin_ctanl(__z); }
947 template<
typename _Tp>
949 tan(
const complex<_Tp>& __z) {
return __complex_tan(__z.__rep()); }
951 template<
typename _Tp>
959 template<
typename _Tp>
961 __complex_tanh(
const complex<_Tp>& __z)
964 #if _GLIBCXX_USE_C99_COMPLEX
965 inline __complex__
float
966 __complex_tanh(__complex__
float __z) {
return __builtin_ctanhf(__z); }
968 inline __complex__
double
969 __complex_tanh(__complex__
double __z) {
return __builtin_ctanh(__z); }
971 inline __complex__
long double
972 __complex_tanh(
const __complex__
long double& __z)
973 {
return __builtin_ctanhl(__z); }
975 template<
typename _Tp>
977 tanh(
const complex<_Tp>& __z) {
return __complex_tanh(__z.__rep()); }
979 template<
typename _Tp>
988 template<
typename _Tp>
990 __complex_pow_unsigned(complex<_Tp> __x,
unsigned __n)
992 complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1);
1010 template<
typename _Tp>
1015 ?
complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(
unsigned)__n)
1016 : std::__complex_pow_unsigned(__z, __n);
1019 template<
typename _Tp>
1023 #if ! _GLIBCXX_USE_C99_COMPLEX
1027 if (__x.imag() == _Tp() && __x.real() > _Tp())
1028 return pow(__x.real(), __y);
1031 return std::polar<_Tp>(
exp(__y * __t.real()), __y * __t.imag());
1034 template<
typename _Tp>
1036 __complex_pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1037 {
return __x == _Tp() ? _Tp() : std::
exp(__y * std::
log(__x)); }
1039 #if _GLIBCXX_USE_C99_COMPLEX
1040 inline __complex__
float
1041 __complex_pow(__complex__
float __x, __complex__
float __y)
1042 {
return __builtin_cpowf(__x, __y); }
1044 inline __complex__
double
1045 __complex_pow(__complex__
double __x, __complex__
double __y)
1046 {
return __builtin_cpow(__x, __y); }
1048 inline __complex__
long double
1049 __complex_pow(
const __complex__
long double& __x,
1050 const __complex__
long double& __y)
1051 {
return __builtin_cpowl(__x, __y); }
1053 template<
typename _Tp>
1055 pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1056 {
return __complex_pow(__x.__rep(), __y.__rep()); }
1058 template<
typename _Tp>
1061 {
return __complex_pow(__x, __y); }
1064 template<
typename _Tp>
1068 return __x > _Tp() ? std::polar<_Tp>(
pow(__x, __y.real()),
1069 __y.imag() *
log(__x))
1079 typedef __complex__
float _ComplexT;
1081 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1083 _GLIBCXX_CONSTEXPR
complex(
float __r = 0.0f,
float __i = 0.0f)
1084 #if __cplusplus >= 201103L
1085 : _M_value{ __r, __i } { }
1088 __real__ _M_value = __r;
1089 __imag__ _M_value = __i;
1096 #if __cplusplus >= 201103L
1099 __attribute ((__abi_tag__ (
"cxx11")))
1101 real()
const {
return __real__ _M_value; }
1103 __attribute ((__abi_tag__ (
"cxx11")))
1105 imag()
const {
return __imag__ _M_value; }
1108 real() {
return __real__ _M_value; }
1111 real()
const {
return __real__ _M_value; }
1114 imag() {
return __imag__ _M_value; }
1117 imag()
const {
return __imag__ _M_value; }
1122 _GLIBCXX20_CONSTEXPR
void
1123 real(
float __val) { __real__ _M_value = __val; }
1125 _GLIBCXX20_CONSTEXPR
void
1126 imag(
float __val) { __imag__ _M_value = __val; }
1128 _GLIBCXX20_CONSTEXPR complex&
1135 _GLIBCXX20_CONSTEXPR complex&
1142 _GLIBCXX20_CONSTEXPR complex&
1149 _GLIBCXX20_CONSTEXPR complex&
1156 _GLIBCXX20_CONSTEXPR complex&
1165 #if __cplusplus >= 201103L
1166 _GLIBCXX14_CONSTEXPR complex&
operator=(
const complex&) =
default;
1169 template<
typename _Tp>
1170 _GLIBCXX20_CONSTEXPR complex&
1173 __real__ _M_value = __z.real();
1174 __imag__ _M_value = __z.imag();
1178 template<
typename _Tp>
1179 _GLIBCXX20_CONSTEXPR complex&
1182 _M_value += __z.__rep();
1187 _GLIBCXX20_CONSTEXPR complex&
1190 _M_value -= __z.__rep();
1195 _GLIBCXX20_CONSTEXPR complex&
1198 const _ComplexT __t = __z.__rep();
1204 _GLIBCXX20_CONSTEXPR complex&
1207 const _ComplexT __t = __z.__rep();
1212 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1224 typedef __complex__
double _ComplexT;
1226 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1228 _GLIBCXX_CONSTEXPR
complex(
double __r = 0.0,
double __i = 0.0)
1229 #if __cplusplus >= 201103L
1230 : _M_value{ __r, __i } { }
1233 __real__ _M_value = __r;
1234 __imag__ _M_value = __i;
1239 : _M_value(__z.__rep()) { }
1243 #if __cplusplus >= 201103L
1246 __attribute ((__abi_tag__ (
"cxx11")))
1248 real()
const {
return __real__ _M_value; }
1250 __attribute ((__abi_tag__ (
"cxx11")))
1252 imag()
const {
return __imag__ _M_value; }
1255 real() {
return __real__ _M_value; }
1258 real()
const {
return __real__ _M_value; }
1261 imag() {
return __imag__ _M_value; }
1264 imag()
const {
return __imag__ _M_value; }
1269 _GLIBCXX20_CONSTEXPR
void
1270 real(
double __val) { __real__ _M_value = __val; }
1272 _GLIBCXX20_CONSTEXPR
void
1273 imag(
double __val) { __imag__ _M_value = __val; }
1275 _GLIBCXX20_CONSTEXPR complex&
1282 _GLIBCXX20_CONSTEXPR complex&
1289 _GLIBCXX20_CONSTEXPR complex&
1296 _GLIBCXX20_CONSTEXPR complex&
1303 _GLIBCXX20_CONSTEXPR complex&
1311 #if __cplusplus >= 201103L
1312 _GLIBCXX14_CONSTEXPR complex&
operator=(
const complex&) =
default;
1315 template<
typename _Tp>
1316 _GLIBCXX20_CONSTEXPR complex&
1319 _M_value = __z.__rep();
1323 template<
typename _Tp>
1324 _GLIBCXX20_CONSTEXPR complex&
1327 _M_value += __z.__rep();
1331 template<
typename _Tp>
1332 _GLIBCXX20_CONSTEXPR complex&
1335 _M_value -= __z.__rep();
1339 template<
typename _Tp>
1340 _GLIBCXX20_CONSTEXPR complex&
1343 const _ComplexT __t = __z.__rep();
1348 template<
typename _Tp>
1349 _GLIBCXX20_CONSTEXPR complex&
1352 const _ComplexT __t = __z.__rep();
1357 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1369 typedef __complex__
long double _ComplexT;
1371 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1373 _GLIBCXX_CONSTEXPR
complex(
long double __r = 0.0L,
1374 long double __i = 0.0L)
1375 #if __cplusplus >= 201103L
1376 : _M_value{ __r, __i } { }
1379 __real__ _M_value = __r;
1380 __imag__ _M_value = __i;
1385 : _M_value(__z.__rep()) { }
1388 : _M_value(__z.__rep()) { }
1390 #if __cplusplus >= 201103L
1393 __attribute ((__abi_tag__ (
"cxx11")))
1394 constexpr
long double
1395 real()
const {
return __real__ _M_value; }
1397 __attribute ((__abi_tag__ (
"cxx11")))
1398 constexpr
long double
1399 imag()
const {
return __imag__ _M_value; }
1402 real() {
return __real__ _M_value; }
1405 real()
const {
return __real__ _M_value; }
1408 imag() {
return __imag__ _M_value; }
1411 imag()
const {
return __imag__ _M_value; }
1416 _GLIBCXX20_CONSTEXPR
void
1417 real(
long double __val) { __real__ _M_value = __val; }
1419 _GLIBCXX20_CONSTEXPR
void
1420 imag(
long double __val) { __imag__ _M_value = __val; }
1422 _GLIBCXX20_CONSTEXPR complex&
1429 _GLIBCXX20_CONSTEXPR complex&
1436 _GLIBCXX20_CONSTEXPR complex&
1443 _GLIBCXX20_CONSTEXPR complex&
1450 _GLIBCXX20_CONSTEXPR complex&
1458 #if __cplusplus >= 201103L
1459 _GLIBCXX14_CONSTEXPR complex&
operator=(
const complex&) =
default;
1462 template<
typename _Tp>
1463 _GLIBCXX20_CONSTEXPR complex&
1466 _M_value = __z.__rep();
1470 template<
typename _Tp>
1471 _GLIBCXX20_CONSTEXPR complex&
1474 _M_value += __z.__rep();
1478 template<
typename _Tp>
1479 _GLIBCXX20_CONSTEXPR complex&
1482 _M_value -= __z.__rep();
1486 template<
typename _Tp>
1487 _GLIBCXX20_CONSTEXPR complex&
1490 const _ComplexT __t = __z.__rep();
1495 template<
typename _Tp>
1496 _GLIBCXX20_CONSTEXPR complex&
1499 const _ComplexT __t = __z.__rep();
1504 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1512 inline _GLIBCXX_CONSTEXPR
1514 : _M_value(__z.__rep()) { }
1516 inline _GLIBCXX_CONSTEXPR
1518 : _M_value(__z.__rep()) { }
1520 inline _GLIBCXX_CONSTEXPR
1522 : _M_value(__z.__rep()) { }
1527 #if _GLIBCXX_EXTERN_TEMPLATE
1529 extern template ostream& operator<<(ostream&, const complex<float>&);
1531 extern template ostream& operator<<(ostream&, const complex<double>&);
1533 extern template ostream& operator<<(ostream&, const complex<long double>&);
1535 #ifdef _GLIBCXX_USE_WCHAR_T
1537 extern template wostream& operator<<(wostream&, const complex<float>&);
1539 extern template wostream& operator<<(wostream&, const complex<double>&);
1541 extern template wostream& operator<<(wostream&, const complex<long double>&);
1547 _GLIBCXX_END_NAMESPACE_VERSION
1550 namespace __gnu_cxx _GLIBCXX_VISIBILITY(
default)
1552 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1555 template<
typename _Tp,
typename _Up>
1556 struct __promote_2<std::complex<_Tp>, _Up>
1562 template<
typename _Tp,
typename _Up>
1563 struct __promote_2<_Tp, std::complex<_Up> >
1569 template<
typename _Tp,
typename _Up>
1570 struct __promote_2<std::complex<_Tp>,
std::complex<_Up> >
1576 _GLIBCXX_END_NAMESPACE_VERSION
1579 #if __cplusplus >= 201103L
1581 namespace std _GLIBCXX_VISIBILITY(default)
1583 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1596 template<
typename _Tp>
1601 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
1605 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1606 inline __complex__
float
1607 __complex_acos(__complex__
float __z)
1608 {
return __builtin_cacosf(__z); }
1610 inline __complex__
double
1611 __complex_acos(__complex__
double __z)
1612 {
return __builtin_cacos(__z); }
1614 inline __complex__
long double
1615 __complex_acos(
const __complex__
long double& __z)
1616 {
return __builtin_cacosl(__z); }
1618 template<
typename _Tp>
1621 {
return __complex_acos(__z.__rep()); }
1626 template<
typename _Tp>
1629 {
return __complex_acos(__z); }
1632 template<
typename _Tp>
1641 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1642 inline __complex__
float
1643 __complex_asin(__complex__
float __z)
1644 {
return __builtin_casinf(__z); }
1646 inline __complex__
double
1647 __complex_asin(__complex__
double __z)
1648 {
return __builtin_casin(__z); }
1650 inline __complex__
long double
1651 __complex_asin(
const __complex__
long double& __z)
1652 {
return __builtin_casinl(__z); }
1654 template<
typename _Tp>
1657 {
return __complex_asin(__z.__rep()); }
1662 template<
typename _Tp>
1665 {
return __complex_asin(__z); }
1668 template<
typename _Tp>
1672 const _Tp __r2 = __z.real() * __z.real();
1673 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
1675 _Tp __num = __z.imag() + _Tp(1.0);
1676 _Tp __den = __z.imag() - _Tp(1.0);
1678 __num = __r2 + __num * __num;
1679 __den = __r2 + __den * __den;
1682 _Tp(0.25) *
log(__num / __den));
1685 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1686 inline __complex__
float
1687 __complex_atan(__complex__
float __z)
1688 {
return __builtin_catanf(__z); }
1690 inline __complex__
double
1691 __complex_atan(__complex__
double __z)
1692 {
return __builtin_catan(__z); }
1694 inline __complex__
long double
1695 __complex_atan(
const __complex__
long double& __z)
1696 {
return __builtin_catanl(__z); }
1698 template<
typename _Tp>
1701 {
return __complex_atan(__z.__rep()); }
1706 template<
typename _Tp>
1709 {
return __complex_atan(__z); }
1712 template<
typename _Tp>
1718 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
1721 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1722 inline __complex__
float
1723 __complex_acosh(__complex__
float __z)
1724 {
return __builtin_cacoshf(__z); }
1726 inline __complex__
double
1727 __complex_acosh(__complex__
double __z)
1728 {
return __builtin_cacosh(__z); }
1730 inline __complex__
long double
1731 __complex_acosh(
const __complex__
long double& __z)
1732 {
return __builtin_cacoshl(__z); }
1734 template<
typename _Tp>
1737 {
return __complex_acosh(__z.__rep()); }
1742 template<
typename _Tp>
1745 {
return __complex_acosh(__z); }
1748 template<
typename _Tp>
1753 * (__z.real() + __z.imag()) + _Tp(1.0),
1754 _Tp(2.0) * __z.real() * __z.imag());
1760 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1761 inline __complex__
float
1762 __complex_asinh(__complex__
float __z)
1763 {
return __builtin_casinhf(__z); }
1765 inline __complex__
double
1766 __complex_asinh(__complex__
double __z)
1767 {
return __builtin_casinh(__z); }
1769 inline __complex__
long double
1770 __complex_asinh(
const __complex__
long double& __z)
1771 {
return __builtin_casinhl(__z); }
1773 template<
typename _Tp>
1776 {
return __complex_asinh(__z.__rep()); }
1781 template<
typename _Tp>
1784 {
return __complex_asinh(__z); }
1787 template<
typename _Tp>
1791 const _Tp __i2 = __z.imag() * __z.imag();
1792 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
1794 _Tp __num = _Tp(1.0) + __z.real();
1795 _Tp __den = _Tp(1.0) - __z.real();
1797 __num = __i2 + __num * __num;
1798 __den = __i2 + __den * __den;
1801 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
1804 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1805 inline __complex__
float
1806 __complex_atanh(__complex__
float __z)
1807 {
return __builtin_catanhf(__z); }
1809 inline __complex__
double
1810 __complex_atanh(__complex__
double __z)
1811 {
return __builtin_catanh(__z); }
1813 inline __complex__
long double
1814 __complex_atanh(
const __complex__
long double& __z)
1815 {
return __builtin_catanhl(__z); }
1817 template<
typename _Tp>
1820 {
return __complex_atanh(__z.__rep()); }
1825 template<
typename _Tp>
1828 {
return __complex_atanh(__z); }
1831 template<
typename _Tp>
1840 template<
typename _Tp>
1841 inline typename __gnu_cxx::__promote<_Tp>::__type
1844 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1845 #if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
1846 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
1853 template<
typename _Tp>
1854 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1858 template<
typename _Tp>
1859 _GLIBCXX20_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1862 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1863 return __type(__x) * __type(__x);
1866 template<
typename _Tp>
1867 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1871 template<
typename _Tp,
typename _Up>
1875 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1879 template<
typename _Tp,
typename _Up>
1883 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1887 template<
typename _Tp,
typename _Up>
1891 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1898 template<
typename _Tp>
1901 template<
typename _Tp>
1905 const _Tp __den = (__z.real() * __z.real()
1906 + __z.imag() * __z.imag() + _Tp(1.0));
1909 (_Tp(2.0) * __z.imag()) / __den);
1912 #if _GLIBCXX_USE_C99_COMPLEX
1913 inline __complex__
float
1914 __complex_proj(__complex__
float __z)
1915 {
return __builtin_cprojf(__z); }
1917 inline __complex__
double
1918 __complex_proj(__complex__
double __z)
1919 {
return __builtin_cproj(__z); }
1921 inline __complex__
long double
1922 __complex_proj(
const __complex__
long double& __z)
1923 {
return __builtin_cprojl(__z); }
1925 template<
typename _Tp>
1928 {
return __complex_proj(__z.__rep()); }
1930 template<
typename _Tp>
1933 {
return __complex_proj(__z); }
1936 template<
typename _Tp>
1940 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1944 template<
typename _Tp>
1945 inline _GLIBCXX20_CONSTEXPR
1949 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1953 #if __cplusplus > 201103L
1955 inline namespace literals {
1956 inline namespace complex_literals {
1957 #pragma GCC diagnostic push
1958 #pragma GCC diagnostic ignored "-Wliteral-suffix"
1959 #define __cpp_lib_complex_udls 201309
1962 operator""if(
long double __num)
1966 operator""if(
unsigned long long __num)
1970 operator""i(
long double __num)
1974 operator""i(
unsigned long long __num)
1978 operator""il(
long double __num)
1982 operator""il(
unsigned long long __num)
1985 #pragma GCC diagnostic pop
1991 _GLIBCXX_END_NAMESPACE_VERSION
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
_Tp value_type
Value typedef.
std::complex< _Tp > acosh(const std::complex< _Tp > &)
acosh(__z) [8.1.5].
complex< _Tp > tanh(const complex< _Tp > &)
Return complex hyperbolic tangent of z.
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
std::complex< _Tp > acos(const std::complex< _Tp > &)
acos(__z) [8.1.2].
complex< _Tp > polar(const _Tp &, const _Tp &=0)
Return complex with magnitude rho and angle theta.
locale imbue(const locale &__loc)
Moves to a new locale.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
constexpr complex(const complex< _Up > &__z)
Converting constructor.
basic_ostream< wchar_t > wostream
Base class for wchar_t output streams.
26.2.3 complex specializations complex<long double> specialization
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
_GLIBCXX20_CONSTEXPR complex< _Tp > conj(const complex< _Tp > &)
Return complex conjugate of z.
std::complex< _Tp > atan(const std::complex< _Tp > &)
atan(__z) [8.1.4].
_GLIBCXX20_CONSTEXPR complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
26.2.3 complex specializations complex<double> specialization
_GLIBCXX20_CONSTEXPR complex< _Tp > & operator+=(const _Tp &__t)
Add a scalar to this complex number.
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
__string_type str() const
Copying out the string buffer.
Controlling output for std::string.
_GLIBCXX20_CONSTEXPR complex< _Tp > & operator*=(const _Tp &)
Multiply this complex number by a scalar.
_GLIBCXX20_CONSTEXPR complex< _Tp > & operator/=(const _Tp &)
Divide this complex number by a scalar.
complex< _Tp > tan(const complex< _Tp > &)
Return complex tangent of z.
26.2.3 complex specializations complex<float> specialization
_Tp arg(const complex< _Tp > &)
Return phase angle of z.
_GLIBCXX14_CONSTEXPR const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
_GLIBCXX20_CONSTEXPR complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
_Tp fabs(const std::complex< _Tp > &)
fabs(__z) [8.1.8].
complex< _Tp > sinh(const complex< _Tp > &)
Return complex hyperbolic sine of z.
_Tp _GLIBCXX20_CONSTEXPR norm(const complex< _Tp > &)
Return z magnitude squared.
basic_istream< char > istream
Base class for char input streams.
Template class basic_istream.
_GLIBCXX20_CONSTEXPR complex< _Tp > & operator-=(const _Tp &__t)
Subtract a scalar from this complex number.
std::complex< _Tp > asin(const std::complex< _Tp > &)
asin(__z) [8.1.3].
fmtflags flags() const
Access to format flags.
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
__istream_type & putback(char_type __c)
Unextracting a single character.
streamsize precision() const
Flags access.
_GLIBCXX20_CONSTEXPR complex< _Tp > & operator=(const _Tp &)
Assign a scalar to this complex number.
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
void setstate(iostate __state)
Sets additional flags in the error state.
char_type widen(char __c) const
Widens characters.
_GLIBCXX20_CONSTEXPR complex< _Tp > operator/(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x divided by y.
basic_ostream< char > ostream
Base class for char output streams.
complex< _Tp > cosh(const complex< _Tp > &)
Return complex hyperbolic cosine of z.
std::complex< _Tp > atanh(const std::complex< _Tp > &)
atanh(__z) [8.1.7].
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...
_GLIBCXX20_CONSTEXPR complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
std::complex< _Tp > asinh(const std::complex< _Tp > &)
asinh(__z) [8.1.6].
complex< _Tp > log10(const complex< _Tp > &)
Return complex base 10 logarithm of z.