38 #ifndef _GLIBCXX_COMPLEX
39 #define _GLIBCXX_COMPLEX 1
41 #pragma GCC system_header
49 namespace std _GLIBCXX_VISIBILITY(default)
51 _GLIBCXX_BEGIN_NAMESPACE_VERSION
63 template<>
class complex<float>;
64 template<>
class complex<double>;
65 template<>
class complex<long double>;
90 #ifndef __GXX_EXPERIMENTAL_CXX0X__
123 template<
typename _Tp>
131 _GLIBCXX_CONSTEXPR
complex(
const _Tp& __r = _Tp(),
const _Tp& __i = _Tp())
132 : _M_real(__r), _M_imag(__i) { }
137 template<
typename _Up>
139 : _M_real(__z.real()), _M_imag(__z.imag()) { }
141 #ifdef __GXX_EXPERIMENTAL_CXX0X__
145 real()
const {
return _M_real; }
148 imag()
const {
return _M_imag; }
152 real() {
return _M_real; }
156 real()
const {
return _M_real; }
160 imag() {
return _M_imag; }
164 imag()
const {
return _M_imag; }
170 real(_Tp __val) { _M_real = __val; }
173 imag(_Tp __val) { _M_imag = __val; }
205 template<
typename _Up>
208 template<
typename _Up>
211 template<
typename _Up>
214 template<
typename _Up>
217 template<
typename _Up>
220 _GLIBCXX_USE_CONSTEXPR
complex __rep()
const
228 template<
typename _Tp>
238 template<
typename _Tp>
248 template<
typename _Tp>
257 template<
typename _Tp>
258 template<
typename _Up>
262 _M_real = __z.real();
263 _M_imag = __z.imag();
268 template<
typename _Tp>
269 template<
typename _Up>
273 _M_real += __z.real();
274 _M_imag += __z.imag();
279 template<
typename _Tp>
280 template<
typename _Up>
284 _M_real -= __z.real();
285 _M_imag -= __z.imag();
291 template<
typename _Tp>
292 template<
typename _Up>
296 const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
297 _M_imag = _M_real * __z.imag() + _M_imag * __z.real();
304 template<
typename _Tp>
305 template<
typename _Up>
309 const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag();
311 _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n;
319 template<
typename _Tp>
328 template<
typename _Tp>
337 template<
typename _Tp>
349 template<
typename _Tp>
358 template<
typename _Tp>
367 template<
typename _Tp>
379 template<
typename _Tp>
388 template<
typename _Tp>
397 template<
typename _Tp>
409 template<
typename _Tp>
418 template<
typename _Tp>
427 template<
typename _Tp>
438 template<
typename _Tp>
444 template<
typename _Tp>
451 template<
typename _Tp>
452 inline _GLIBCXX_CONSTEXPR
bool
454 {
return __x.real() == __y.real() && __x.imag() == __y.imag(); }
456 template<
typename _Tp>
457 inline _GLIBCXX_CONSTEXPR
bool
459 {
return __x.real() == __y && __x.imag() == _Tp(); }
461 template<
typename _Tp>
462 inline _GLIBCXX_CONSTEXPR
bool
464 {
return __x == __y.real() && _Tp() == __y.imag(); }
469 template<
typename _Tp>
470 inline _GLIBCXX_CONSTEXPR
bool
472 {
return __x.real() != __y.real() || __x.imag() != __y.imag(); }
474 template<
typename _Tp>
475 inline _GLIBCXX_CONSTEXPR
bool
477 {
return __x.real() != __y || __x.imag() != _Tp(); }
479 template<
typename _Tp>
480 inline _GLIBCXX_CONSTEXPR
bool
482 {
return __x != __y.real() || _Tp() != __y.imag(); }
486 template<
typename _Tp,
typename _CharT,
class _Traits>
487 basic_istream<_CharT, _Traits>&
495 __is >> __re_x >> __ch;
498 __is >> __im_x >> __ch;
504 else if (__ch ==
')')
519 template<
typename _Tp,
typename _CharT,
class _Traits>
520 basic_ostream<_CharT, _Traits>&
521 operator<<(basic_ostream<_CharT, _Traits>& __os,
const complex<_Tp>& __x)
524 __s.
flags(__os.flags());
525 __s.
imbue(__os.getloc());
527 __s <<
'(' << __x.real() <<
',' << __x.imag() <<
')';
528 return __os << __s.
str();
532 #ifdef __GXX_EXPERIMENTAL_CXX0X__
533 template<
typename _Tp>
535 real(
const complex<_Tp>& __z)
536 {
return __z.real(); }
538 template<
typename _Tp>
540 imag(
const complex<_Tp>& __z)
541 {
return __z.imag(); }
543 template<
typename _Tp>
545 real(complex<_Tp>& __z)
546 {
return __z.real(); }
548 template<
typename _Tp>
550 real(
const complex<_Tp>& __z)
551 {
return __z.real(); }
553 template<
typename _Tp>
555 imag(complex<_Tp>& __z)
556 {
return __z.imag(); }
558 template<
typename _Tp>
560 imag(
const complex<_Tp>& __z)
561 {
return __z.imag(); }
565 template<
typename _Tp>
567 __complex_abs(
const complex<_Tp>& __z)
569 _Tp __x = __z.real();
570 _Tp __y = __z.imag();
576 return __s *
sqrt(__x * __x + __y * __y);
579 #if _GLIBCXX_USE_C99_COMPLEX
581 __complex_abs(__complex__
float __z) {
return __builtin_cabsf(__z); }
584 __complex_abs(__complex__
double __z) {
return __builtin_cabs(__z); }
587 __complex_abs(
const __complex__
long double& __z)
588 {
return __builtin_cabsl(__z); }
590 template<
typename _Tp>
592 abs(
const complex<_Tp>& __z) {
return __complex_abs(__z.__rep()); }
594 template<
typename _Tp>
601 template<
typename _Tp>
603 __complex_arg(
const complex<_Tp>& __z)
604 {
return atan2(__z.imag(), __z.real()); }
606 #if _GLIBCXX_USE_C99_COMPLEX
608 __complex_arg(__complex__
float __z) {
return __builtin_cargf(__z); }
611 __complex_arg(__complex__
double __z) {
return __builtin_carg(__z); }
614 __complex_arg(
const __complex__
long double& __z)
615 {
return __builtin_cargl(__z); }
617 template<
typename _Tp>
619 arg(
const complex<_Tp>& __z) {
return __complex_arg(__z.__rep()); }
621 template<
typename _Tp>
634 template<
typename _Tp>
635 static inline _Tp _S_do_it(
const complex<_Tp>& __z)
637 const _Tp __x = __z.real();
638 const _Tp __y = __z.imag();
639 return __x * __x + __y * __y;
644 struct _Norm_helper<true>
646 template<
typename _Tp>
647 static inline _Tp _S_do_it(
const complex<_Tp>& __z)
650 return __res * __res;
654 template<
typename _Tp>
658 return _Norm_helper<__is_floating<_Tp>::__value
659 && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
662 template<
typename _Tp>
664 polar(
const _Tp& __rho,
const _Tp& __theta)
667 template<
typename _Tp>
675 template<
typename _Tp>
677 __complex_cos(
const complex<_Tp>& __z)
679 const _Tp __x = __z.real();
680 const _Tp __y = __z.imag();
684 #if _GLIBCXX_USE_C99_COMPLEX
685 inline __complex__
float
686 __complex_cos(__complex__
float __z) {
return __builtin_ccosf(__z); }
688 inline __complex__
double
689 __complex_cos(__complex__
double __z) {
return __builtin_ccos(__z); }
691 inline __complex__
long double
692 __complex_cos(
const __complex__
long double& __z)
693 {
return __builtin_ccosl(__z); }
695 template<
typename _Tp>
697 cos(
const complex<_Tp>& __z) {
return __complex_cos(__z.__rep()); }
699 template<
typename _Tp>
705 template<
typename _Tp>
707 __complex_cosh(
const complex<_Tp>& __z)
709 const _Tp __x = __z.real();
710 const _Tp __y = __z.imag();
714 #if _GLIBCXX_USE_C99_COMPLEX
715 inline __complex__
float
716 __complex_cosh(__complex__
float __z) {
return __builtin_ccoshf(__z); }
718 inline __complex__
double
719 __complex_cosh(__complex__
double __z) {
return __builtin_ccosh(__z); }
721 inline __complex__
long double
722 __complex_cosh(
const __complex__
long double& __z)
723 {
return __builtin_ccoshl(__z); }
725 template<
typename _Tp>
727 cosh(
const complex<_Tp>& __z) {
return __complex_cosh(__z.__rep()); }
729 template<
typename _Tp>
735 template<
typename _Tp>
737 __complex_exp(
const complex<_Tp>& __z)
740 #if _GLIBCXX_USE_C99_COMPLEX
741 inline __complex__
float
742 __complex_exp(__complex__
float __z) {
return __builtin_cexpf(__z); }
744 inline __complex__
double
745 __complex_exp(__complex__
double __z) {
return __builtin_cexp(__z); }
747 inline __complex__
long double
748 __complex_exp(
const __complex__
long double& __z)
749 {
return __builtin_cexpl(__z); }
751 template<
typename _Tp>
753 exp(
const complex<_Tp>& __z) {
return __complex_exp(__z.__rep()); }
755 template<
typename _Tp>
762 template<
typename _Tp>
764 __complex_log(
const complex<_Tp>& __z)
767 #if _GLIBCXX_USE_C99_COMPLEX
768 inline __complex__
float
769 __complex_log(__complex__
float __z) {
return __builtin_clogf(__z); }
771 inline __complex__
double
772 __complex_log(__complex__
double __z) {
return __builtin_clog(__z); }
774 inline __complex__
long double
775 __complex_log(
const __complex__
long double& __z)
776 {
return __builtin_clogl(__z); }
778 template<
typename _Tp>
780 log(
const complex<_Tp>& __z) {
return __complex_log(__z.__rep()); }
782 template<
typename _Tp>
787 template<
typename _Tp>
793 template<
typename _Tp>
795 __complex_sin(
const complex<_Tp>& __z)
797 const _Tp __x = __z.real();
798 const _Tp __y = __z.imag();
802 #if _GLIBCXX_USE_C99_COMPLEX
803 inline __complex__
float
804 __complex_sin(__complex__
float __z) {
return __builtin_csinf(__z); }
806 inline __complex__
double
807 __complex_sin(__complex__
double __z) {
return __builtin_csin(__z); }
809 inline __complex__
long double
810 __complex_sin(
const __complex__
long double& __z)
811 {
return __builtin_csinl(__z); }
813 template<
typename _Tp>
815 sin(
const complex<_Tp>& __z) {
return __complex_sin(__z.__rep()); }
817 template<
typename _Tp>
823 template<
typename _Tp>
825 __complex_sinh(
const complex<_Tp>& __z)
827 const _Tp __x = __z.real();
828 const _Tp __y = __z.imag();
832 #if _GLIBCXX_USE_C99_COMPLEX
833 inline __complex__
float
834 __complex_sinh(__complex__
float __z) {
return __builtin_csinhf(__z); }
836 inline __complex__
double
837 __complex_sinh(__complex__
double __z) {
return __builtin_csinh(__z); }
839 inline __complex__
long double
840 __complex_sinh(
const __complex__
long double& __z)
841 {
return __builtin_csinhl(__z); }
843 template<
typename _Tp>
845 sinh(
const complex<_Tp>& __z) {
return __complex_sinh(__z.__rep()); }
847 template<
typename _Tp>
854 template<
typename _Tp>
856 __complex_sqrt(
const complex<_Tp>& __z)
858 _Tp __x = __z.real();
859 _Tp __y = __z.imag();
864 return complex<_Tp>(__t, __y < _Tp() ? -__t : __t);
871 ? complex<_Tp>(__u, __y / __t)
872 : complex<_Tp>(
abs(__y) / __t, __y < _Tp() ? -__u : __u);
876 #if _GLIBCXX_USE_C99_COMPLEX
877 inline __complex__
float
878 __complex_sqrt(__complex__
float __z) {
return __builtin_csqrtf(__z); }
880 inline __complex__
double
881 __complex_sqrt(__complex__
double __z) {
return __builtin_csqrt(__z); }
883 inline __complex__
long double
884 __complex_sqrt(
const __complex__
long double& __z)
885 {
return __builtin_csqrtl(__z); }
887 template<
typename _Tp>
889 sqrt(
const complex<_Tp>& __z) {
return __complex_sqrt(__z.__rep()); }
891 template<
typename _Tp>
898 template<
typename _Tp>
900 __complex_tan(
const complex<_Tp>& __z)
903 #if _GLIBCXX_USE_C99_COMPLEX
904 inline __complex__
float
905 __complex_tan(__complex__
float __z) {
return __builtin_ctanf(__z); }
907 inline __complex__
double
908 __complex_tan(__complex__
double __z) {
return __builtin_ctan(__z); }
910 inline __complex__
long double
911 __complex_tan(
const __complex__
long double& __z)
912 {
return __builtin_ctanl(__z); }
914 template<
typename _Tp>
916 tan(
const complex<_Tp>& __z) {
return __complex_tan(__z.__rep()); }
918 template<
typename _Tp>
926 template<
typename _Tp>
928 __complex_tanh(
const complex<_Tp>& __z)
931 #if _GLIBCXX_USE_C99_COMPLEX
932 inline __complex__
float
933 __complex_tanh(__complex__
float __z) {
return __builtin_ctanhf(__z); }
935 inline __complex__
double
936 __complex_tanh(__complex__
double __z) {
return __builtin_ctanh(__z); }
938 inline __complex__
long double
939 __complex_tanh(
const __complex__
long double& __z)
940 {
return __builtin_ctanhl(__z); }
942 template<
typename _Tp>
944 tanh(
const complex<_Tp>& __z) {
return __complex_tanh(__z.__rep()); }
946 template<
typename _Tp>
955 #ifndef __GXX_EXPERIMENTAL_CXX0X__
956 template<
typename _Tp>
958 __complex_pow_unsigned(complex<_Tp> __x,
unsigned __n)
960 complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1);
974 template<
typename _Tp>
976 pow(
const complex<_Tp>& __z,
int __n)
979 ? complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -__n)
980 : std::__complex_pow_unsigned(__z, __n);
984 template<
typename _Tp>
988 #ifndef _GLIBCXX_USE_C99_COMPLEX
992 if (__x.imag() == _Tp() && __x.real() > _Tp())
993 return pow(__x.real(), __y);
999 template<
typename _Tp>
1001 __complex_pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1002 {
return __x == _Tp() ? _Tp() : std::
exp(__y * std::
log(__x)); }
1004 #if _GLIBCXX_USE_C99_COMPLEX
1005 inline __complex__
float
1006 __complex_pow(__complex__
float __x, __complex__
float __y)
1007 {
return __builtin_cpowf(__x, __y); }
1009 inline __complex__
double
1010 __complex_pow(__complex__
double __x, __complex__
double __y)
1011 {
return __builtin_cpow(__x, __y); }
1013 inline __complex__
long double
1014 __complex_pow(
const __complex__
long double& __x,
1015 const __complex__
long double& __y)
1016 {
return __builtin_cpowl(__x, __y); }
1018 template<
typename _Tp>
1020 pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1021 {
return __complex_pow(__x.__rep(), __y.__rep()); }
1023 template<
typename _Tp>
1026 {
return __complex_pow(__x, __y); }
1029 template<
typename _Tp>
1034 __y.imag() *
log(__x))
1041 struct complex<float>
1044 typedef __complex__
float _ComplexT;
1046 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1048 _GLIBCXX_CONSTEXPR
complex(
float __r = 0.0f,
float __i = 0.0f)
1049 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1053 : _M_value(__r + __i * 1.0fi) { }
1056 __real__ _M_value = __r;
1057 __imag__ _M_value = __i;
1061 explicit _GLIBCXX_CONSTEXPR
complex(
const complex<double>&);
1062 explicit _GLIBCXX_CONSTEXPR
complex(
const complex<long double>&);
1064 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1068 real()
const {
return __real__ _M_value; }
1071 imag()
const {
return __imag__ _M_value; }
1074 real() {
return __real__ _M_value; }
1077 real()
const {
return __real__ _M_value; }
1080 imag() {
return __imag__ _M_value; }
1083 imag()
const {
return __imag__ _M_value; }
1089 real(
float __val) { __real__ _M_value = __val; }
1092 imag(
float __val) { __imag__ _M_value = __val; }
1133 template<
typename _Tp>
1137 __real__ _M_value = __z.real();
1138 __imag__ _M_value = __z.imag();
1142 template<
typename _Tp>
1146 __real__ _M_value += __z.real();
1147 __imag__ _M_value += __z.imag();
1155 __real__ _M_value -= __z.real();
1156 __imag__ _M_value -= __z.imag();
1165 __real__ __t = __z.real();
1166 __imag__ __t = __z.imag();
1176 __real__ __t = __z.real();
1177 __imag__ __t = __z.imag();
1182 _GLIBCXX_USE_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1191 struct complex<double>
1194 typedef __complex__
double _ComplexT;
1196 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1198 _GLIBCXX_CONSTEXPR
complex(
double __r = 0.0,
double __i = 0.0)
1199 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1203 : _M_value(__r + __i * 1.0i) { }
1206 __real__ _M_value = __r;
1207 __imag__ _M_value = __i;
1211 _GLIBCXX_CONSTEXPR
complex(
const complex<float>& __z)
1212 : _M_value(__z.__rep()) { }
1214 explicit _GLIBCXX_CONSTEXPR
complex(
const complex<long double>&);
1216 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1220 real()
const {
return __real__ _M_value; }
1223 imag()
const {
return __imag__ _M_value; }
1226 real() {
return __real__ _M_value; }
1229 real()
const {
return __real__ _M_value; }
1232 imag() {
return __imag__ _M_value; }
1235 imag()
const {
return __imag__ _M_value; }
1241 real(
double __val) { __real__ _M_value = __val; }
1244 imag(
double __val) { __imag__ _M_value = __val; }
1284 template<
typename _Tp>
1288 __real__ _M_value = __z.real();
1289 __imag__ _M_value = __z.imag();
1293 template<
typename _Tp>
1297 __real__ _M_value += __z.real();
1298 __imag__ _M_value += __z.imag();
1302 template<
typename _Tp>
1306 __real__ _M_value -= __z.real();
1307 __imag__ _M_value -= __z.imag();
1311 template<
typename _Tp>
1316 __real__ __t = __z.real();
1317 __imag__ __t = __z.imag();
1322 template<
typename _Tp>
1327 __real__ __t = __z.real();
1328 __imag__ __t = __z.imag();
1333 _GLIBCXX_USE_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1342 struct complex<long double>
1345 typedef __complex__
long double _ComplexT;
1347 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1349 _GLIBCXX_CONSTEXPR
complex(
long double __r = 0.0L,
1350 long double __i = 0.0L)
1351 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1355 : _M_value(__r + __i * 1.0Li) { }
1358 __real__ _M_value = __r;
1359 __imag__ _M_value = __i;
1363 _GLIBCXX_CONSTEXPR
complex(
const complex<float>& __z)
1364 : _M_value(__z.__rep()) { }
1366 _GLIBCXX_CONSTEXPR
complex(
const complex<double>& __z)
1367 : _M_value(__z.__rep()) { }
1369 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1372 constexpr
long double
1373 real()
const {
return __real__ _M_value; }
1375 constexpr
long double
1376 imag()
const {
return __imag__ _M_value; }
1379 real() {
return __real__ _M_value; }
1382 real()
const {
return __real__ _M_value; }
1385 imag() {
return __imag__ _M_value; }
1388 imag()
const {
return __imag__ _M_value; }
1394 real(
long double __val) { __real__ _M_value = __val; }
1397 imag(
long double __val) { __imag__ _M_value = __val; }
1437 template<
typename _Tp>
1441 __real__ _M_value = __z.real();
1442 __imag__ _M_value = __z.imag();
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>
1469 __real__ __t = __z.real();
1470 __imag__ __t = __z.imag();
1475 template<
typename _Tp>
1480 __real__ __t = __z.real();
1481 __imag__ __t = __z.imag();
1486 _GLIBCXX_USE_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1494 inline _GLIBCXX_CONSTEXPR
1496 : _M_value(__z.__rep()) { }
1498 inline _GLIBCXX_CONSTEXPR
1499 complex<float>::complex(
const complex<long double>& __z)
1500 : _M_value(__z.__rep()) { }
1502 inline _GLIBCXX_CONSTEXPR
1503 complex<double>::complex(
const complex<long double>& __z)
1504 : _M_value(__z.__rep()) { }
1509 #if _GLIBCXX_EXTERN_TEMPLATE
1511 extern template ostream& operator<<(ostream&, const complex<float>&);
1513 extern template ostream& operator<<(ostream&, const complex<double>&);
1515 extern template ostream& operator<<(ostream&, const complex<long double>&);
1517 #ifdef _GLIBCXX_USE_WCHAR_T
1519 extern template wostream& operator<<(wostream&, const complex<float>&);
1521 extern template wostream& operator<<(wostream&, const complex<double>&);
1523 extern template wostream& operator<<(wostream&, const complex<long double>&);
1529 _GLIBCXX_END_NAMESPACE_VERSION
1532 namespace __gnu_cxx _GLIBCXX_VISIBILITY(
default)
1534 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1537 template<
typename _Tp,
typename _Up>
1538 struct __promote_2<std::complex<_Tp>, _Up>
1544 template<
typename _Tp,
typename _Up>
1545 struct __promote_2<_Tp, std::complex<_Up> >
1551 template<
typename _Tp,
typename _Up>
1552 struct __promote_2<std::complex<_Tp>,
std::complex<_Up> >
1558 _GLIBCXX_END_NAMESPACE_VERSION
1561 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1563 namespace std _GLIBCXX_VISIBILITY(default)
1565 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1578 template<
typename _Tp>
1583 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
1587 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1588 inline __complex__
float
1589 __complex_acos(__complex__
float __z)
1590 {
return __builtin_cacosf(__z); }
1592 inline __complex__
double
1593 __complex_acos(__complex__
double __z)
1594 {
return __builtin_cacos(__z); }
1596 inline __complex__
long double
1597 __complex_acos(
const __complex__
long double& __z)
1598 {
return __builtin_cacosl(__z); }
1600 template<
typename _Tp>
1603 {
return __complex_acos(__z.__rep()); }
1608 template<
typename _Tp>
1611 {
return __complex_acos(__z); }
1614 template<
typename _Tp>
1623 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1624 inline __complex__
float
1625 __complex_asin(__complex__
float __z)
1626 {
return __builtin_casinf(__z); }
1628 inline __complex__
double
1629 __complex_asin(__complex__
double __z)
1630 {
return __builtin_casin(__z); }
1632 inline __complex__
long double
1633 __complex_asin(
const __complex__
long double& __z)
1634 {
return __builtin_casinl(__z); }
1636 template<
typename _Tp>
1639 {
return __complex_asin(__z.__rep()); }
1644 template<
typename _Tp>
1647 {
return __complex_asin(__z); }
1650 template<
typename _Tp>
1654 const _Tp __r2 = __z.real() * __z.real();
1655 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
1657 _Tp __num = __z.imag() + _Tp(1.0);
1658 _Tp __den = __z.imag() - _Tp(1.0);
1660 __num = __r2 + __num * __num;
1661 __den = __r2 + __den * __den;
1664 _Tp(0.25) *
log(__num / __den));
1667 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1668 inline __complex__
float
1669 __complex_atan(__complex__
float __z)
1670 {
return __builtin_catanf(__z); }
1672 inline __complex__
double
1673 __complex_atan(__complex__
double __z)
1674 {
return __builtin_catan(__z); }
1676 inline __complex__
long double
1677 __complex_atan(
const __complex__
long double& __z)
1678 {
return __builtin_catanl(__z); }
1680 template<
typename _Tp>
1683 {
return __complex_atan(__z.__rep()); }
1688 template<
typename _Tp>
1691 {
return __complex_atan(__z); }
1694 template<
typename _Tp>
1700 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
1703 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1704 inline __complex__
float
1705 __complex_acosh(__complex__
float __z)
1706 {
return __builtin_cacoshf(__z); }
1708 inline __complex__
double
1709 __complex_acosh(__complex__
double __z)
1710 {
return __builtin_cacosh(__z); }
1712 inline __complex__
long double
1713 __complex_acosh(
const __complex__
long double& __z)
1714 {
return __builtin_cacoshl(__z); }
1716 template<
typename _Tp>
1719 {
return __complex_acosh(__z.__rep()); }
1724 template<
typename _Tp>
1727 {
return __complex_acosh(__z); }
1730 template<
typename _Tp>
1735 * (__z.real() + __z.imag()) + _Tp(1.0),
1736 _Tp(2.0) * __z.real() * __z.imag());
1742 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1743 inline __complex__
float
1744 __complex_asinh(__complex__
float __z)
1745 {
return __builtin_casinhf(__z); }
1747 inline __complex__
double
1748 __complex_asinh(__complex__
double __z)
1749 {
return __builtin_casinh(__z); }
1751 inline __complex__
long double
1752 __complex_asinh(
const __complex__
long double& __z)
1753 {
return __builtin_casinhl(__z); }
1755 template<
typename _Tp>
1758 {
return __complex_asinh(__z.__rep()); }
1763 template<
typename _Tp>
1766 {
return __complex_asinh(__z); }
1769 template<
typename _Tp>
1773 const _Tp __i2 = __z.imag() * __z.imag();
1774 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
1776 _Tp __num = _Tp(1.0) + __z.real();
1777 _Tp __den = _Tp(1.0) - __z.real();
1779 __num = __i2 + __num * __num;
1780 __den = __i2 + __den * __den;
1783 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
1786 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1787 inline __complex__
float
1788 __complex_atanh(__complex__
float __z)
1789 {
return __builtin_catanhf(__z); }
1791 inline __complex__
double
1792 __complex_atanh(__complex__
double __z)
1793 {
return __builtin_catanh(__z); }
1795 inline __complex__
long double
1796 __complex_atanh(
const __complex__
long double& __z)
1797 {
return __builtin_catanhl(__z); }
1799 template<
typename _Tp>
1802 {
return __complex_atanh(__z.__rep()); }
1807 template<
typename _Tp>
1810 {
return __complex_atanh(__z); }
1813 template<
typename _Tp>
1822 template<
typename _Tp>
1823 inline typename __gnu_cxx::__promote<_Tp>::__type
1826 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1827 #if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
1828 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
1835 template<
typename _Tp>
1836 inline typename __gnu_cxx::__promote<_Tp>::__type
1840 template<
typename _Tp>
1841 inline typename __gnu_cxx::__promote<_Tp>::__type
1844 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1845 return __type(__x) * __type(__x);
1848 template<
typename _Tp>
1849 inline typename __gnu_cxx::__promote<_Tp>::__type
1853 template<
typename _Tp,
typename _Up>
1857 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1861 template<
typename _Tp,
typename _Up>
1865 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1869 template<
typename _Tp,
typename _Up>
1873 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1882 template<
typename _Tp>
1886 const _Tp __den = (__z.real() * __z.real()
1887 + __z.imag() * __z.imag() + _Tp(1.0));
1890 (_Tp(2.0) * __z.imag()) / __den);
1893 #if _GLIBCXX_USE_C99_COMPLEX
1894 inline __complex__
float
1895 __complex_proj(__complex__
float __z)
1896 {
return __builtin_cprojf(__z); }
1898 inline __complex__
double
1899 __complex_proj(__complex__
double __z)
1900 {
return __builtin_cproj(__z); }
1902 inline __complex__
long double
1903 __complex_proj(
const __complex__
long double& __z)
1904 {
return __builtin_cprojl(__z); }
1906 template<
typename _Tp>
1909 {
return __complex_proj(__z.__rep()); }
1911 template<
typename _Tp>
1914 {
return __complex_proj(__z); }
1918 template<
typename _Tp>
1919 inline typename __gnu_cxx::__promote<_Tp>::__type
1923 template<
typename _Tp>
1924 inline typename __gnu_cxx::__promote<_Tp>::__type
1928 _GLIBCXX_END_NAMESPACE_VERSION
1931 #endif // __GXX_EXPERIMENTAL_CXX0X__
complex< _Tp > & operator*=(const _Tp &)
Multiply this complex number by t.
complex< _Tp > & operator/=(const _Tp &)
Divide this complex number by t.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
basic_istream< _CharT, _Traits > & operator>>(basic_istream< _CharT, _Traits > &__is, complex< _Tp > &__x)
Extraction operator for complex values.
complex< _Tp > tan(const complex< _Tp > &)
Return complex tangent of z.
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
std::complex< _Tp > acosh(const std::complex< _Tp > &)
acosh(__z) [8.1.5].
_Tp norm(const complex< _Tp > &)
Return z magnitude squared.
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
complex< _Tp > sinh(const complex< _Tp > &)
Return complex hyperbolic sine of z.
const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
complex< _Tp > cosh(const complex< _Tp > &)
Return complex hyperbolic cosine of z.
streamsize precision() const
Flags access.
complex< _Tp > & operator-=(const _Tp &__t)
Subtract t from this complex number.
complex< _Tp > conj(const complex< _Tp > &)
Return complex conjugate of z.
complex< _Tp > pow(const complex< _Tp > &, const _Tp &)
Return x to the y'th power.
bitset< _Nb > operator>>(size_t __position) const
Self-explanatory.
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...
Controlling input.This is the base class for all input streams. It provides text formatting of all bu...
_Tp fabs(const std::complex< _Tp > &)
fabs(__z) [8.1.8].
std::complex< _Tp > asin(const std::complex< _Tp > &)
asin(__z) [8.1.3].
complex< _Tp > & operator=(const _Tp &)
Assign this complex number to scalar t.
complex< _Tp > tanh(const complex< _Tp > &)
Return complex hyperbolic tangent of z.
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
std::complex< _Tp > acos(const std::complex< _Tp > &)
acos(__z) [8.1.2].
complex< _Tp > polar(const _Tp &, const _Tp &=0)
Return complex with magnitude rho and angle theta.
complex< _Tp > & operator+=(const _Tp &__t)
Add t to this complex number.
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
std::complex< _Tp > atan(const std::complex< _Tp > &)
atan(__z) [8.1.4].
constexpr complex(const complex< _Up > &__z)
Copy constructor.
complex< _Tp > log10(const complex< _Tp > &)
Return complex base 10 logarithm of z.
complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
fmtflags flags() const
Access to format flags.
void setstate(iostate __state)
Sets additional flags in the error state.
std::complex< _Tp > asinh(const std::complex< _Tp > &)
asinh(__z) [8.1.6].
Controlling output for std::string.This class supports writing to objects of type std::basic_string...
complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
complex< _Tp > operator/(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x divided by y.
std::complex< _Tp > atanh(const std::complex< _Tp > &)
atanh(__z) [8.1.7].
locale imbue(const locale &__loc)
Moves to a new locale.
__istream_type & putback(char_type __c)
Unextracting a single character.
basic_istream< char > istream
Base class for char input streams.
_Tp arg(const complex< _Tp > &)
Return phase angle of z.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
__string_type str() const
Copying out the string buffer.
_Tp value_type
Value typedef.
basic_ostream< wchar_t > wostream
Base class for wchar_t output streams.
basic_ostream< char > ostream
Base class for char output streams.