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>;
121 template<
typename _Tp>
129 _GLIBCXX_CONSTEXPR
complex(
const _Tp& __r = _Tp(),
const _Tp& __i = _Tp())
130 : _M_real(__r), _M_imag(__i) { }
133 #if __cplusplus >= 201103L
138 template<
typename _Up>
140 : _M_real(__z.real()), _M_imag(__z.imag()) { }
142 #if __cplusplus >= 201103L
145 _GLIBCXX_ABI_TAG_CXX11
147 real()
const {
return _M_real; }
149 _GLIBCXX_ABI_TAG_CXX11
151 imag()
const {
return _M_imag; }
155 real() {
return _M_real; }
159 real()
const {
return _M_real; }
163 imag() {
return _M_imag; }
167 imag()
const {
return _M_imag; }
173 real(_Tp __val) { _M_real = __val; }
176 imag(_Tp __val) { _M_imag = __val; }
205 #if __cplusplus >= 201103L
210 template<
typename _Up>
213 template<
typename _Up>
216 template<
typename _Up>
219 template<
typename _Up>
222 template<
typename _Up>
225 _GLIBCXX_CONSTEXPR
complex __rep()
const
233 template<
typename _Tp>
243 template<
typename _Tp>
253 template<
typename _Tp>
262 template<
typename _Tp>
263 template<
typename _Up>
267 _M_real = __z.real();
268 _M_imag = __z.imag();
273 template<
typename _Tp>
274 template<
typename _Up>
278 _M_real += __z.real();
279 _M_imag += __z.imag();
284 template<
typename _Tp>
285 template<
typename _Up>
289 _M_real -= __z.real();
290 _M_imag -= __z.imag();
296 template<
typename _Tp>
297 template<
typename _Up>
301 const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
302 _M_imag = _M_real * __z.imag() + _M_imag * __z.real();
309 template<
typename _Tp>
310 template<
typename _Up>
314 const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag();
316 _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n;
324 template<
typename _Tp>
333 template<
typename _Tp>
342 template<
typename _Tp>
354 template<
typename _Tp>
363 template<
typename _Tp>
372 template<
typename _Tp>
384 template<
typename _Tp>
393 template<
typename _Tp>
402 template<
typename _Tp>
414 template<
typename _Tp>
423 template<
typename _Tp>
432 template<
typename _Tp>
443 template<
typename _Tp>
449 template<
typename _Tp>
456 template<
typename _Tp>
457 inline _GLIBCXX_CONSTEXPR
bool
459 {
return __x.real() == __y.real() && __x.imag() == __y.imag(); }
461 template<
typename _Tp>
462 inline _GLIBCXX_CONSTEXPR
bool
464 {
return __x.real() == __y && __x.imag() == _Tp(); }
466 template<
typename _Tp>
467 inline _GLIBCXX_CONSTEXPR
bool
469 {
return __x == __y.real() && _Tp() == __y.imag(); }
474 template<
typename _Tp>
475 inline _GLIBCXX_CONSTEXPR
bool
477 {
return __x.real() != __y.real() || __x.imag() != __y.imag(); }
479 template<
typename _Tp>
480 inline _GLIBCXX_CONSTEXPR
bool
482 {
return __x.real() != __y || __x.imag() != _Tp(); }
484 template<
typename _Tp>
485 inline _GLIBCXX_CONSTEXPR
bool
487 {
return __x != __y.real() || _Tp() != __y.imag(); }
491 template<
typename _Tp,
typename _CharT,
class _Traits>
492 basic_istream<_CharT, _Traits>&
496 _CharT __ch = _CharT();
500 __is >> __re_x >> __ch;
503 __is >> __im_x >> __ch;
509 else if (__ch ==
')')
526 template<
typename _Tp,
typename _CharT,
class _Traits>
527 basic_ostream<_CharT, _Traits>&
528 operator<<(basic_ostream<_CharT, _Traits>& __os,
const complex<_Tp>& __x)
531 __s.
flags(__os.flags());
532 __s.
imbue(__os.getloc());
534 __s <<
'(' << __x.real() <<
',' << __x.imag() <<
')';
535 return __os << __s.
str();
539 #if __cplusplus >= 201103L
540 template<
typename _Tp>
542 real(
const complex<_Tp>& __z)
543 {
return __z.real(); }
545 template<
typename _Tp>
547 imag(
const complex<_Tp>& __z)
548 {
return __z.imag(); }
550 template<
typename _Tp>
552 real(complex<_Tp>& __z)
553 {
return __z.real(); }
555 template<
typename _Tp>
557 real(
const complex<_Tp>& __z)
558 {
return __z.real(); }
560 template<
typename _Tp>
562 imag(complex<_Tp>& __z)
563 {
return __z.imag(); }
565 template<
typename _Tp>
567 imag(
const complex<_Tp>& __z)
568 {
return __z.imag(); }
572 template<
typename _Tp>
574 __complex_abs(
const complex<_Tp>& __z)
576 _Tp __x = __z.real();
577 _Tp __y = __z.imag();
583 return __s *
sqrt(__x * __x + __y * __y);
586 #if _GLIBCXX_USE_C99_COMPLEX
588 __complex_abs(__complex__
float __z) {
return __builtin_cabsf(__z); }
591 __complex_abs(__complex__
double __z) {
return __builtin_cabs(__z); }
594 __complex_abs(
const __complex__
long double& __z)
595 {
return __builtin_cabsl(__z); }
597 template<
typename _Tp>
599 abs(
const complex<_Tp>& __z) {
return __complex_abs(__z.__rep()); }
601 template<
typename _Tp>
608 template<
typename _Tp>
610 __complex_arg(
const complex<_Tp>& __z)
611 {
return atan2(__z.imag(), __z.real()); }
613 #if _GLIBCXX_USE_C99_COMPLEX
615 __complex_arg(__complex__
float __z) {
return __builtin_cargf(__z); }
618 __complex_arg(__complex__
double __z) {
return __builtin_carg(__z); }
621 __complex_arg(
const __complex__
long double& __z)
622 {
return __builtin_cargl(__z); }
624 template<
typename _Tp>
626 arg(
const complex<_Tp>& __z) {
return __complex_arg(__z.__rep()); }
628 template<
typename _Tp>
641 template<
typename _Tp>
642 static inline _Tp _S_do_it(
const complex<_Tp>& __z)
644 const _Tp __x = __z.real();
645 const _Tp __y = __z.imag();
646 return __x * __x + __y * __y;
651 struct _Norm_helper<true>
653 template<
typename _Tp>
654 static inline _Tp _S_do_it(
const complex<_Tp>& __z)
657 return __res * __res;
661 template<
typename _Tp>
665 return _Norm_helper<__is_floating<_Tp>::__value
666 && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
669 template<
typename _Tp>
671 polar(
const _Tp& __rho,
const _Tp& __theta)
673 __glibcxx_assert( __rho >= 0 );
677 template<
typename _Tp>
685 template<
typename _Tp>
687 __complex_cos(
const complex<_Tp>& __z)
689 const _Tp __x = __z.real();
690 const _Tp __y = __z.imag();
694 #if _GLIBCXX_USE_C99_COMPLEX
695 inline __complex__
float
696 __complex_cos(__complex__
float __z) {
return __builtin_ccosf(__z); }
698 inline __complex__
double
699 __complex_cos(__complex__
double __z) {
return __builtin_ccos(__z); }
701 inline __complex__
long double
702 __complex_cos(
const __complex__
long double& __z)
703 {
return __builtin_ccosl(__z); }
705 template<
typename _Tp>
707 cos(
const complex<_Tp>& __z) {
return __complex_cos(__z.__rep()); }
709 template<
typename _Tp>
715 template<
typename _Tp>
717 __complex_cosh(
const complex<_Tp>& __z)
719 const _Tp __x = __z.real();
720 const _Tp __y = __z.imag();
724 #if _GLIBCXX_USE_C99_COMPLEX
725 inline __complex__
float
726 __complex_cosh(__complex__
float __z) {
return __builtin_ccoshf(__z); }
728 inline __complex__
double
729 __complex_cosh(__complex__
double __z) {
return __builtin_ccosh(__z); }
731 inline __complex__
long double
732 __complex_cosh(
const __complex__
long double& __z)
733 {
return __builtin_ccoshl(__z); }
735 template<
typename _Tp>
737 cosh(
const complex<_Tp>& __z) {
return __complex_cosh(__z.__rep()); }
739 template<
typename _Tp>
745 template<
typename _Tp>
747 __complex_exp(
const complex<_Tp>& __z)
748 {
return std::polar<_Tp>(
exp(__z.real()), __z.imag()); }
750 #if _GLIBCXX_USE_C99_COMPLEX
751 inline __complex__
float
752 __complex_exp(__complex__
float __z) {
return __builtin_cexpf(__z); }
754 inline __complex__
double
755 __complex_exp(__complex__
double __z) {
return __builtin_cexp(__z); }
757 inline __complex__
long double
758 __complex_exp(
const __complex__
long double& __z)
759 {
return __builtin_cexpl(__z); }
761 template<
typename _Tp>
763 exp(
const complex<_Tp>& __z) {
return __complex_exp(__z.__rep()); }
765 template<
typename _Tp>
772 template<
typename _Tp>
774 __complex_log(
const complex<_Tp>& __z)
777 #if _GLIBCXX_USE_C99_COMPLEX
778 inline __complex__
float
779 __complex_log(__complex__
float __z) {
return __builtin_clogf(__z); }
781 inline __complex__
double
782 __complex_log(__complex__
double __z) {
return __builtin_clog(__z); }
784 inline __complex__
long double
785 __complex_log(
const __complex__
long double& __z)
786 {
return __builtin_clogl(__z); }
788 template<
typename _Tp>
790 log(
const complex<_Tp>& __z) {
return __complex_log(__z.__rep()); }
792 template<
typename _Tp>
797 template<
typename _Tp>
803 template<
typename _Tp>
805 __complex_sin(
const complex<_Tp>& __z)
807 const _Tp __x = __z.real();
808 const _Tp __y = __z.imag();
812 #if _GLIBCXX_USE_C99_COMPLEX
813 inline __complex__
float
814 __complex_sin(__complex__
float __z) {
return __builtin_csinf(__z); }
816 inline __complex__
double
817 __complex_sin(__complex__
double __z) {
return __builtin_csin(__z); }
819 inline __complex__
long double
820 __complex_sin(
const __complex__
long double& __z)
821 {
return __builtin_csinl(__z); }
823 template<
typename _Tp>
825 sin(
const complex<_Tp>& __z) {
return __complex_sin(__z.__rep()); }
827 template<
typename _Tp>
833 template<
typename _Tp>
835 __complex_sinh(
const complex<_Tp>& __z)
837 const _Tp __x = __z.real();
838 const _Tp __y = __z.imag();
842 #if _GLIBCXX_USE_C99_COMPLEX
843 inline __complex__
float
844 __complex_sinh(__complex__
float __z) {
return __builtin_csinhf(__z); }
846 inline __complex__
double
847 __complex_sinh(__complex__
double __z) {
return __builtin_csinh(__z); }
849 inline __complex__
long double
850 __complex_sinh(
const __complex__
long double& __z)
851 {
return __builtin_csinhl(__z); }
853 template<
typename _Tp>
855 sinh(
const complex<_Tp>& __z) {
return __complex_sinh(__z.__rep()); }
857 template<
typename _Tp>
864 template<
typename _Tp>
866 __complex_sqrt(
const complex<_Tp>& __z)
868 _Tp __x = __z.real();
869 _Tp __y = __z.imag();
874 return complex<_Tp>(__t, __y < _Tp() ? -__t : __t);
881 ? complex<_Tp>(__u, __y / __t)
882 : complex<_Tp>(
abs(__y) / __t, __y < _Tp() ? -__u : __u);
886 #if _GLIBCXX_USE_C99_COMPLEX
887 inline __complex__
float
888 __complex_sqrt(__complex__
float __z) {
return __builtin_csqrtf(__z); }
890 inline __complex__
double
891 __complex_sqrt(__complex__
double __z) {
return __builtin_csqrt(__z); }
893 inline __complex__
long double
894 __complex_sqrt(
const __complex__
long double& __z)
895 {
return __builtin_csqrtl(__z); }
897 template<
typename _Tp>
899 sqrt(
const complex<_Tp>& __z) {
return __complex_sqrt(__z.__rep()); }
901 template<
typename _Tp>
908 template<
typename _Tp>
910 __complex_tan(
const complex<_Tp>& __z)
913 #if _GLIBCXX_USE_C99_COMPLEX
914 inline __complex__
float
915 __complex_tan(__complex__
float __z) {
return __builtin_ctanf(__z); }
917 inline __complex__
double
918 __complex_tan(__complex__
double __z) {
return __builtin_ctan(__z); }
920 inline __complex__
long double
921 __complex_tan(
const __complex__
long double& __z)
922 {
return __builtin_ctanl(__z); }
924 template<
typename _Tp>
926 tan(
const complex<_Tp>& __z) {
return __complex_tan(__z.__rep()); }
928 template<
typename _Tp>
936 template<
typename _Tp>
938 __complex_tanh(
const complex<_Tp>& __z)
941 #if _GLIBCXX_USE_C99_COMPLEX
942 inline __complex__
float
943 __complex_tanh(__complex__
float __z) {
return __builtin_ctanhf(__z); }
945 inline __complex__
double
946 __complex_tanh(__complex__
double __z) {
return __builtin_ctanh(__z); }
948 inline __complex__
long double
949 __complex_tanh(
const __complex__
long double& __z)
950 {
return __builtin_ctanhl(__z); }
952 template<
typename _Tp>
954 tanh(
const complex<_Tp>& __z) {
return __complex_tanh(__z.__rep()); }
956 template<
typename _Tp>
965 template<
typename _Tp>
967 __complex_pow_unsigned(complex<_Tp> __x,
unsigned __n)
969 complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1);
987 template<
typename _Tp>
992 ?
complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(
unsigned)__n)
993 : std::__complex_pow_unsigned(__z, __n);
996 template<
typename _Tp>
1000 #if ! _GLIBCXX_USE_C99_COMPLEX
1004 if (__x.imag() == _Tp() && __x.real() > _Tp())
1005 return pow(__x.real(), __y);
1008 return std::polar<_Tp>(
exp(__y * __t.real()), __y * __t.imag());
1011 template<
typename _Tp>
1013 __complex_pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1014 {
return __x == _Tp() ? _Tp() : std::
exp(__y * std::
log(__x)); }
1016 #if _GLIBCXX_USE_C99_COMPLEX
1017 inline __complex__
float
1018 __complex_pow(__complex__
float __x, __complex__
float __y)
1019 {
return __builtin_cpowf(__x, __y); }
1021 inline __complex__
double
1022 __complex_pow(__complex__
double __x, __complex__
double __y)
1023 {
return __builtin_cpow(__x, __y); }
1025 inline __complex__
long double
1026 __complex_pow(
const __complex__
long double& __x,
1027 const __complex__
long double& __y)
1028 {
return __builtin_cpowl(__x, __y); }
1030 template<
typename _Tp>
1032 pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1033 {
return __complex_pow(__x.__rep(), __y.__rep()); }
1035 template<
typename _Tp>
1038 {
return __complex_pow(__x, __y); }
1041 template<
typename _Tp>
1045 return __x > _Tp() ? std::polar<_Tp>(
pow(__x, __y.real()),
1046 __y.imag() *
log(__x))
1056 typedef __complex__
float _ComplexT;
1058 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1060 _GLIBCXX_CONSTEXPR
complex(
float __r = 0.0f,
float __i = 0.0f)
1061 #if __cplusplus >= 201103L
1062 : _M_value{ __r, __i } { }
1065 __real__ _M_value = __r;
1066 __imag__ _M_value = __i;
1073 #if __cplusplus >= 201103L
1076 __attribute ((__abi_tag__ (
"cxx11")))
1078 real()
const {
return __real__ _M_value; }
1080 __attribute ((__abi_tag__ (
"cxx11")))
1082 imag()
const {
return __imag__ _M_value; }
1085 real() {
return __real__ _M_value; }
1088 real()
const {
return __real__ _M_value; }
1091 imag() {
return __imag__ _M_value; }
1094 imag()
const {
return __imag__ _M_value; }
1100 real(
float __val) { __real__ _M_value = __val; }
1103 imag(
float __val) { __imag__ _M_value = __val; }
1144 template<
typename _Tp>
1148 __real__ _M_value = __z.real();
1149 __imag__ _M_value = __z.imag();
1153 template<
typename _Tp>
1157 __real__ _M_value += __z.real();
1158 __imag__ _M_value += __z.imag();
1166 __real__ _M_value -= __z.real();
1167 __imag__ _M_value -= __z.imag();
1176 __real__ __t = __z.real();
1177 __imag__ __t = __z.imag();
1187 __real__ __t = __z.real();
1188 __imag__ __t = __z.imag();
1193 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1205 typedef __complex__
double _ComplexT;
1207 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1209 _GLIBCXX_CONSTEXPR
complex(
double __r = 0.0,
double __i = 0.0)
1210 #if __cplusplus >= 201103L
1211 : _M_value{ __r, __i } { }
1214 __real__ _M_value = __r;
1215 __imag__ _M_value = __i;
1220 : _M_value(__z.__rep()) { }
1224 #if __cplusplus >= 201103L
1227 __attribute ((__abi_tag__ (
"cxx11")))
1229 real()
const {
return __real__ _M_value; }
1231 __attribute ((__abi_tag__ (
"cxx11")))
1233 imag()
const {
return __imag__ _M_value; }
1236 real() {
return __real__ _M_value; }
1239 real()
const {
return __real__ _M_value; }
1242 imag() {
return __imag__ _M_value; }
1245 imag()
const {
return __imag__ _M_value; }
1251 real(
double __val) { __real__ _M_value = __val; }
1254 imag(
double __val) { __imag__ _M_value = __val; }
1294 template<
typename _Tp>
1298 __real__ _M_value = __z.real();
1299 __imag__ _M_value = __z.imag();
1303 template<
typename _Tp>
1307 __real__ _M_value += __z.real();
1308 __imag__ _M_value += __z.imag();
1312 template<
typename _Tp>
1316 __real__ _M_value -= __z.real();
1317 __imag__ _M_value -= __z.imag();
1321 template<
typename _Tp>
1326 __real__ __t = __z.real();
1327 __imag__ __t = __z.imag();
1332 template<
typename _Tp>
1337 __real__ __t = __z.real();
1338 __imag__ __t = __z.imag();
1343 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1355 typedef __complex__
long double _ComplexT;
1357 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1359 _GLIBCXX_CONSTEXPR
complex(
long double __r = 0.0L,
1360 long double __i = 0.0L)
1361 #if __cplusplus >= 201103L
1362 : _M_value{ __r, __i } { }
1365 __real__ _M_value = __r;
1366 __imag__ _M_value = __i;
1371 : _M_value(__z.__rep()) { }
1374 : _M_value(__z.__rep()) { }
1376 #if __cplusplus >= 201103L
1379 __attribute ((__abi_tag__ (
"cxx11")))
1380 constexpr
long double
1381 real()
const {
return __real__ _M_value; }
1383 __attribute ((__abi_tag__ (
"cxx11")))
1384 constexpr
long double
1385 imag()
const {
return __imag__ _M_value; }
1388 real() {
return __real__ _M_value; }
1391 real()
const {
return __real__ _M_value; }
1394 imag() {
return __imag__ _M_value; }
1397 imag()
const {
return __imag__ _M_value; }
1403 real(
long double __val) { __real__ _M_value = __val; }
1406 imag(
long double __val) { __imag__ _M_value = __val; }
1446 template<
typename _Tp>
1450 __real__ _M_value = __z.real();
1451 __imag__ _M_value = __z.imag();
1455 template<
typename _Tp>
1459 __real__ _M_value += __z.real();
1460 __imag__ _M_value += __z.imag();
1464 template<
typename _Tp>
1468 __real__ _M_value -= __z.real();
1469 __imag__ _M_value -= __z.imag();
1473 template<
typename _Tp>
1478 __real__ __t = __z.real();
1479 __imag__ __t = __z.imag();
1484 template<
typename _Tp>
1489 __real__ __t = __z.real();
1490 __imag__ __t = __z.imag();
1495 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1503 inline _GLIBCXX_CONSTEXPR
1505 : _M_value(__z.__rep()) { }
1507 inline _GLIBCXX_CONSTEXPR
1509 : _M_value(__z.__rep()) { }
1511 inline _GLIBCXX_CONSTEXPR
1513 : _M_value(__z.__rep()) { }
1518 #if _GLIBCXX_EXTERN_TEMPLATE
1520 extern template ostream& operator<<(ostream&, const complex<float>&);
1522 extern template ostream& operator<<(ostream&, const complex<double>&);
1524 extern template ostream& operator<<(ostream&, const complex<long double>&);
1526 #ifdef _GLIBCXX_USE_WCHAR_T
1528 extern template wostream& operator<<(wostream&, const complex<float>&);
1530 extern template wostream& operator<<(wostream&, const complex<double>&);
1532 extern template wostream& operator<<(wostream&, const complex<long double>&);
1538 _GLIBCXX_END_NAMESPACE_VERSION
1541 namespace __gnu_cxx _GLIBCXX_VISIBILITY(
default)
1543 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1546 template<
typename _Tp,
typename _Up>
1547 struct __promote_2<std::complex<_Tp>, _Up>
1553 template<
typename _Tp,
typename _Up>
1554 struct __promote_2<_Tp, std::complex<_Up> >
1560 template<
typename _Tp,
typename _Up>
1561 struct __promote_2<std::complex<_Tp>,
std::complex<_Up> >
1567 _GLIBCXX_END_NAMESPACE_VERSION
1570 #if __cplusplus >= 201103L
1572 namespace std _GLIBCXX_VISIBILITY(default)
1574 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1587 template<
typename _Tp>
1592 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
1596 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1597 inline __complex__
float
1598 __complex_acos(__complex__
float __z)
1599 {
return __builtin_cacosf(__z); }
1601 inline __complex__
double
1602 __complex_acos(__complex__
double __z)
1603 {
return __builtin_cacos(__z); }
1605 inline __complex__
long double
1606 __complex_acos(
const __complex__
long double& __z)
1607 {
return __builtin_cacosl(__z); }
1609 template<
typename _Tp>
1612 {
return __complex_acos(__z.__rep()); }
1617 template<
typename _Tp>
1620 {
return __complex_acos(__z); }
1623 template<
typename _Tp>
1632 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1633 inline __complex__
float
1634 __complex_asin(__complex__
float __z)
1635 {
return __builtin_casinf(__z); }
1637 inline __complex__
double
1638 __complex_asin(__complex__
double __z)
1639 {
return __builtin_casin(__z); }
1641 inline __complex__
long double
1642 __complex_asin(
const __complex__
long double& __z)
1643 {
return __builtin_casinl(__z); }
1645 template<
typename _Tp>
1648 {
return __complex_asin(__z.__rep()); }
1653 template<
typename _Tp>
1656 {
return __complex_asin(__z); }
1659 template<
typename _Tp>
1663 const _Tp __r2 = __z.real() * __z.real();
1664 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
1666 _Tp __num = __z.imag() + _Tp(1.0);
1667 _Tp __den = __z.imag() - _Tp(1.0);
1669 __num = __r2 + __num * __num;
1670 __den = __r2 + __den * __den;
1673 _Tp(0.25) *
log(__num / __den));
1676 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1677 inline __complex__
float
1678 __complex_atan(__complex__
float __z)
1679 {
return __builtin_catanf(__z); }
1681 inline __complex__
double
1682 __complex_atan(__complex__
double __z)
1683 {
return __builtin_catan(__z); }
1685 inline __complex__
long double
1686 __complex_atan(
const __complex__
long double& __z)
1687 {
return __builtin_catanl(__z); }
1689 template<
typename _Tp>
1692 {
return __complex_atan(__z.__rep()); }
1697 template<
typename _Tp>
1700 {
return __complex_atan(__z); }
1703 template<
typename _Tp>
1709 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
1712 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1713 inline __complex__
float
1714 __complex_acosh(__complex__
float __z)
1715 {
return __builtin_cacoshf(__z); }
1717 inline __complex__
double
1718 __complex_acosh(__complex__
double __z)
1719 {
return __builtin_cacosh(__z); }
1721 inline __complex__
long double
1722 __complex_acosh(
const __complex__
long double& __z)
1723 {
return __builtin_cacoshl(__z); }
1725 template<
typename _Tp>
1728 {
return __complex_acosh(__z.__rep()); }
1733 template<
typename _Tp>
1736 {
return __complex_acosh(__z); }
1739 template<
typename _Tp>
1744 * (__z.real() + __z.imag()) + _Tp(1.0),
1745 _Tp(2.0) * __z.real() * __z.imag());
1751 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1752 inline __complex__
float
1753 __complex_asinh(__complex__
float __z)
1754 {
return __builtin_casinhf(__z); }
1756 inline __complex__
double
1757 __complex_asinh(__complex__
double __z)
1758 {
return __builtin_casinh(__z); }
1760 inline __complex__
long double
1761 __complex_asinh(
const __complex__
long double& __z)
1762 {
return __builtin_casinhl(__z); }
1764 template<
typename _Tp>
1767 {
return __complex_asinh(__z.__rep()); }
1772 template<
typename _Tp>
1775 {
return __complex_asinh(__z); }
1778 template<
typename _Tp>
1782 const _Tp __i2 = __z.imag() * __z.imag();
1783 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
1785 _Tp __num = _Tp(1.0) + __z.real();
1786 _Tp __den = _Tp(1.0) - __z.real();
1788 __num = __i2 + __num * __num;
1789 __den = __i2 + __den * __den;
1792 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
1795 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1796 inline __complex__
float
1797 __complex_atanh(__complex__
float __z)
1798 {
return __builtin_catanhf(__z); }
1800 inline __complex__
double
1801 __complex_atanh(__complex__
double __z)
1802 {
return __builtin_catanh(__z); }
1804 inline __complex__
long double
1805 __complex_atanh(
const __complex__
long double& __z)
1806 {
return __builtin_catanhl(__z); }
1808 template<
typename _Tp>
1811 {
return __complex_atanh(__z.__rep()); }
1816 template<
typename _Tp>
1819 {
return __complex_atanh(__z); }
1822 template<
typename _Tp>
1831 template<
typename _Tp>
1832 inline typename __gnu_cxx::__promote<_Tp>::__type
1835 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1836 #if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
1837 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
1844 template<
typename _Tp>
1845 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1849 template<
typename _Tp>
1850 inline typename __gnu_cxx::__promote<_Tp>::__type
1853 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1854 return __type(__x) * __type(__x);
1857 template<
typename _Tp>
1858 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1862 template<
typename _Tp,
typename _Up>
1866 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1870 template<
typename _Tp,
typename _Up>
1874 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1878 template<
typename _Tp,
typename _Up>
1882 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1891 template<
typename _Tp>
1895 const _Tp __den = (__z.real() * __z.real()
1896 + __z.imag() * __z.imag() + _Tp(1.0));
1899 (_Tp(2.0) * __z.imag()) / __den);
1902 #if _GLIBCXX_USE_C99_COMPLEX
1903 inline __complex__
float
1904 __complex_proj(__complex__
float __z)
1905 {
return __builtin_cprojf(__z); }
1907 inline __complex__
double
1908 __complex_proj(__complex__
double __z)
1909 {
return __builtin_cproj(__z); }
1911 inline __complex__
long double
1912 __complex_proj(
const __complex__
long double& __z)
1913 {
return __builtin_cprojl(__z); }
1915 template<
typename _Tp>
1918 {
return __complex_proj(__z.__rep()); }
1920 template<
typename _Tp>
1923 {
return __complex_proj(__z); }
1926 template<
typename _Tp>
1930 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1934 template<
typename _Tp>
1938 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1942 _GLIBCXX_END_NAMESPACE_VERSION
1944 #if __cplusplus > 201103L
1946 inline namespace literals {
1947 inline namespace complex_literals {
1948 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1950 #define __cpp_lib_complex_udls 201309
1953 operator""if(
long double __num)
1957 operator""if(
unsigned long long __num)
1961 operator""i(
long double __num)
1965 operator""i(
unsigned long long __num)
1969 operator""il(
long double __num)
1973 operator""il(
unsigned long long __num)
1976 _GLIBCXX_END_NAMESPACE_VERSION
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...
complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
complex< _Tp > & operator+=(const _Tp &__t)
Add a scalar to this complex number.
complex< _Tp > & operator-=(const _Tp &__t)
Subtract a scalar from this complex number.
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
streamsize precision() const
Flags access.
complex< _Tp > sinh(const complex< _Tp > &)
Return complex hyperbolic sine of z.
std::complex< _Tp > asinh(const std::complex< _Tp > &)
asinh(__z) [8.1.6].
std::complex< _Tp > acos(const std::complex< _Tp > &)
acos(__z) [8.1.2].
basic_istream< char > istream
Base class for char input streams.
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
complex< _Tp > cosh(const complex< _Tp > &)
Return complex hyperbolic cosine of z.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
constexpr complex(const complex< _Up > &__z)
Converting constructor.
complex< _Tp > operator/(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x divided by y.
complex< _Tp > & operator=(const _Tp &)
Assign a scalar to this complex number.
std::complex< _Tp > asin(const std::complex< _Tp > &)
asin(__z) [8.1.3].
26.2.3 complex specializations complex<double> specialization
fmtflags flags() const
Access to format flags.
__istream_type & putback(char_type __c)
Unextracting a single character.
complex< _Tp > tanh(const complex< _Tp > &)
Return complex hyperbolic tangent of z.
complex< _Tp > & operator/=(const _Tp &)
Divide this complex number by a scalar.
Controlling output for std::string.
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
_GLIBCXX14_CONSTEXPR const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
_Tp norm(const complex< _Tp > &)
Return z magnitude squared.
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
26.2.3 complex specializations complex<long double> specialization
complex< _Tp > log10(const complex< _Tp > &)
Return complex base 10 logarithm of z.
complex< _Tp > & operator*=(const _Tp &)
Multiply this complex number by a scalar.
complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
basic_ostream< char > ostream
Base class for char output streams.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
std::complex< _Tp > atan(const std::complex< _Tp > &)
atan(__z) [8.1.4].
complex< _Tp > tan(const complex< _Tp > &)
Return complex tangent of z.
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
basic_ostream< wchar_t > wostream
Base class for wchar_t output streams.
_Tp fabs(const std::complex< _Tp > &)
fabs(__z) [8.1.8].
Template class basic_istream.
std::complex< _Tp > acosh(const std::complex< _Tp > &)
acosh(__z) [8.1.5].
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
locale imbue(const locale &__loc)
Moves to a new locale.
complex< _Tp > polar(const _Tp &, const _Tp &=0)
Return complex with magnitude rho and angle theta.
26.2.3 complex specializations complex<float> specialization
_Tp value_type
Value typedef.
__string_type str() const
Copying out the string buffer.
complex< _Tp > conj(const complex< _Tp > &)
Return complex conjugate of z.
std::complex< _Tp > atanh(const std::complex< _Tp > &)
atanh(__z) [8.1.7].
void setstate(iostate __state)
Sets additional flags in the error state.
_Tp arg(const complex< _Tp > &)
Return phase angle of z.