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 54 namespace std _GLIBCXX_VISIBILITY(default)
56 _GLIBCXX_BEGIN_NAMESPACE_VERSION
68 template<>
class complex<float>;
69 template<>
class complex<double>;
70 template<>
class complex<long double>;
80 template<
typename _Tp>
126 template<
typename _Tp>
134 _GLIBCXX_CONSTEXPR
complex(
const _Tp& __r = _Tp(),
const _Tp& __i = _Tp())
135 : _M_real(__r), _M_imag(__i) { }
138 #if __cplusplus >= 201103L 143 template<
typename _Up>
145 : _M_real(__z.real()), _M_imag(__z.imag()) { }
147 #if __cplusplus >= 201103L 150 _GLIBCXX_ABI_TAG_CXX11
152 real()
const {
return _M_real; }
154 _GLIBCXX_ABI_TAG_CXX11
156 imag()
const {
return _M_imag; }
160 real() {
return _M_real; }
164 real()
const {
return _M_real; }
168 imag() {
return _M_imag; }
172 imag()
const {
return _M_imag; }
177 _GLIBCXX20_CONSTEXPR
void 178 real(_Tp __val) { _M_real = __val; }
180 _GLIBCXX20_CONSTEXPR
void 181 imag(_Tp __val) { _M_imag = __val; }
210 #if __cplusplus >= 201103L 215 template<
typename _Up>
218 template<
typename _Up>
221 template<
typename _Up>
224 template<
typename _Up>
227 template<
typename _Up>
230 _GLIBCXX_CONSTEXPR
complex __rep()
const 238 template<
typename _Tp>
248 template<
typename _Tp>
258 template<
typename _Tp>
267 template<
typename _Tp>
268 template<
typename _Up>
272 _M_real = __z.real();
273 _M_imag = __z.imag();
278 template<
typename _Tp>
279 template<
typename _Up>
283 _M_real += __z.real();
284 _M_imag += __z.imag();
289 template<
typename _Tp>
290 template<
typename _Up>
294 _M_real -= __z.real();
295 _M_imag -= __z.imag();
301 template<
typename _Tp>
302 template<
typename _Up>
306 const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
307 _M_imag = _M_real * __z.imag() + _M_imag * __z.real();
314 template<
typename _Tp>
315 template<
typename _Up>
319 const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag();
321 _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n;
329 template<
typename _Tp>
338 template<
typename _Tp>
347 template<
typename _Tp>
359 template<
typename _Tp>
368 template<
typename _Tp>
377 template<
typename _Tp>
389 template<
typename _Tp>
398 template<
typename _Tp>
407 template<
typename _Tp>
419 template<
typename _Tp>
428 template<
typename _Tp>
437 template<
typename _Tp>
448 template<
typename _Tp>
454 template<
typename _Tp>
461 template<
typename _Tp>
462 inline _GLIBCXX_CONSTEXPR
bool 464 {
return __x.real() == __y.real() && __x.imag() == __y.imag(); }
466 template<
typename _Tp>
467 inline _GLIBCXX_CONSTEXPR
bool 469 {
return __x.real() == __y && __x.imag() == _Tp(); }
471 template<
typename _Tp>
472 inline _GLIBCXX_CONSTEXPR
bool 474 {
return __x == __y.real() && _Tp() == __y.imag(); }
479 template<
typename _Tp>
480 inline _GLIBCXX_CONSTEXPR
bool 482 {
return __x.real() != __y.real() || __x.imag() != __y.imag(); }
484 template<
typename _Tp>
485 inline _GLIBCXX_CONSTEXPR
bool 487 {
return __x.real() != __y || __x.imag() != _Tp(); }
489 template<
typename _Tp>
490 inline _GLIBCXX_CONSTEXPR
bool 492 {
return __x != __y.real() || _Tp() != __y.imag(); }
496 template<
typename _Tp,
typename _CharT,
class _Traits>
504 if (_Traits::eq(__ch, __is.
widen(
'(')))
507 if (__is >> __u >> __ch)
509 const _CharT __rparen = __is.
widen(
')');
510 if (_Traits::eq(__ch, __rparen))
515 else if (_Traits::eq(__ch, __is.
widen(
',')))
518 if (__is >> __v >> __ch)
520 if (_Traits::eq(__ch, __rparen))
550 template<
typename _Tp,
typename _CharT,
class _Traits>
552 operator<<(basic_ostream<_CharT, _Traits>& __os,
const complex<_Tp>& __x)
555 __s.
flags(__os.flags());
556 __s.
imbue(__os.getloc());
558 __s <<
'(' << __x.real() <<
',' << __x.imag() <<
')';
559 return __os << __s.
str();
563 #if __cplusplus >= 201103L 564 template<
typename _Tp>
567 {
return __z.real(); }
569 template<
typename _Tp>
572 {
return __z.imag(); }
574 template<
typename _Tp>
577 {
return __z.real(); }
579 template<
typename _Tp>
582 {
return __z.real(); }
584 template<
typename _Tp>
587 {
return __z.imag(); }
589 template<
typename _Tp>
592 {
return __z.imag(); }
596 template<
typename _Tp>
600 _Tp __x = __z.real();
601 _Tp __y = __z.imag();
607 return __s *
sqrt(__x * __x + __y * __y);
610 #if _GLIBCXX_USE_C99_COMPLEX 612 __complex_abs(__complex__
float __z) {
return __builtin_cabsf(__z); }
615 __complex_abs(__complex__
double __z) {
return __builtin_cabs(__z); }
618 __complex_abs(
const __complex__
long double& __z)
619 {
return __builtin_cabsl(__z); }
621 template<
typename _Tp>
625 template<
typename _Tp>
632 template<
typename _Tp>
635 {
return atan2(__z.imag(), __z.real()); }
637 #if _GLIBCXX_USE_C99_COMPLEX 639 __complex_arg(__complex__
float __z) {
return __builtin_cargf(__z); }
642 __complex_arg(__complex__
double __z) {
return __builtin_carg(__z); }
645 __complex_arg(
const __complex__
long double& __z)
646 {
return __builtin_cargl(__z); }
648 template<
typename _Tp>
652 template<
typename _Tp>
665 template<
typename _Tp>
666 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
668 const _Tp __x = __z.real();
669 const _Tp __y = __z.imag();
670 return __x * __x + __y * __y;
675 struct _Norm_helper<true>
677 template<
typename _Tp>
678 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
682 const _Tp __x = __z.real();
683 const _Tp __y = __z.imag();
684 return __x * __x + __y * __y;
688 template<
typename _Tp>
689 inline _GLIBCXX20_CONSTEXPR _Tp
692 return _Norm_helper<__is_floating<_Tp>::__value
693 && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
696 template<
typename _Tp>
698 polar(
const _Tp& __rho,
const _Tp& __theta)
700 __glibcxx_assert( __rho >= 0 );
704 template<
typename _Tp>
712 template<
typename _Tp>
716 const _Tp __x = __z.real();
717 const _Tp __y = __z.imag();
721 #if _GLIBCXX_USE_C99_COMPLEX 722 inline __complex__
float 723 __complex_cos(__complex__
float __z) {
return __builtin_ccosf(__z); }
725 inline __complex__
double 726 __complex_cos(__complex__
double __z) {
return __builtin_ccos(__z); }
728 inline __complex__
long double 729 __complex_cos(
const __complex__
long double& __z)
730 {
return __builtin_ccosl(__z); }
732 template<
typename _Tp>
736 template<
typename _Tp>
742 template<
typename _Tp>
746 const _Tp __x = __z.real();
747 const _Tp __y = __z.imag();
751 #if _GLIBCXX_USE_C99_COMPLEX 752 inline __complex__
float 753 __complex_cosh(__complex__
float __z) {
return __builtin_ccoshf(__z); }
755 inline __complex__
double 756 __complex_cosh(__complex__
double __z) {
return __builtin_ccosh(__z); }
758 inline __complex__
long double 759 __complex_cosh(
const __complex__
long double& __z)
760 {
return __builtin_ccoshl(__z); }
762 template<
typename _Tp>
766 template<
typename _Tp>
772 template<
typename _Tp>
775 {
return std::polar<_Tp>(
exp(__z.real()), __z.imag()); }
777 #if _GLIBCXX_USE_C99_COMPLEX 778 inline __complex__
float 779 __complex_exp(__complex__
float __z) {
return __builtin_cexpf(__z); }
781 inline __complex__
double 782 __complex_exp(__complex__
double __z) {
return __builtin_cexp(__z); }
784 inline __complex__
long double 785 __complex_exp(
const __complex__
long double& __z)
786 {
return __builtin_cexpl(__z); }
788 template<
typename _Tp>
792 template<
typename _Tp>
799 template<
typename _Tp>
804 #if _GLIBCXX_USE_C99_COMPLEX 805 inline __complex__
float 806 __complex_log(__complex__
float __z) {
return __builtin_clogf(__z); }
808 inline __complex__
double 809 __complex_log(__complex__
double __z) {
return __builtin_clog(__z); }
811 inline __complex__
long double 812 __complex_log(
const __complex__
long double& __z)
813 {
return __builtin_clogl(__z); }
815 template<
typename _Tp>
819 template<
typename _Tp>
824 template<
typename _Tp>
830 template<
typename _Tp>
834 const _Tp __x = __z.real();
835 const _Tp __y = __z.imag();
839 #if _GLIBCXX_USE_C99_COMPLEX 840 inline __complex__
float 841 __complex_sin(__complex__
float __z) {
return __builtin_csinf(__z); }
843 inline __complex__
double 844 __complex_sin(__complex__
double __z) {
return __builtin_csin(__z); }
846 inline __complex__
long double 847 __complex_sin(
const __complex__
long double& __z)
848 {
return __builtin_csinl(__z); }
850 template<
typename _Tp>
854 template<
typename _Tp>
860 template<
typename _Tp>
864 const _Tp __x = __z.real();
865 const _Tp __y = __z.imag();
869 #if _GLIBCXX_USE_C99_COMPLEX 870 inline __complex__
float 871 __complex_sinh(__complex__
float __z) {
return __builtin_csinhf(__z); }
873 inline __complex__
double 874 __complex_sinh(__complex__
double __z) {
return __builtin_csinh(__z); }
876 inline __complex__
long double 877 __complex_sinh(
const __complex__
long double& __z)
878 {
return __builtin_csinhl(__z); }
880 template<
typename _Tp>
884 template<
typename _Tp>
891 template<
typename _Tp>
895 _Tp __x = __z.real();
896 _Tp __y = __z.imag();
913 #if _GLIBCXX_USE_C99_COMPLEX 914 inline __complex__
float 915 __complex_sqrt(__complex__
float __z) {
return __builtin_csqrtf(__z); }
917 inline __complex__
double 918 __complex_sqrt(__complex__
double __z) {
return __builtin_csqrt(__z); }
920 inline __complex__
long double 921 __complex_sqrt(
const __complex__
long double& __z)
922 {
return __builtin_csqrtl(__z); }
924 template<
typename _Tp>
928 template<
typename _Tp>
935 template<
typename _Tp>
940 #if _GLIBCXX_USE_C99_COMPLEX 941 inline __complex__
float 942 __complex_tan(__complex__
float __z) {
return __builtin_ctanf(__z); }
944 inline __complex__
double 945 __complex_tan(__complex__
double __z) {
return __builtin_ctan(__z); }
947 inline __complex__
long double 948 __complex_tan(
const __complex__
long double& __z)
949 {
return __builtin_ctanl(__z); }
951 template<
typename _Tp>
955 template<
typename _Tp>
963 template<
typename _Tp>
968 #if _GLIBCXX_USE_C99_COMPLEX 969 inline __complex__
float 970 __complex_tanh(__complex__
float __z) {
return __builtin_ctanhf(__z); }
972 inline __complex__
double 973 __complex_tanh(__complex__
double __z) {
return __builtin_ctanh(__z); }
975 inline __complex__
long double 976 __complex_tanh(
const __complex__
long double& __z)
977 {
return __builtin_ctanhl(__z); }
979 template<
typename _Tp>
983 template<
typename _Tp>
992 template<
typename _Tp>
1014 template<
typename _Tp>
1019 ?
complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(
unsigned)__n)
1020 : std::__complex_pow_unsigned(__z, __n);
1023 template<
typename _Tp>
1027 #if ! _GLIBCXX_USE_C99_COMPLEX 1031 if (__x.imag() == _Tp() && __x.real() > _Tp())
1032 return pow(__x.real(), __y);
1035 return std::polar<_Tp>(
exp(__y * __t.real()), __y * __t.imag());
1038 template<
typename _Tp>
1043 #if _GLIBCXX_USE_C99_COMPLEX 1044 inline __complex__
float 1045 __complex_pow(__complex__
float __x, __complex__
float __y)
1046 {
return __builtin_cpowf(__x, __y); }
1048 inline __complex__
double 1049 __complex_pow(__complex__
double __x, __complex__
double __y)
1050 {
return __builtin_cpow(__x, __y); }
1052 inline __complex__
long double 1053 __complex_pow(
const __complex__
long double& __x,
1054 const __complex__
long double& __y)
1055 {
return __builtin_cpowl(__x, __y); }
1057 template<
typename _Tp>
1060 {
return __complex_pow(__x.__rep(), __y.__rep()); }
1062 template<
typename _Tp>
1065 {
return __complex_pow(__x, __y); }
1068 template<
typename _Tp>
1072 return __x > _Tp() ? std::polar<_Tp>(
pow(__x, __y.real()),
1073 __y.imag() *
log(__x))
1083 typedef __complex__
float _ComplexT;
1085 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1087 _GLIBCXX_CONSTEXPR
complex(
float __r = 0.0f,
float __i = 0.0f)
1088 #if __cplusplus >= 201103L 1089 : _M_value{ __r, __i } { }
1092 __real__ _M_value = __r;
1093 __imag__ _M_value = __i;
1100 #if __cplusplus >= 201103L 1103 __attribute ((__abi_tag__ (
"cxx11")))
1105 real()
const {
return __real__ _M_value; }
1107 __attribute ((__abi_tag__ (
"cxx11")))
1109 imag()
const {
return __imag__ _M_value; }
1112 real() {
return __real__ _M_value; }
1115 real()
const {
return __real__ _M_value; }
1118 imag() {
return __imag__ _M_value; }
1121 imag()
const {
return __imag__ _M_value; }
1126 _GLIBCXX20_CONSTEXPR
void 1127 real(
float __val) { __real__ _M_value = __val; }
1129 _GLIBCXX20_CONSTEXPR
void 1130 imag(
float __val) { __imag__ _M_value = __val; }
1132 _GLIBCXX20_CONSTEXPR complex&
1139 _GLIBCXX20_CONSTEXPR complex&
1146 _GLIBCXX20_CONSTEXPR complex&
1153 _GLIBCXX20_CONSTEXPR complex&
1160 _GLIBCXX20_CONSTEXPR complex&
1169 #if __cplusplus >= 201103L 1170 _GLIBCXX14_CONSTEXPR complex&
operator=(
const complex&) =
default;
1173 template<
typename _Tp>
1174 _GLIBCXX20_CONSTEXPR complex&
1177 __real__ _M_value = __z.real();
1178 __imag__ _M_value = __z.imag();
1182 template<
typename _Tp>
1183 _GLIBCXX20_CONSTEXPR complex&
1186 _M_value += __z.__rep();
1191 _GLIBCXX20_CONSTEXPR complex&
1194 _M_value -= __z.__rep();
1199 _GLIBCXX20_CONSTEXPR complex&
1202 const _ComplexT __t = __z.__rep();
1208 _GLIBCXX20_CONSTEXPR complex&
1211 const _ComplexT __t = __z.__rep();
1216 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1228 typedef __complex__
double _ComplexT;
1230 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1232 _GLIBCXX_CONSTEXPR
complex(
double __r = 0.0,
double __i = 0.0)
1233 #if __cplusplus >= 201103L 1234 : _M_value{ __r, __i } { }
1237 __real__ _M_value = __r;
1238 __imag__ _M_value = __i;
1243 : _M_value(__z.__rep()) { }
1247 #if __cplusplus >= 201103L 1250 __attribute ((__abi_tag__ (
"cxx11")))
1252 real()
const {
return __real__ _M_value; }
1254 __attribute ((__abi_tag__ (
"cxx11")))
1256 imag()
const {
return __imag__ _M_value; }
1259 real() {
return __real__ _M_value; }
1262 real()
const {
return __real__ _M_value; }
1265 imag() {
return __imag__ _M_value; }
1268 imag()
const {
return __imag__ _M_value; }
1273 _GLIBCXX20_CONSTEXPR
void 1274 real(
double __val) { __real__ _M_value = __val; }
1276 _GLIBCXX20_CONSTEXPR
void 1277 imag(
double __val) { __imag__ _M_value = __val; }
1279 _GLIBCXX20_CONSTEXPR complex&
1286 _GLIBCXX20_CONSTEXPR complex&
1293 _GLIBCXX20_CONSTEXPR complex&
1300 _GLIBCXX20_CONSTEXPR complex&
1307 _GLIBCXX20_CONSTEXPR complex&
1315 #if __cplusplus >= 201103L 1316 _GLIBCXX14_CONSTEXPR complex&
operator=(
const complex&) =
default;
1319 template<
typename _Tp>
1320 _GLIBCXX20_CONSTEXPR complex&
1323 _M_value = __z.__rep();
1327 template<
typename _Tp>
1328 _GLIBCXX20_CONSTEXPR complex&
1331 _M_value += __z.__rep();
1335 template<
typename _Tp>
1336 _GLIBCXX20_CONSTEXPR complex&
1339 _M_value -= __z.__rep();
1343 template<
typename _Tp>
1344 _GLIBCXX20_CONSTEXPR complex&
1347 const _ComplexT __t = __z.__rep();
1352 template<
typename _Tp>
1353 _GLIBCXX20_CONSTEXPR complex&
1356 const _ComplexT __t = __z.__rep();
1361 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1373 typedef __complex__
long double _ComplexT;
1375 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1377 _GLIBCXX_CONSTEXPR
complex(
long double __r = 0.0L,
1378 long double __i = 0.0L)
1379 #if __cplusplus >= 201103L 1380 : _M_value{ __r, __i } { }
1383 __real__ _M_value = __r;
1384 __imag__ _M_value = __i;
1389 : _M_value(__z.__rep()) { }
1392 : _M_value(__z.__rep()) { }
1394 #if __cplusplus >= 201103L 1397 __attribute ((__abi_tag__ (
"cxx11")))
1398 constexpr
long double 1399 real()
const {
return __real__ _M_value; }
1401 __attribute ((__abi_tag__ (
"cxx11")))
1402 constexpr
long double 1403 imag()
const {
return __imag__ _M_value; }
1406 real() {
return __real__ _M_value; }
1409 real()
const {
return __real__ _M_value; }
1412 imag() {
return __imag__ _M_value; }
1415 imag()
const {
return __imag__ _M_value; }
1420 _GLIBCXX20_CONSTEXPR
void 1421 real(
long double __val) { __real__ _M_value = __val; }
1423 _GLIBCXX20_CONSTEXPR
void 1424 imag(
long double __val) { __imag__ _M_value = __val; }
1426 _GLIBCXX20_CONSTEXPR complex&
1433 _GLIBCXX20_CONSTEXPR complex&
1440 _GLIBCXX20_CONSTEXPR complex&
1447 _GLIBCXX20_CONSTEXPR complex&
1454 _GLIBCXX20_CONSTEXPR complex&
1462 #if __cplusplus >= 201103L 1463 _GLIBCXX14_CONSTEXPR complex&
operator=(
const complex&) =
default;
1466 template<
typename _Tp>
1467 _GLIBCXX20_CONSTEXPR complex&
1470 _M_value = __z.__rep();
1474 template<
typename _Tp>
1475 _GLIBCXX20_CONSTEXPR complex&
1478 _M_value += __z.__rep();
1482 template<
typename _Tp>
1483 _GLIBCXX20_CONSTEXPR complex&
1486 _M_value -= __z.__rep();
1490 template<
typename _Tp>
1491 _GLIBCXX20_CONSTEXPR complex&
1494 const _ComplexT __t = __z.__rep();
1499 template<
typename _Tp>
1500 _GLIBCXX20_CONSTEXPR complex&
1503 const _ComplexT __t = __z.__rep();
1508 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1516 inline _GLIBCXX_CONSTEXPR
1518 : _M_value(__z.__rep()) { }
1520 inline _GLIBCXX_CONSTEXPR
1522 : _M_value(__z.__rep()) { }
1524 inline _GLIBCXX_CONSTEXPR
1526 : _M_value(__z.__rep()) { }
1531 #if _GLIBCXX_EXTERN_TEMPLATE 1533 extern template ostream& operator<<(ostream&, const complex<float>&);
1535 extern template ostream& operator<<(ostream&, const complex<double>&);
1537 extern template ostream& operator<<(ostream&, const complex<long double>&);
1539 #ifdef _GLIBCXX_USE_WCHAR_T 1541 extern template wostream& operator<<(wostream&, const complex<float>&);
1543 extern template wostream& operator<<(wostream&, const complex<double>&);
1545 extern template wostream& operator<<(wostream&, const complex<long double>&);
1551 _GLIBCXX_END_NAMESPACE_VERSION
1554 namespace __gnu_cxx _GLIBCXX_VISIBILITY(
default)
1556 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1559 template<
typename _Tp,
typename _Up>
1560 struct __promote_2<std::complex<_Tp>, _Up>
1566 template<
typename _Tp,
typename _Up>
1567 struct __promote_2<_Tp, std::
complex<_Up> >
1573 template<
typename _Tp,
typename _Up>
1580 _GLIBCXX_END_NAMESPACE_VERSION
1583 #if __cplusplus >= 201103L 1585 namespace std _GLIBCXX_VISIBILITY(default)
1587 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1600 template<
typename _Tp>
1605 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
1609 #if _GLIBCXX_USE_C99_COMPLEX_TR1 1610 inline __complex__
float 1611 __complex_acos(__complex__
float __z)
1612 {
return __builtin_cacosf(__z); }
1614 inline __complex__
double 1615 __complex_acos(__complex__
double __z)
1616 {
return __builtin_cacos(__z); }
1618 inline __complex__
long double 1619 __complex_acos(
const __complex__
long double& __z)
1620 {
return __builtin_cacosl(__z); }
1622 template<
typename _Tp>
1625 {
return __complex_acos(__z.__rep()); }
1630 template<
typename _Tp>
1633 {
return __complex_acos(__z); }
1636 template<
typename _Tp>
1645 #if _GLIBCXX_USE_C99_COMPLEX_TR1 1646 inline __complex__
float 1647 __complex_asin(__complex__
float __z)
1648 {
return __builtin_casinf(__z); }
1650 inline __complex__
double 1651 __complex_asin(__complex__
double __z)
1652 {
return __builtin_casin(__z); }
1654 inline __complex__
long double 1655 __complex_asin(
const __complex__
long double& __z)
1656 {
return __builtin_casinl(__z); }
1658 template<
typename _Tp>
1661 {
return __complex_asin(__z.__rep()); }
1666 template<
typename _Tp>
1669 {
return __complex_asin(__z); }
1672 template<
typename _Tp>
1676 const _Tp __r2 = __z.real() * __z.real();
1677 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
1679 _Tp __num = __z.imag() + _Tp(1.0);
1680 _Tp __den = __z.imag() - _Tp(1.0);
1682 __num = __r2 + __num * __num;
1683 __den = __r2 + __den * __den;
1686 _Tp(0.25) *
log(__num / __den));
1689 #if _GLIBCXX_USE_C99_COMPLEX_TR1 1690 inline __complex__
float 1691 __complex_atan(__complex__
float __z)
1692 {
return __builtin_catanf(__z); }
1694 inline __complex__
double 1695 __complex_atan(__complex__
double __z)
1696 {
return __builtin_catan(__z); }
1698 inline __complex__
long double 1699 __complex_atan(
const __complex__
long double& __z)
1700 {
return __builtin_catanl(__z); }
1702 template<
typename _Tp>
1705 {
return __complex_atan(__z.__rep()); }
1710 template<
typename _Tp>
1713 {
return __complex_atan(__z); }
1716 template<
typename _Tp>
1722 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
1725 #if _GLIBCXX_USE_C99_COMPLEX_TR1 1726 inline __complex__
float 1727 __complex_acosh(__complex__
float __z)
1728 {
return __builtin_cacoshf(__z); }
1730 inline __complex__
double 1731 __complex_acosh(__complex__
double __z)
1732 {
return __builtin_cacosh(__z); }
1734 inline __complex__
long double 1735 __complex_acosh(
const __complex__
long double& __z)
1736 {
return __builtin_cacoshl(__z); }
1738 template<
typename _Tp>
1741 {
return __complex_acosh(__z.__rep()); }
1746 template<
typename _Tp>
1749 {
return __complex_acosh(__z); }
1752 template<
typename _Tp>
1757 * (__z.real() + __z.imag()) + _Tp(1.0),
1758 _Tp(2.0) * __z.real() * __z.imag());
1764 #if _GLIBCXX_USE_C99_COMPLEX_TR1 1765 inline __complex__
float 1766 __complex_asinh(__complex__
float __z)
1767 {
return __builtin_casinhf(__z); }
1769 inline __complex__
double 1770 __complex_asinh(__complex__
double __z)
1771 {
return __builtin_casinh(__z); }
1773 inline __complex__
long double 1774 __complex_asinh(
const __complex__
long double& __z)
1775 {
return __builtin_casinhl(__z); }
1777 template<
typename _Tp>
1780 {
return __complex_asinh(__z.__rep()); }
1785 template<
typename _Tp>
1788 {
return __complex_asinh(__z); }
1791 template<
typename _Tp>
1795 const _Tp __i2 = __z.imag() * __z.imag();
1796 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
1798 _Tp __num = _Tp(1.0) + __z.real();
1799 _Tp __den = _Tp(1.0) - __z.real();
1801 __num = __i2 + __num * __num;
1802 __den = __i2 + __den * __den;
1805 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
1808 #if _GLIBCXX_USE_C99_COMPLEX_TR1 1809 inline __complex__
float 1810 __complex_atanh(__complex__
float __z)
1811 {
return __builtin_catanhf(__z); }
1813 inline __complex__
double 1814 __complex_atanh(__complex__
double __z)
1815 {
return __builtin_catanh(__z); }
1817 inline __complex__
long double 1818 __complex_atanh(
const __complex__
long double& __z)
1819 {
return __builtin_catanhl(__z); }
1821 template<
typename _Tp>
1824 {
return __complex_atanh(__z.__rep()); }
1829 template<
typename _Tp>
1832 {
return __complex_atanh(__z); }
1835 template<
typename _Tp>
1844 template<
typename _Tp>
1845 inline typename __gnu_cxx::__promote<_Tp>::__type
1848 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1849 #if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC) 1850 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
1857 template<
typename _Tp>
1858 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1862 template<
typename _Tp>
1863 _GLIBCXX20_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1866 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1867 return __type(__x) * __type(__x);
1870 template<
typename _Tp>
1871 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1875 template<
typename _Tp,
typename _Up>
1879 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1883 template<
typename _Tp,
typename _Up>
1887 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1891 template<
typename _Tp,
typename _Up>
1895 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1902 template<
typename _Tp>
1906 template<
typename _Tp>
1911 #if _GLIBCXX_USE_C99_COMPLEX 1914 {
return __builtin_cprojf(__z.__rep()); }
1918 {
return __builtin_cproj(__z.__rep()); }
1922 {
return __builtin_cprojl(__z.__rep()); }
1923 #elif defined _GLIBCXX_USE_C99_MATH_TR1 1927 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
1929 __builtin_copysignf(0.0f, __z.imag()));
1936 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
1938 __builtin_copysign(0.0, __z.imag()));
1945 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
1947 __builtin_copysignl(0.0l, __z.imag()));
1952 template<
typename _Tp>
1955 {
return __complex_proj(__z); }
1958 template<
typename _Tp>
1962 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1966 template<
typename _Tp>
1967 inline _GLIBCXX20_CONSTEXPR
1971 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1975 #if __cplusplus > 201103L 1977 inline namespace literals {
1978 inline namespace complex_literals {
1979 #pragma GCC diagnostic push 1980 #pragma GCC diagnostic ignored "-Wliteral-suffix" 1981 #define __cpp_lib_complex_udls 201309 1984 operator""if(
long double __num)
1988 operator""if(
unsigned long long __num)
1992 operator""i(
long double __num)
1996 operator""i(
unsigned long long __num)
2000 operator""il(
long double __num)
2004 operator""il(
unsigned long long __num)
2007 #pragma GCC diagnostic pop 2013 _GLIBCXX_END_NAMESPACE_VERSION
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 > sqrt(const complex< _Tp > &)
Return complex square root of z.
constexpr complex(const complex< _Up > &__z)
Converting constructor.
std::complex< _Tp > atan(const std::complex< _Tp > &)
atan(__z) [8.1.4].
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
complex< _Tp > log10(const complex< _Tp > &)
Return complex base 10 logarithm of z.
complex< _Tp > sinh(const complex< _Tp > &)
Return complex hyperbolic sine of z.
constexpr complex< _Tp > conj(const complex< _Tp > &)
Return complex conjugate of z.
Template class basic_ostream.
complex< _Tp > tanh(const complex< _Tp > &)
Return complex hyperbolic tangent 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 &)
Divide this complex number by a scalar.
fmtflags flags() const
Access to format flags.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
complex< _Tp > polar(const _Tp &, const _Tp &=0)
Return complex with magnitude rho and angle theta.
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
void setstate(iostate __state)
Sets additional flags in the error state.
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
complex< _Tp > cosh(const complex< _Tp > &)
Return complex hyperbolic cosine of z.
_Tp fabs(const std::complex< _Tp > &)
fabs(__z) [8.1.8].
GNU extensions for public use.
Template class basic_istream.
locale imbue(const locale &__loc)
Moves to a new locale.
__istream_type & putback(char_type __c)
Unextracting a single character.
std::complex< _Tp > asin(const std::complex< _Tp > &)
asin(__z) [8.1.3].
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 const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
Controlling output for std::string.
26.2.3 complex specializations complex<float> specialization
constexpr complex< _Tp > & operator+=(const _Tp &__t)
Add a scalar to this complex number.
std::complex< _Tp > acos(const std::complex< _Tp > &)
acos(__z) [8.1.2].
std::complex< _Tp > asinh(const std::complex< _Tp > &)
asinh(__z) [8.1.6].
constexpr complex< _Tp > & operator*=(const _Tp &)
Multiply this complex number by a scalar.
_Tp value_type
Value typedef.
char_type widen(char __c) const
Widens characters.
_Tp arg(const complex< _Tp > &)
Return phase angle of z.
ISO C++ entities toplevel namespace is std.
constexpr complex< _Tp > operator/(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x divided by y.
_Tp constexpr norm(const complex< _Tp > &)
Return z magnitude squared.
std::complex< _Tp > atanh(const std::complex< _Tp > &)
atanh(__z) [8.1.7].
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
26.2.3 complex specializations complex<long double> specialization
std::complex< _Tp > acosh(const std::complex< _Tp > &)
acosh(__z) [8.1.5].
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
streamsize precision() const
Flags access.
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
constexpr complex< _Tp > & operator-=(const _Tp &__t)
Subtract a scalar from this complex number.
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
constexpr complex< _Tp > & operator=(const _Tp &)
Assign a scalar to this complex number.
__string_type str() const
Copying out the string buffer.
26.2.3 complex specializations complex<double> specialization