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>&
499 if (_Traits::eq(__ch, __is.
widen(
'(')))
502 if (__is >> __u >> __ch)
504 const _CharT __rparen = __is.
widen(
')');
505 if (_Traits::eq(__ch, __rparen))
510 else if (_Traits::eq(__ch, __is.
widen(
',')))
513 if (__is >> __v >> __ch)
515 if (_Traits::eq(__ch, __rparen))
545 template<
typename _Tp,
typename _CharT,
class _Traits>
546 basic_ostream<_CharT, _Traits>&
547 operator<<(basic_ostream<_CharT, _Traits>& __os,
const complex<_Tp>& __x)
550 __s.
flags(__os.flags());
551 __s.
imbue(__os.getloc());
553 __s <<
'(' << __x.real() <<
',' << __x.imag() <<
')';
554 return __os << __s.
str();
558 #if __cplusplus >= 201103L
559 template<
typename _Tp>
561 real(
const complex<_Tp>& __z)
562 {
return __z.real(); }
564 template<
typename _Tp>
566 imag(
const complex<_Tp>& __z)
567 {
return __z.imag(); }
569 template<
typename _Tp>
571 real(complex<_Tp>& __z)
572 {
return __z.real(); }
574 template<
typename _Tp>
576 real(
const complex<_Tp>& __z)
577 {
return __z.real(); }
579 template<
typename _Tp>
581 imag(complex<_Tp>& __z)
582 {
return __z.imag(); }
584 template<
typename _Tp>
586 imag(
const complex<_Tp>& __z)
587 {
return __z.imag(); }
591 template<
typename _Tp>
593 __complex_abs(
const complex<_Tp>& __z)
595 _Tp __x = __z.real();
596 _Tp __y = __z.imag();
602 return __s *
sqrt(__x * __x + __y * __y);
605 #if _GLIBCXX_USE_C99_COMPLEX
607 __complex_abs(__complex__
float __z) {
return __builtin_cabsf(__z); }
610 __complex_abs(__complex__
double __z) {
return __builtin_cabs(__z); }
613 __complex_abs(
const __complex__
long double& __z)
614 {
return __builtin_cabsl(__z); }
616 template<
typename _Tp>
618 abs(
const complex<_Tp>& __z) {
return __complex_abs(__z.__rep()); }
620 template<
typename _Tp>
627 template<
typename _Tp>
629 __complex_arg(
const complex<_Tp>& __z)
630 {
return atan2(__z.imag(), __z.real()); }
632 #if _GLIBCXX_USE_C99_COMPLEX
634 __complex_arg(__complex__
float __z) {
return __builtin_cargf(__z); }
637 __complex_arg(__complex__
double __z) {
return __builtin_carg(__z); }
640 __complex_arg(
const __complex__
long double& __z)
641 {
return __builtin_cargl(__z); }
643 template<
typename _Tp>
645 arg(
const complex<_Tp>& __z) {
return __complex_arg(__z.__rep()); }
647 template<
typename _Tp>
660 template<
typename _Tp>
661 static inline _Tp _S_do_it(
const complex<_Tp>& __z)
663 const _Tp __x = __z.real();
664 const _Tp __y = __z.imag();
665 return __x * __x + __y * __y;
670 struct _Norm_helper<true>
672 template<
typename _Tp>
673 static inline _Tp _S_do_it(
const complex<_Tp>& __z)
676 return __res * __res;
680 template<
typename _Tp>
684 return _Norm_helper<__is_floating<_Tp>::__value
685 && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
688 template<
typename _Tp>
690 polar(
const _Tp& __rho,
const _Tp& __theta)
692 __glibcxx_assert( __rho >= 0 );
696 template<
typename _Tp>
704 template<
typename _Tp>
706 __complex_cos(
const complex<_Tp>& __z)
708 const _Tp __x = __z.real();
709 const _Tp __y = __z.imag();
713 #if _GLIBCXX_USE_C99_COMPLEX
714 inline __complex__
float
715 __complex_cos(__complex__
float __z) {
return __builtin_ccosf(__z); }
717 inline __complex__
double
718 __complex_cos(__complex__
double __z) {
return __builtin_ccos(__z); }
720 inline __complex__
long double
721 __complex_cos(
const __complex__
long double& __z)
722 {
return __builtin_ccosl(__z); }
724 template<
typename _Tp>
726 cos(
const complex<_Tp>& __z) {
return __complex_cos(__z.__rep()); }
728 template<
typename _Tp>
734 template<
typename _Tp>
736 __complex_cosh(
const complex<_Tp>& __z)
738 const _Tp __x = __z.real();
739 const _Tp __y = __z.imag();
743 #if _GLIBCXX_USE_C99_COMPLEX
744 inline __complex__
float
745 __complex_cosh(__complex__
float __z) {
return __builtin_ccoshf(__z); }
747 inline __complex__
double
748 __complex_cosh(__complex__
double __z) {
return __builtin_ccosh(__z); }
750 inline __complex__
long double
751 __complex_cosh(
const __complex__
long double& __z)
752 {
return __builtin_ccoshl(__z); }
754 template<
typename _Tp>
756 cosh(
const complex<_Tp>& __z) {
return __complex_cosh(__z.__rep()); }
758 template<
typename _Tp>
764 template<
typename _Tp>
766 __complex_exp(
const complex<_Tp>& __z)
767 {
return std::polar<_Tp>(
exp(__z.real()), __z.imag()); }
769 #if _GLIBCXX_USE_C99_COMPLEX
770 inline __complex__
float
771 __complex_exp(__complex__
float __z) {
return __builtin_cexpf(__z); }
773 inline __complex__
double
774 __complex_exp(__complex__
double __z) {
return __builtin_cexp(__z); }
776 inline __complex__
long double
777 __complex_exp(
const __complex__
long double& __z)
778 {
return __builtin_cexpl(__z); }
780 template<
typename _Tp>
782 exp(
const complex<_Tp>& __z) {
return __complex_exp(__z.__rep()); }
784 template<
typename _Tp>
791 template<
typename _Tp>
793 __complex_log(
const complex<_Tp>& __z)
796 #if _GLIBCXX_USE_C99_COMPLEX
797 inline __complex__
float
798 __complex_log(__complex__
float __z) {
return __builtin_clogf(__z); }
800 inline __complex__
double
801 __complex_log(__complex__
double __z) {
return __builtin_clog(__z); }
803 inline __complex__
long double
804 __complex_log(
const __complex__
long double& __z)
805 {
return __builtin_clogl(__z); }
807 template<
typename _Tp>
809 log(
const complex<_Tp>& __z) {
return __complex_log(__z.__rep()); }
811 template<
typename _Tp>
816 template<
typename _Tp>
822 template<
typename _Tp>
824 __complex_sin(
const complex<_Tp>& __z)
826 const _Tp __x = __z.real();
827 const _Tp __y = __z.imag();
831 #if _GLIBCXX_USE_C99_COMPLEX
832 inline __complex__
float
833 __complex_sin(__complex__
float __z) {
return __builtin_csinf(__z); }
835 inline __complex__
double
836 __complex_sin(__complex__
double __z) {
return __builtin_csin(__z); }
838 inline __complex__
long double
839 __complex_sin(
const __complex__
long double& __z)
840 {
return __builtin_csinl(__z); }
842 template<
typename _Tp>
844 sin(
const complex<_Tp>& __z) {
return __complex_sin(__z.__rep()); }
846 template<
typename _Tp>
852 template<
typename _Tp>
854 __complex_sinh(
const complex<_Tp>& __z)
856 const _Tp __x = __z.real();
857 const _Tp __y = __z.imag();
861 #if _GLIBCXX_USE_C99_COMPLEX
862 inline __complex__
float
863 __complex_sinh(__complex__
float __z) {
return __builtin_csinhf(__z); }
865 inline __complex__
double
866 __complex_sinh(__complex__
double __z) {
return __builtin_csinh(__z); }
868 inline __complex__
long double
869 __complex_sinh(
const __complex__
long double& __z)
870 {
return __builtin_csinhl(__z); }
872 template<
typename _Tp>
874 sinh(
const complex<_Tp>& __z) {
return __complex_sinh(__z.__rep()); }
876 template<
typename _Tp>
883 template<
typename _Tp>
885 __complex_sqrt(
const complex<_Tp>& __z)
887 _Tp __x = __z.real();
888 _Tp __y = __z.imag();
893 return complex<_Tp>(__t, __y < _Tp() ? -__t : __t);
900 ? complex<_Tp>(__u, __y / __t)
901 : complex<_Tp>(
abs(__y) / __t, __y < _Tp() ? -__u : __u);
905 #if _GLIBCXX_USE_C99_COMPLEX
906 inline __complex__
float
907 __complex_sqrt(__complex__
float __z) {
return __builtin_csqrtf(__z); }
909 inline __complex__
double
910 __complex_sqrt(__complex__
double __z) {
return __builtin_csqrt(__z); }
912 inline __complex__
long double
913 __complex_sqrt(
const __complex__
long double& __z)
914 {
return __builtin_csqrtl(__z); }
916 template<
typename _Tp>
918 sqrt(
const complex<_Tp>& __z) {
return __complex_sqrt(__z.__rep()); }
920 template<
typename _Tp>
927 template<
typename _Tp>
929 __complex_tan(
const complex<_Tp>& __z)
932 #if _GLIBCXX_USE_C99_COMPLEX
933 inline __complex__
float
934 __complex_tan(__complex__
float __z) {
return __builtin_ctanf(__z); }
936 inline __complex__
double
937 __complex_tan(__complex__
double __z) {
return __builtin_ctan(__z); }
939 inline __complex__
long double
940 __complex_tan(
const __complex__
long double& __z)
941 {
return __builtin_ctanl(__z); }
943 template<
typename _Tp>
945 tan(
const complex<_Tp>& __z) {
return __complex_tan(__z.__rep()); }
947 template<
typename _Tp>
955 template<
typename _Tp>
957 __complex_tanh(
const complex<_Tp>& __z)
960 #if _GLIBCXX_USE_C99_COMPLEX
961 inline __complex__
float
962 __complex_tanh(__complex__
float __z) {
return __builtin_ctanhf(__z); }
964 inline __complex__
double
965 __complex_tanh(__complex__
double __z) {
return __builtin_ctanh(__z); }
967 inline __complex__
long double
968 __complex_tanh(
const __complex__
long double& __z)
969 {
return __builtin_ctanhl(__z); }
971 template<
typename _Tp>
973 tanh(
const complex<_Tp>& __z) {
return __complex_tanh(__z.__rep()); }
975 template<
typename _Tp>
984 template<
typename _Tp>
986 __complex_pow_unsigned(complex<_Tp> __x,
unsigned __n)
988 complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1);
1006 template<
typename _Tp>
1011 ?
complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(
unsigned)__n)
1012 : std::__complex_pow_unsigned(__z, __n);
1015 template<
typename _Tp>
1019 #if ! _GLIBCXX_USE_C99_COMPLEX
1023 if (__x.imag() == _Tp() && __x.real() > _Tp())
1024 return pow(__x.real(), __y);
1027 return std::polar<_Tp>(
exp(__y * __t.real()), __y * __t.imag());
1030 template<
typename _Tp>
1032 __complex_pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1033 {
return __x == _Tp() ? _Tp() : std::
exp(__y * std::
log(__x)); }
1035 #if _GLIBCXX_USE_C99_COMPLEX
1036 inline __complex__
float
1037 __complex_pow(__complex__
float __x, __complex__
float __y)
1038 {
return __builtin_cpowf(__x, __y); }
1040 inline __complex__
double
1041 __complex_pow(__complex__
double __x, __complex__
double __y)
1042 {
return __builtin_cpow(__x, __y); }
1044 inline __complex__
long double
1045 __complex_pow(
const __complex__
long double& __x,
1046 const __complex__
long double& __y)
1047 {
return __builtin_cpowl(__x, __y); }
1049 template<
typename _Tp>
1051 pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1052 {
return __complex_pow(__x.__rep(), __y.__rep()); }
1054 template<
typename _Tp>
1057 {
return __complex_pow(__x, __y); }
1060 template<
typename _Tp>
1064 return __x > _Tp() ? std::polar<_Tp>(
pow(__x, __y.real()),
1065 __y.imag() *
log(__x))
1075 typedef __complex__
float _ComplexT;
1077 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1079 _GLIBCXX_CONSTEXPR
complex(
float __r = 0.0f,
float __i = 0.0f)
1080 #if __cplusplus >= 201103L
1081 : _M_value{ __r, __i } { }
1084 __real__ _M_value = __r;
1085 __imag__ _M_value = __i;
1092 #if __cplusplus >= 201103L
1095 __attribute ((__abi_tag__ (
"cxx11")))
1097 real()
const {
return __real__ _M_value; }
1099 __attribute ((__abi_tag__ (
"cxx11")))
1101 imag()
const {
return __imag__ _M_value; }
1104 real() {
return __real__ _M_value; }
1107 real()
const {
return __real__ _M_value; }
1110 imag() {
return __imag__ _M_value; }
1113 imag()
const {
return __imag__ _M_value; }
1119 real(
float __val) { __real__ _M_value = __val; }
1122 imag(
float __val) { __imag__ _M_value = __val; }
1163 template<
typename _Tp>
1167 __real__ _M_value = __z.real();
1168 __imag__ _M_value = __z.imag();
1172 template<
typename _Tp>
1176 __real__ _M_value += __z.real();
1177 __imag__ _M_value += __z.imag();
1185 __real__ _M_value -= __z.real();
1186 __imag__ _M_value -= __z.imag();
1195 __real__ __t = __z.real();
1196 __imag__ __t = __z.imag();
1206 __real__ __t = __z.real();
1207 __imag__ __t = __z.imag();
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; }
1270 real(
double __val) { __real__ _M_value = __val; }
1273 imag(
double __val) { __imag__ _M_value = __val; }
1313 template<
typename _Tp>
1317 __real__ _M_value = __z.real();
1318 __imag__ _M_value = __z.imag();
1322 template<
typename _Tp>
1326 __real__ _M_value += __z.real();
1327 __imag__ _M_value += __z.imag();
1331 template<
typename _Tp>
1335 __real__ _M_value -= __z.real();
1336 __imag__ _M_value -= __z.imag();
1340 template<
typename _Tp>
1345 __real__ __t = __z.real();
1346 __imag__ __t = __z.imag();
1351 template<
typename _Tp>
1356 __real__ __t = __z.real();
1357 __imag__ __t = __z.imag();
1362 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1374 typedef __complex__
long double _ComplexT;
1376 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1378 _GLIBCXX_CONSTEXPR
complex(
long double __r = 0.0L,
1379 long double __i = 0.0L)
1380 #if __cplusplus >= 201103L
1381 : _M_value{ __r, __i } { }
1384 __real__ _M_value = __r;
1385 __imag__ _M_value = __i;
1390 : _M_value(__z.__rep()) { }
1393 : _M_value(__z.__rep()) { }
1395 #if __cplusplus >= 201103L
1398 __attribute ((__abi_tag__ (
"cxx11")))
1399 constexpr
long double
1400 real()
const {
return __real__ _M_value; }
1402 __attribute ((__abi_tag__ (
"cxx11")))
1403 constexpr
long double
1404 imag()
const {
return __imag__ _M_value; }
1407 real() {
return __real__ _M_value; }
1410 real()
const {
return __real__ _M_value; }
1413 imag() {
return __imag__ _M_value; }
1416 imag()
const {
return __imag__ _M_value; }
1422 real(
long double __val) { __real__ _M_value = __val; }
1425 imag(
long double __val) { __imag__ _M_value = __val; }
1465 template<
typename _Tp>
1469 __real__ _M_value = __z.real();
1470 __imag__ _M_value = __z.imag();
1474 template<
typename _Tp>
1478 __real__ _M_value += __z.real();
1479 __imag__ _M_value += __z.imag();
1483 template<
typename _Tp>
1487 __real__ _M_value -= __z.real();
1488 __imag__ _M_value -= __z.imag();
1492 template<
typename _Tp>
1497 __real__ __t = __z.real();
1498 __imag__ __t = __z.imag();
1503 template<
typename _Tp>
1508 __real__ __t = __z.real();
1509 __imag__ __t = __z.imag();
1514 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1522 inline _GLIBCXX_CONSTEXPR
1524 : _M_value(__z.__rep()) { }
1526 inline _GLIBCXX_CONSTEXPR
1528 : _M_value(__z.__rep()) { }
1530 inline _GLIBCXX_CONSTEXPR
1532 : _M_value(__z.__rep()) { }
1537 #if _GLIBCXX_EXTERN_TEMPLATE
1539 extern template ostream& operator<<(ostream&, const complex<float>&);
1541 extern template ostream& operator<<(ostream&, const complex<double>&);
1543 extern template ostream& operator<<(ostream&, const complex<long double>&);
1545 #ifdef _GLIBCXX_USE_WCHAR_T
1547 extern template wostream& operator<<(wostream&, const complex<float>&);
1549 extern template wostream& operator<<(wostream&, const complex<double>&);
1551 extern template wostream& operator<<(wostream&, const complex<long double>&);
1557 _GLIBCXX_END_NAMESPACE_VERSION
1560 namespace __gnu_cxx _GLIBCXX_VISIBILITY(
default)
1562 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1565 template<
typename _Tp,
typename _Up>
1566 struct __promote_2<std::complex<_Tp>, _Up>
1572 template<
typename _Tp,
typename _Up>
1573 struct __promote_2<_Tp, std::complex<_Up> >
1579 template<
typename _Tp,
typename _Up>
1580 struct __promote_2<std::complex<_Tp>,
std::complex<_Up> >
1586 _GLIBCXX_END_NAMESPACE_VERSION
1589 #if __cplusplus >= 201103L
1591 namespace std _GLIBCXX_VISIBILITY(default)
1593 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1606 template<
typename _Tp>
1611 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
1615 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1616 inline __complex__
float
1617 __complex_acos(__complex__
float __z)
1618 {
return __builtin_cacosf(__z); }
1620 inline __complex__
double
1621 __complex_acos(__complex__
double __z)
1622 {
return __builtin_cacos(__z); }
1624 inline __complex__
long double
1625 __complex_acos(
const __complex__
long double& __z)
1626 {
return __builtin_cacosl(__z); }
1628 template<
typename _Tp>
1631 {
return __complex_acos(__z.__rep()); }
1636 template<
typename _Tp>
1639 {
return __complex_acos(__z); }
1642 template<
typename _Tp>
1651 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1652 inline __complex__
float
1653 __complex_asin(__complex__
float __z)
1654 {
return __builtin_casinf(__z); }
1656 inline __complex__
double
1657 __complex_asin(__complex__
double __z)
1658 {
return __builtin_casin(__z); }
1660 inline __complex__
long double
1661 __complex_asin(
const __complex__
long double& __z)
1662 {
return __builtin_casinl(__z); }
1664 template<
typename _Tp>
1667 {
return __complex_asin(__z.__rep()); }
1672 template<
typename _Tp>
1675 {
return __complex_asin(__z); }
1678 template<
typename _Tp>
1682 const _Tp __r2 = __z.real() * __z.real();
1683 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
1685 _Tp __num = __z.imag() + _Tp(1.0);
1686 _Tp __den = __z.imag() - _Tp(1.0);
1688 __num = __r2 + __num * __num;
1689 __den = __r2 + __den * __den;
1692 _Tp(0.25) *
log(__num / __den));
1695 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1696 inline __complex__
float
1697 __complex_atan(__complex__
float __z)
1698 {
return __builtin_catanf(__z); }
1700 inline __complex__
double
1701 __complex_atan(__complex__
double __z)
1702 {
return __builtin_catan(__z); }
1704 inline __complex__
long double
1705 __complex_atan(
const __complex__
long double& __z)
1706 {
return __builtin_catanl(__z); }
1708 template<
typename _Tp>
1711 {
return __complex_atan(__z.__rep()); }
1716 template<
typename _Tp>
1719 {
return __complex_atan(__z); }
1722 template<
typename _Tp>
1728 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
1731 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1732 inline __complex__
float
1733 __complex_acosh(__complex__
float __z)
1734 {
return __builtin_cacoshf(__z); }
1736 inline __complex__
double
1737 __complex_acosh(__complex__
double __z)
1738 {
return __builtin_cacosh(__z); }
1740 inline __complex__
long double
1741 __complex_acosh(
const __complex__
long double& __z)
1742 {
return __builtin_cacoshl(__z); }
1744 template<
typename _Tp>
1747 {
return __complex_acosh(__z.__rep()); }
1752 template<
typename _Tp>
1755 {
return __complex_acosh(__z); }
1758 template<
typename _Tp>
1763 * (__z.real() + __z.imag()) + _Tp(1.0),
1764 _Tp(2.0) * __z.real() * __z.imag());
1770 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1771 inline __complex__
float
1772 __complex_asinh(__complex__
float __z)
1773 {
return __builtin_casinhf(__z); }
1775 inline __complex__
double
1776 __complex_asinh(__complex__
double __z)
1777 {
return __builtin_casinh(__z); }
1779 inline __complex__
long double
1780 __complex_asinh(
const __complex__
long double& __z)
1781 {
return __builtin_casinhl(__z); }
1783 template<
typename _Tp>
1786 {
return __complex_asinh(__z.__rep()); }
1791 template<
typename _Tp>
1794 {
return __complex_asinh(__z); }
1797 template<
typename _Tp>
1801 const _Tp __i2 = __z.imag() * __z.imag();
1802 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
1804 _Tp __num = _Tp(1.0) + __z.real();
1805 _Tp __den = _Tp(1.0) - __z.real();
1807 __num = __i2 + __num * __num;
1808 __den = __i2 + __den * __den;
1811 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
1814 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1815 inline __complex__
float
1816 __complex_atanh(__complex__
float __z)
1817 {
return __builtin_catanhf(__z); }
1819 inline __complex__
double
1820 __complex_atanh(__complex__
double __z)
1821 {
return __builtin_catanh(__z); }
1823 inline __complex__
long double
1824 __complex_atanh(
const __complex__
long double& __z)
1825 {
return __builtin_catanhl(__z); }
1827 template<
typename _Tp>
1830 {
return __complex_atanh(__z.__rep()); }
1835 template<
typename _Tp>
1838 {
return __complex_atanh(__z); }
1841 template<
typename _Tp>
1850 template<
typename _Tp>
1851 inline typename __gnu_cxx::__promote<_Tp>::__type
1854 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1855 #if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
1856 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
1863 template<
typename _Tp>
1864 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1868 template<
typename _Tp>
1869 inline typename __gnu_cxx::__promote<_Tp>::__type
1872 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1873 return __type(__x) * __type(__x);
1876 template<
typename _Tp>
1877 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1881 template<
typename _Tp,
typename _Up>
1885 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1889 template<
typename _Tp,
typename _Up>
1893 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1897 template<
typename _Tp,
typename _Up>
1901 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1910 template<
typename _Tp>
1914 const _Tp __den = (__z.real() * __z.real()
1915 + __z.imag() * __z.imag() + _Tp(1.0));
1918 (_Tp(2.0) * __z.imag()) / __den);
1921 #if _GLIBCXX_USE_C99_COMPLEX
1922 inline __complex__
float
1923 __complex_proj(__complex__
float __z)
1924 {
return __builtin_cprojf(__z); }
1926 inline __complex__
double
1927 __complex_proj(__complex__
double __z)
1928 {
return __builtin_cproj(__z); }
1930 inline __complex__
long double
1931 __complex_proj(
const __complex__
long double& __z)
1932 {
return __builtin_cprojl(__z); }
1934 template<
typename _Tp>
1937 {
return __complex_proj(__z.__rep()); }
1939 template<
typename _Tp>
1942 {
return __complex_proj(__z); }
1945 template<
typename _Tp>
1949 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1953 template<
typename _Tp>
1957 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1961 #if __cplusplus > 201103L
1963 inline namespace literals {
1964 inline namespace complex_literals {
1965 #pragma GCC diagnostic push
1966 #pragma GCC diagnostic ignored "-Wliteral-suffix"
1967 #define __cpp_lib_complex_udls 201309
1970 operator""if(
long double __num)
1974 operator""if(
unsigned long long __num)
1978 operator""i(
long double __num)
1982 operator""i(
unsigned long long __num)
1986 operator""il(
long double __num)
1990 operator""il(
unsigned long long __num)
1993 #pragma GCC diagnostic pop
1999 _GLIBCXX_END_NAMESPACE_VERSION
_Tp value_type
Value typedef.
complex< _Tp > & operator/=(const _Tp &)
Divide this complex number by a scalar.
_Tp fabs(const std::complex< _Tp > &)
fabs(__z) [8.1.8].
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
_Tp norm(const complex< _Tp > &)
Return z magnitude squared.
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
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.
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 > tan(const complex< _Tp > &)
Return complex tangent of z.
basic_ostream< char > ostream
Base class for char output streams.
26.2.3 complex specializations complex<long double> specialization
complex< _Tp > polar(const _Tp &, const _Tp &=0)
Return complex with magnitude rho and angle theta.
std::complex< _Tp > atan(const std::complex< _Tp > &)
atan(__z) [8.1.4].
std::complex< _Tp > acos(const std::complex< _Tp > &)
acos(__z) [8.1.2].
complex< _Tp > cosh(const complex< _Tp > &)
Return complex hyperbolic cosine of z.
26.2.3 complex specializations complex<double> specialization
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
complex< _Tp > operator/(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x divided by y.
__string_type str() const
Copying out the string buffer.
Controlling output for std::string.
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
std::complex< _Tp > asin(const std::complex< _Tp > &)
asin(__z) [8.1.3].
complex< _Tp > tanh(const complex< _Tp > &)
Return complex hyperbolic tangent of z.
std::complex< _Tp > asinh(const std::complex< _Tp > &)
asinh(__z) [8.1.6].
complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
complex< _Tp > sinh(const complex< _Tp > &)
Return complex hyperbolic sine of z.
26.2.3 complex specializations complex<float> specialization
std::complex< _Tp > acosh(const std::complex< _Tp > &)
acosh(__z) [8.1.5].
complex< _Tp > & operator=(const _Tp &)
Assign a scalar to this complex number.
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
_Tp arg(const complex< _Tp > &)
Return phase angle of z.
Template class basic_istream.
_GLIBCXX14_CONSTEXPR const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
fmtflags flags() const
Access to format flags.
complex< _Tp > & operator*=(const _Tp &)
Multiply this complex number by a scalar.
basic_ostream< wchar_t > wostream
Base class for wchar_t output streams.
std::complex< _Tp > atanh(const std::complex< _Tp > &)
atanh(__z) [8.1.7].
complex< _Tp > conj(const complex< _Tp > &)
Return complex conjugate of z.
__istream_type & putback(char_type __c)
Unextracting a single character.
streamsize precision() const
Flags access.
void setstate(iostate __state)
Sets additional flags in the error state.
char_type widen(char __c) const
Widens characters.
complex< _Tp > log10(const complex< _Tp > &)
Return complex base 10 logarithm of z.
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
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.
basic_istream< char > istream
Base class for char input streams.
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.