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>&
500 __is >> __re_x >> __ch;
503 __is >> __im_x >> __ch;
509 else if (__ch ==
')')
524 template<
typename _Tp,
typename _CharT,
class _Traits>
525 basic_ostream<_CharT, _Traits>&
526 operator<<(basic_ostream<_CharT, _Traits>& __os,
const complex<_Tp>& __x)
529 __s.
flags(__os.flags());
530 __s.
imbue(__os.getloc());
532 __s <<
'(' << __x.real() <<
',' << __x.imag() <<
')';
533 return __os << __s.
str();
537 #if __cplusplus >= 201103L
538 template<
typename _Tp>
540 real(
const complex<_Tp>& __z)
541 {
return __z.real(); }
543 template<
typename _Tp>
545 imag(
const complex<_Tp>& __z)
546 {
return __z.imag(); }
548 template<
typename _Tp>
550 real(complex<_Tp>& __z)
551 {
return __z.real(); }
553 template<
typename _Tp>
555 real(
const complex<_Tp>& __z)
556 {
return __z.real(); }
558 template<
typename _Tp>
560 imag(complex<_Tp>& __z)
561 {
return __z.imag(); }
563 template<
typename _Tp>
565 imag(
const complex<_Tp>& __z)
566 {
return __z.imag(); }
570 template<
typename _Tp>
572 __complex_abs(
const complex<_Tp>& __z)
574 _Tp __x = __z.real();
575 _Tp __y = __z.imag();
581 return __s *
sqrt(__x * __x + __y * __y);
584 #if _GLIBCXX_USE_C99_COMPLEX
586 __complex_abs(__complex__
float __z) {
return __builtin_cabsf(__z); }
589 __complex_abs(__complex__
double __z) {
return __builtin_cabs(__z); }
592 __complex_abs(
const __complex__
long double& __z)
593 {
return __builtin_cabsl(__z); }
595 template<
typename _Tp>
597 abs(
const complex<_Tp>& __z) {
return __complex_abs(__z.__rep()); }
599 template<
typename _Tp>
606 template<
typename _Tp>
608 __complex_arg(
const complex<_Tp>& __z)
609 {
return atan2(__z.imag(), __z.real()); }
611 #if _GLIBCXX_USE_C99_COMPLEX
613 __complex_arg(__complex__
float __z) {
return __builtin_cargf(__z); }
616 __complex_arg(__complex__
double __z) {
return __builtin_carg(__z); }
619 __complex_arg(
const __complex__
long double& __z)
620 {
return __builtin_cargl(__z); }
622 template<
typename _Tp>
624 arg(
const complex<_Tp>& __z) {
return __complex_arg(__z.__rep()); }
626 template<
typename _Tp>
639 template<
typename _Tp>
640 static inline _Tp _S_do_it(
const complex<_Tp>& __z)
642 const _Tp __x = __z.real();
643 const _Tp __y = __z.imag();
644 return __x * __x + __y * __y;
649 struct _Norm_helper<true>
651 template<
typename _Tp>
652 static inline _Tp _S_do_it(
const complex<_Tp>& __z)
655 return __res * __res;
659 template<
typename _Tp>
663 return _Norm_helper<__is_floating<_Tp>::__value
664 && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
667 template<
typename _Tp>
669 polar(
const _Tp& __rho,
const _Tp& __theta)
672 template<
typename _Tp>
680 template<
typename _Tp>
682 __complex_cos(
const complex<_Tp>& __z)
684 const _Tp __x = __z.real();
685 const _Tp __y = __z.imag();
689 #if _GLIBCXX_USE_C99_COMPLEX
690 inline __complex__
float
691 __complex_cos(__complex__
float __z) {
return __builtin_ccosf(__z); }
693 inline __complex__
double
694 __complex_cos(__complex__
double __z) {
return __builtin_ccos(__z); }
696 inline __complex__
long double
697 __complex_cos(
const __complex__
long double& __z)
698 {
return __builtin_ccosl(__z); }
700 template<
typename _Tp>
702 cos(
const complex<_Tp>& __z) {
return __complex_cos(__z.__rep()); }
704 template<
typename _Tp>
710 template<
typename _Tp>
712 __complex_cosh(
const complex<_Tp>& __z)
714 const _Tp __x = __z.real();
715 const _Tp __y = __z.imag();
719 #if _GLIBCXX_USE_C99_COMPLEX
720 inline __complex__
float
721 __complex_cosh(__complex__
float __z) {
return __builtin_ccoshf(__z); }
723 inline __complex__
double
724 __complex_cosh(__complex__
double __z) {
return __builtin_ccosh(__z); }
726 inline __complex__
long double
727 __complex_cosh(
const __complex__
long double& __z)
728 {
return __builtin_ccoshl(__z); }
730 template<
typename _Tp>
732 cosh(
const complex<_Tp>& __z) {
return __complex_cosh(__z.__rep()); }
734 template<
typename _Tp>
740 template<
typename _Tp>
742 __complex_exp(
const complex<_Tp>& __z)
743 {
return std::polar<_Tp>(
exp(__z.real()), __z.imag()); }
745 #if _GLIBCXX_USE_C99_COMPLEX
746 inline __complex__
float
747 __complex_exp(__complex__
float __z) {
return __builtin_cexpf(__z); }
749 inline __complex__
double
750 __complex_exp(__complex__
double __z) {
return __builtin_cexp(__z); }
752 inline __complex__
long double
753 __complex_exp(
const __complex__
long double& __z)
754 {
return __builtin_cexpl(__z); }
756 template<
typename _Tp>
758 exp(
const complex<_Tp>& __z) {
return __complex_exp(__z.__rep()); }
760 template<
typename _Tp>
767 template<
typename _Tp>
769 __complex_log(
const complex<_Tp>& __z)
772 #if _GLIBCXX_USE_C99_COMPLEX
773 inline __complex__
float
774 __complex_log(__complex__
float __z) {
return __builtin_clogf(__z); }
776 inline __complex__
double
777 __complex_log(__complex__
double __z) {
return __builtin_clog(__z); }
779 inline __complex__
long double
780 __complex_log(
const __complex__
long double& __z)
781 {
return __builtin_clogl(__z); }
783 template<
typename _Tp>
785 log(
const complex<_Tp>& __z) {
return __complex_log(__z.__rep()); }
787 template<
typename _Tp>
792 template<
typename _Tp>
798 template<
typename _Tp>
800 __complex_sin(
const complex<_Tp>& __z)
802 const _Tp __x = __z.real();
803 const _Tp __y = __z.imag();
807 #if _GLIBCXX_USE_C99_COMPLEX
808 inline __complex__
float
809 __complex_sin(__complex__
float __z) {
return __builtin_csinf(__z); }
811 inline __complex__
double
812 __complex_sin(__complex__
double __z) {
return __builtin_csin(__z); }
814 inline __complex__
long double
815 __complex_sin(
const __complex__
long double& __z)
816 {
return __builtin_csinl(__z); }
818 template<
typename _Tp>
820 sin(
const complex<_Tp>& __z) {
return __complex_sin(__z.__rep()); }
822 template<
typename _Tp>
828 template<
typename _Tp>
830 __complex_sinh(
const complex<_Tp>& __z)
832 const _Tp __x = __z.real();
833 const _Tp __y = __z.imag();
837 #if _GLIBCXX_USE_C99_COMPLEX
838 inline __complex__
float
839 __complex_sinh(__complex__
float __z) {
return __builtin_csinhf(__z); }
841 inline __complex__
double
842 __complex_sinh(__complex__
double __z) {
return __builtin_csinh(__z); }
844 inline __complex__
long double
845 __complex_sinh(
const __complex__
long double& __z)
846 {
return __builtin_csinhl(__z); }
848 template<
typename _Tp>
850 sinh(
const complex<_Tp>& __z) {
return __complex_sinh(__z.__rep()); }
852 template<
typename _Tp>
859 template<
typename _Tp>
861 __complex_sqrt(
const complex<_Tp>& __z)
863 _Tp __x = __z.real();
864 _Tp __y = __z.imag();
869 return complex<_Tp>(__t, __y < _Tp() ? -__t : __t);
876 ? complex<_Tp>(__u, __y / __t)
877 : complex<_Tp>(
abs(__y) / __t, __y < _Tp() ? -__u : __u);
881 #if _GLIBCXX_USE_C99_COMPLEX
882 inline __complex__
float
883 __complex_sqrt(__complex__
float __z) {
return __builtin_csqrtf(__z); }
885 inline __complex__
double
886 __complex_sqrt(__complex__
double __z) {
return __builtin_csqrt(__z); }
888 inline __complex__
long double
889 __complex_sqrt(
const __complex__
long double& __z)
890 {
return __builtin_csqrtl(__z); }
892 template<
typename _Tp>
894 sqrt(
const complex<_Tp>& __z) {
return __complex_sqrt(__z.__rep()); }
896 template<
typename _Tp>
903 template<
typename _Tp>
905 __complex_tan(
const complex<_Tp>& __z)
908 #if _GLIBCXX_USE_C99_COMPLEX
909 inline __complex__
float
910 __complex_tan(__complex__
float __z) {
return __builtin_ctanf(__z); }
912 inline __complex__
double
913 __complex_tan(__complex__
double __z) {
return __builtin_ctan(__z); }
915 inline __complex__
long double
916 __complex_tan(
const __complex__
long double& __z)
917 {
return __builtin_ctanl(__z); }
919 template<
typename _Tp>
921 tan(
const complex<_Tp>& __z) {
return __complex_tan(__z.__rep()); }
923 template<
typename _Tp>
931 template<
typename _Tp>
933 __complex_tanh(
const complex<_Tp>& __z)
936 #if _GLIBCXX_USE_C99_COMPLEX
937 inline __complex__
float
938 __complex_tanh(__complex__
float __z) {
return __builtin_ctanhf(__z); }
940 inline __complex__
double
941 __complex_tanh(__complex__
double __z) {
return __builtin_ctanh(__z); }
943 inline __complex__
long double
944 __complex_tanh(
const __complex__
long double& __z)
945 {
return __builtin_ctanhl(__z); }
947 template<
typename _Tp>
949 tanh(
const complex<_Tp>& __z) {
return __complex_tanh(__z.__rep()); }
951 template<
typename _Tp>
960 template<
typename _Tp>
962 __complex_pow_unsigned(complex<_Tp> __x,
unsigned __n)
964 complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1);
982 template<
typename _Tp>
987 ?
complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(
unsigned)__n)
988 : std::__complex_pow_unsigned(__z, __n);
991 template<
typename _Tp>
995 #ifndef _GLIBCXX_USE_C99_COMPLEX
999 if (__x.imag() == _Tp() && __x.real() > _Tp())
1000 return pow(__x.real(), __y);
1003 return std::polar<_Tp>(
exp(__y * __t.real()), __y * __t.imag());
1006 template<
typename _Tp>
1008 __complex_pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1009 {
return __x == _Tp() ? _Tp() : std::
exp(__y * std::
log(__x)); }
1011 #if _GLIBCXX_USE_C99_COMPLEX
1012 inline __complex__
float
1013 __complex_pow(__complex__
float __x, __complex__
float __y)
1014 {
return __builtin_cpowf(__x, __y); }
1016 inline __complex__
double
1017 __complex_pow(__complex__
double __x, __complex__
double __y)
1018 {
return __builtin_cpow(__x, __y); }
1020 inline __complex__
long double
1021 __complex_pow(
const __complex__
long double& __x,
1022 const __complex__
long double& __y)
1023 {
return __builtin_cpowl(__x, __y); }
1025 template<
typename _Tp>
1027 pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1028 {
return __complex_pow(__x.__rep(), __y.__rep()); }
1030 template<
typename _Tp>
1033 {
return __complex_pow(__x, __y); }
1036 template<
typename _Tp>
1040 return __x > _Tp() ? std::polar<_Tp>(
pow(__x, __y.real()),
1041 __y.imag() *
log(__x))
1051 typedef __complex__
float _ComplexT;
1053 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1055 _GLIBCXX_CONSTEXPR
complex(
float __r = 0.0f,
float __i = 0.0f)
1056 #if __cplusplus >= 201103L
1057 : _M_value{ __r, __i } { }
1060 __real__ _M_value = __r;
1061 __imag__ _M_value = __i;
1068 #if __cplusplus >= 201103L
1071 __attribute ((__abi_tag__ (
"cxx11")))
1073 real()
const {
return __real__ _M_value; }
1075 __attribute ((__abi_tag__ (
"cxx11")))
1077 imag()
const {
return __imag__ _M_value; }
1080 real() {
return __real__ _M_value; }
1083 real()
const {
return __real__ _M_value; }
1086 imag() {
return __imag__ _M_value; }
1089 imag()
const {
return __imag__ _M_value; }
1095 real(
float __val) { __real__ _M_value = __val; }
1098 imag(
float __val) { __imag__ _M_value = __val; }
1139 template<
typename _Tp>
1143 __real__ _M_value = __z.real();
1144 __imag__ _M_value = __z.imag();
1148 template<
typename _Tp>
1152 __real__ _M_value += __z.real();
1153 __imag__ _M_value += __z.imag();
1161 __real__ _M_value -= __z.real();
1162 __imag__ _M_value -= __z.imag();
1171 __real__ __t = __z.real();
1172 __imag__ __t = __z.imag();
1182 __real__ __t = __z.real();
1183 __imag__ __t = __z.imag();
1188 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1200 typedef __complex__
double _ComplexT;
1202 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1204 _GLIBCXX_CONSTEXPR
complex(
double __r = 0.0,
double __i = 0.0)
1205 #if __cplusplus >= 201103L
1206 : _M_value{ __r, __i } { }
1209 __real__ _M_value = __r;
1210 __imag__ _M_value = __i;
1215 : _M_value(__z.__rep()) { }
1219 #if __cplusplus >= 201103L
1222 __attribute ((__abi_tag__ (
"cxx11")))
1224 real()
const {
return __real__ _M_value; }
1226 __attribute ((__abi_tag__ (
"cxx11")))
1228 imag()
const {
return __imag__ _M_value; }
1231 real() {
return __real__ _M_value; }
1234 real()
const {
return __real__ _M_value; }
1237 imag() {
return __imag__ _M_value; }
1240 imag()
const {
return __imag__ _M_value; }
1246 real(
double __val) { __real__ _M_value = __val; }
1249 imag(
double __val) { __imag__ _M_value = __val; }
1289 template<
typename _Tp>
1293 __real__ _M_value = __z.real();
1294 __imag__ _M_value = __z.imag();
1298 template<
typename _Tp>
1302 __real__ _M_value += __z.real();
1303 __imag__ _M_value += __z.imag();
1307 template<
typename _Tp>
1311 __real__ _M_value -= __z.real();
1312 __imag__ _M_value -= __z.imag();
1316 template<
typename _Tp>
1321 __real__ __t = __z.real();
1322 __imag__ __t = __z.imag();
1327 template<
typename _Tp>
1332 __real__ __t = __z.real();
1333 __imag__ __t = __z.imag();
1338 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1350 typedef __complex__
long double _ComplexT;
1352 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1354 _GLIBCXX_CONSTEXPR
complex(
long double __r = 0.0L,
1355 long double __i = 0.0L)
1356 #if __cplusplus >= 201103L
1357 : _M_value{ __r, __i } { }
1360 __real__ _M_value = __r;
1361 __imag__ _M_value = __i;
1366 : _M_value(__z.__rep()) { }
1369 : _M_value(__z.__rep()) { }
1371 #if __cplusplus >= 201103L
1374 __attribute ((__abi_tag__ (
"cxx11")))
1375 constexpr
long double
1376 real()
const {
return __real__ _M_value; }
1378 __attribute ((__abi_tag__ (
"cxx11")))
1379 constexpr
long double
1380 imag()
const {
return __imag__ _M_value; }
1383 real() {
return __real__ _M_value; }
1386 real()
const {
return __real__ _M_value; }
1389 imag() {
return __imag__ _M_value; }
1392 imag()
const {
return __imag__ _M_value; }
1398 real(
long double __val) { __real__ _M_value = __val; }
1401 imag(
long double __val) { __imag__ _M_value = __val; }
1441 template<
typename _Tp>
1445 __real__ _M_value = __z.real();
1446 __imag__ _M_value = __z.imag();
1450 template<
typename _Tp>
1454 __real__ _M_value += __z.real();
1455 __imag__ _M_value += __z.imag();
1459 template<
typename _Tp>
1463 __real__ _M_value -= __z.real();
1464 __imag__ _M_value -= __z.imag();
1468 template<
typename _Tp>
1473 __real__ __t = __z.real();
1474 __imag__ __t = __z.imag();
1479 template<
typename _Tp>
1484 __real__ __t = __z.real();
1485 __imag__ __t = __z.imag();
1490 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1498 inline _GLIBCXX_CONSTEXPR
1500 : _M_value(__z.__rep()) { }
1502 inline _GLIBCXX_CONSTEXPR
1504 : _M_value(__z.__rep()) { }
1506 inline _GLIBCXX_CONSTEXPR
1508 : _M_value(__z.__rep()) { }
1513 #if _GLIBCXX_EXTERN_TEMPLATE
1515 extern template ostream& operator<<(ostream&, const complex<float>&);
1517 extern template ostream& operator<<(ostream&, const complex<double>&);
1519 extern template ostream& operator<<(ostream&, const complex<long double>&);
1521 #ifdef _GLIBCXX_USE_WCHAR_T
1523 extern template wostream& operator<<(wostream&, const complex<float>&);
1525 extern template wostream& operator<<(wostream&, const complex<double>&);
1527 extern template wostream& operator<<(wostream&, const complex<long double>&);
1533 _GLIBCXX_END_NAMESPACE_VERSION
1536 namespace __gnu_cxx _GLIBCXX_VISIBILITY(
default)
1538 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1541 template<
typename _Tp,
typename _Up>
1542 struct __promote_2<std::complex<_Tp>, _Up>
1548 template<
typename _Tp,
typename _Up>
1549 struct __promote_2<_Tp, std::complex<_Up> >
1555 template<
typename _Tp,
typename _Up>
1556 struct __promote_2<std::complex<_Tp>,
std::complex<_Up> >
1562 _GLIBCXX_END_NAMESPACE_VERSION
1565 #if __cplusplus >= 201103L
1567 namespace std _GLIBCXX_VISIBILITY(default)
1569 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1582 template<
typename _Tp>
1587 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
1591 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1592 inline __complex__
float
1593 __complex_acos(__complex__
float __z)
1594 {
return __builtin_cacosf(__z); }
1596 inline __complex__
double
1597 __complex_acos(__complex__
double __z)
1598 {
return __builtin_cacos(__z); }
1600 inline __complex__
long double
1601 __complex_acos(
const __complex__
long double& __z)
1602 {
return __builtin_cacosl(__z); }
1604 template<
typename _Tp>
1607 {
return __complex_acos(__z.__rep()); }
1612 template<
typename _Tp>
1615 {
return __complex_acos(__z); }
1618 template<
typename _Tp>
1627 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1628 inline __complex__
float
1629 __complex_asin(__complex__
float __z)
1630 {
return __builtin_casinf(__z); }
1632 inline __complex__
double
1633 __complex_asin(__complex__
double __z)
1634 {
return __builtin_casin(__z); }
1636 inline __complex__
long double
1637 __complex_asin(
const __complex__
long double& __z)
1638 {
return __builtin_casinl(__z); }
1640 template<
typename _Tp>
1643 {
return __complex_asin(__z.__rep()); }
1648 template<
typename _Tp>
1651 {
return __complex_asin(__z); }
1654 template<
typename _Tp>
1658 const _Tp __r2 = __z.real() * __z.real();
1659 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
1661 _Tp __num = __z.imag() + _Tp(1.0);
1662 _Tp __den = __z.imag() - _Tp(1.0);
1664 __num = __r2 + __num * __num;
1665 __den = __r2 + __den * __den;
1668 _Tp(0.25) *
log(__num / __den));
1671 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1672 inline __complex__
float
1673 __complex_atan(__complex__
float __z)
1674 {
return __builtin_catanf(__z); }
1676 inline __complex__
double
1677 __complex_atan(__complex__
double __z)
1678 {
return __builtin_catan(__z); }
1680 inline __complex__
long double
1681 __complex_atan(
const __complex__
long double& __z)
1682 {
return __builtin_catanl(__z); }
1684 template<
typename _Tp>
1687 {
return __complex_atan(__z.__rep()); }
1692 template<
typename _Tp>
1695 {
return __complex_atan(__z); }
1698 template<
typename _Tp>
1704 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
1707 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1708 inline __complex__
float
1709 __complex_acosh(__complex__
float __z)
1710 {
return __builtin_cacoshf(__z); }
1712 inline __complex__
double
1713 __complex_acosh(__complex__
double __z)
1714 {
return __builtin_cacosh(__z); }
1716 inline __complex__
long double
1717 __complex_acosh(
const __complex__
long double& __z)
1718 {
return __builtin_cacoshl(__z); }
1720 template<
typename _Tp>
1723 {
return __complex_acosh(__z.__rep()); }
1728 template<
typename _Tp>
1731 {
return __complex_acosh(__z); }
1734 template<
typename _Tp>
1739 * (__z.real() + __z.imag()) + _Tp(1.0),
1740 _Tp(2.0) * __z.real() * __z.imag());
1746 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1747 inline __complex__
float
1748 __complex_asinh(__complex__
float __z)
1749 {
return __builtin_casinhf(__z); }
1751 inline __complex__
double
1752 __complex_asinh(__complex__
double __z)
1753 {
return __builtin_casinh(__z); }
1755 inline __complex__
long double
1756 __complex_asinh(
const __complex__
long double& __z)
1757 {
return __builtin_casinhl(__z); }
1759 template<
typename _Tp>
1762 {
return __complex_asinh(__z.__rep()); }
1767 template<
typename _Tp>
1770 {
return __complex_asinh(__z); }
1773 template<
typename _Tp>
1777 const _Tp __i2 = __z.imag() * __z.imag();
1778 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
1780 _Tp __num = _Tp(1.0) + __z.real();
1781 _Tp __den = _Tp(1.0) - __z.real();
1783 __num = __i2 + __num * __num;
1784 __den = __i2 + __den * __den;
1787 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
1790 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1791 inline __complex__
float
1792 __complex_atanh(__complex__
float __z)
1793 {
return __builtin_catanhf(__z); }
1795 inline __complex__
double
1796 __complex_atanh(__complex__
double __z)
1797 {
return __builtin_catanh(__z); }
1799 inline __complex__
long double
1800 __complex_atanh(
const __complex__
long double& __z)
1801 {
return __builtin_catanhl(__z); }
1803 template<
typename _Tp>
1806 {
return __complex_atanh(__z.__rep()); }
1811 template<
typename _Tp>
1814 {
return __complex_atanh(__z); }
1817 template<
typename _Tp>
1826 template<
typename _Tp>
1827 inline typename __gnu_cxx::__promote<_Tp>::__type
1830 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1831 #if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
1832 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
1839 template<
typename _Tp>
1840 inline typename __gnu_cxx::__promote<_Tp>::__type
1844 template<
typename _Tp>
1845 inline typename __gnu_cxx::__promote<_Tp>::__type
1848 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1849 return __type(__x) * __type(__x);
1852 template<
typename _Tp>
1853 inline typename __gnu_cxx::__promote<_Tp>::__type
1857 template<
typename _Tp,
typename _Up>
1861 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1865 template<
typename _Tp,
typename _Up>
1869 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1873 template<
typename _Tp,
typename _Up>
1877 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1886 template<
typename _Tp>
1890 const _Tp __den = (__z.real() * __z.real()
1891 + __z.imag() * __z.imag() + _Tp(1.0));
1894 (_Tp(2.0) * __z.imag()) / __den);
1897 #if _GLIBCXX_USE_C99_COMPLEX
1898 inline __complex__
float
1899 __complex_proj(__complex__
float __z)
1900 {
return __builtin_cprojf(__z); }
1902 inline __complex__
double
1903 __complex_proj(__complex__
double __z)
1904 {
return __builtin_cproj(__z); }
1906 inline __complex__
long double
1907 __complex_proj(
const __complex__
long double& __z)
1908 {
return __builtin_cprojl(__z); }
1910 template<
typename _Tp>
1913 {
return __complex_proj(__z.__rep()); }
1915 template<
typename _Tp>
1918 {
return __complex_proj(__z); }
1922 template<
typename _Tp>
1923 inline typename __gnu_cxx::__promote<_Tp>::__type
1927 template<
typename _Tp>
1928 inline typename __gnu_cxx::__promote<_Tp>::__type
1932 _GLIBCXX_END_NAMESPACE_VERSION
1934 #if __cplusplus > 201103L
1936 inline namespace literals {
1937 inline namespace complex_literals {
1938 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1940 #define __cpp_lib_complex_udls 201309
1943 operator""if(
long double __num)
1947 operator""if(
unsigned long long __num)
1951 operator""i(
long double __num)
1955 operator""i(
unsigned long long __num)
1959 operator""il(
long double __num)
1963 operator""il(
unsigned long long __num)
1966 _GLIBCXX_END_NAMESPACE_VERSION
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
constexpr complex(const complex< _Up > &__z)
Converting constructor.
locale imbue(const locale &__loc)
Moves to a new locale.
__istream_type & putback(char_type __c)
Unextracting a single character.
Controlling output for std::string.
std::complex< _Tp > asinh(const std::complex< _Tp > &)
asinh(__z) [8.1.6].
complex< _Tp > polar(const _Tp &, const _Tp &=0)
Return complex with magnitude rho and angle theta.
_Tp norm(const complex< _Tp > &)
Return z magnitude squared.
complex< _Tp > & operator*=(const _Tp &)
Multiply this complex number by a scalar.
complex< _Tp > tanh(const complex< _Tp > &)
Return complex hyperbolic tangent of z.
complex< _Tp > & operator/=(const _Tp &)
Divide this complex number by a scalar.
complex< _Tp > conj(const complex< _Tp > &)
Return complex conjugate of z.
Template class basic_istream.
complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
_Tp arg(const complex< _Tp > &)
Return phase angle of z.
complex< _Tp > tan(const complex< _Tp > &)
Return complex tangent of z.
complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
__string_type str() const
Copying out the string buffer.
26.2.3 complex specializations complex<long double> specialization
basic_ostream< char > ostream
Base class for char output streams.
fmtflags flags() const
Access to format flags.
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
std::complex< _Tp > asin(const std::complex< _Tp > &)
asin(__z) [8.1.3].
complex< _Tp > log10(const complex< _Tp > &)
Return complex base 10 logarithm of z.
std::complex< _Tp > atanh(const std::complex< _Tp > &)
atanh(__z) [8.1.7].
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
_GLIBCXX14_CONSTEXPR const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
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...
void setstate(iostate __state)
Sets additional flags in the error state.
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
streamsize precision() const
Flags access.
26.2.3 complex specializations complex<float> specialization
basic_ostream< wchar_t > wostream
Base class for wchar_t output streams.
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 value_type
Value typedef.
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
basic_istream< char > istream
Base class for char input streams.
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
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 > sqrt(const complex< _Tp > &)
Return complex square root of z.
26.2.3 complex specializations complex<double> specialization
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.
_Tp fabs(const std::complex< _Tp > &)
fabs(__z) [8.1.8].
std::complex< _Tp > acosh(const std::complex< _Tp > &)
acosh(__z) [8.1.5].
std::complex< _Tp > acos(const std::complex< _Tp > &)
acos(__z) [8.1.2].
complex< _Tp > & operator=(const _Tp &)
Assign a scalar to this complex number.
complex< _Tp > cosh(const complex< _Tp > &)
Return complex hyperbolic cosine of z.