36 #ifndef _GLIBCXX_COMPLEX
37 #define _GLIBCXX_COMPLEX 1
39 #pragma GCC system_header
50 #if __cplusplus > 201703L
51 # define __cpp_lib_constexpr_complex 201711L
54 namespace std _GLIBCXX_VISIBILITY(default)
56 _GLIBCXX_BEGIN_NAMESPACE_VERSION
68 template<>
class complex<float>;
69 template<>
class complex<double>;
70 template<>
class complex<long double>;
80 template<
typename _Tp>
126 template<
typename _Tp>
134 _GLIBCXX_CONSTEXPR
complex(
const _Tp& __r = _Tp(),
const _Tp& __i = _Tp())
135 : _M_real(__r), _M_imag(__i) { }
138 #if __cplusplus >= 201103L
143 template<
typename _Up>
145 : _M_real(__z.real()), _M_imag(__z.imag()) { }
147 #if __cplusplus >= 201103L
150 _GLIBCXX_ABI_TAG_CXX11
152 real()
const {
return _M_real; }
154 _GLIBCXX_ABI_TAG_CXX11
156 imag()
const {
return _M_imag; }
160 real() {
return _M_real; }
164 real()
const {
return _M_real; }
168 imag() {
return _M_imag; }
172 imag()
const {
return _M_imag; }
177 _GLIBCXX20_CONSTEXPR
void
178 real(_Tp __val) { _M_real = __val; }
180 _GLIBCXX20_CONSTEXPR
void
181 imag(_Tp __val) { _M_imag = __val; }
184 _GLIBCXX20_CONSTEXPR complex<_Tp>&
operator=(
const _Tp&);
188 _GLIBCXX20_CONSTEXPR complex<_Tp>&
210 #if __cplusplus >= 201103L
215 template<
typename _Up>
218 template<
typename _Up>
221 template<
typename _Up>
224 template<
typename _Up>
227 template<
typename _Up>
230 _GLIBCXX_CONSTEXPR
complex __rep()
const
238 template<
typename _Tp>
239 _GLIBCXX20_CONSTEXPR complex<_Tp>&
248 template<
typename _Tp>
258 template<
typename _Tp>
267 template<
typename _Tp>
268 template<
typename _Up>
272 _M_real = __z.real();
273 _M_imag = __z.imag();
278 template<
typename _Tp>
279 template<
typename _Up>
283 _M_real += __z.real();
284 _M_imag += __z.imag();
289 template<
typename _Tp>
290 template<
typename _Up>
294 _M_real -= __z.real();
295 _M_imag -= __z.imag();
301 template<
typename _Tp>
302 template<
typename _Up>
306 const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
307 _M_imag = _M_real * __z.imag() + _M_imag * __z.real();
314 template<
typename _Tp>
315 template<
typename _Up>
319 const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag();
321 _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n;
329 template<
typename _Tp>
338 template<
typename _Tp>
339 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
340 operator+(
const complex<_Tp>& __x,
const _Tp& __y)
342 complex<_Tp> __r = __x;
347 template<
typename _Tp>
348 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
349 operator+(
const _Tp& __x,
const complex<_Tp>& __y)
351 complex<_Tp> __r = __y;
359 template<
typename _Tp>
360 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
368 template<
typename _Tp>
369 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
370 operator-(
const complex<_Tp>& __x,
const _Tp& __y)
372 complex<_Tp> __r = __x;
377 template<
typename _Tp>
378 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
379 operator-(
const _Tp& __x,
const complex<_Tp>& __y)
381 complex<_Tp> __r = -__y;
389 template<
typename _Tp>
390 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
398 template<
typename _Tp>
399 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
400 operator*(
const complex<_Tp>& __x,
const _Tp& __y)
402 complex<_Tp> __r = __x;
407 template<
typename _Tp>
408 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
409 operator*(
const _Tp& __x,
const complex<_Tp>& __y)
411 complex<_Tp> __r = __y;
419 template<
typename _Tp>
420 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
428 template<
typename _Tp>
429 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
430 operator/(
const complex<_Tp>& __x,
const _Tp& __y)
432 complex<_Tp> __r = __x;
437 template<
typename _Tp>
438 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
439 operator/(
const _Tp& __x,
const complex<_Tp>& __y)
441 complex<_Tp> __r = __x;
448 template<
typename _Tp>
449 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
454 template<
typename _Tp>
455 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
461 template<
typename _Tp>
462 inline _GLIBCXX_CONSTEXPR
bool
464 {
return __x.real() == __y.real() && __x.imag() == __y.imag(); }
466 template<
typename _Tp>
467 inline _GLIBCXX_CONSTEXPR
bool
468 operator==(
const complex<_Tp>& __x,
const _Tp& __y)
469 {
return __x.real() == __y && __x.imag() == _Tp(); }
471 template<
typename _Tp>
472 inline _GLIBCXX_CONSTEXPR
bool
473 operator==(
const _Tp& __x,
const complex<_Tp>& __y)
474 {
return __x == __y.real() && _Tp() == __y.imag(); }
479 template<
typename _Tp>
480 inline _GLIBCXX_CONSTEXPR
bool
482 {
return __x.real() != __y.real() || __x.imag() != __y.imag(); }
484 template<
typename _Tp>
485 inline _GLIBCXX_CONSTEXPR
bool
486 operator!=(
const complex<_Tp>& __x,
const _Tp& __y)
487 {
return __x.real() != __y || __x.imag() != _Tp(); }
489 template<
typename _Tp>
490 inline _GLIBCXX_CONSTEXPR
bool
491 operator!=(
const _Tp& __x,
const complex<_Tp>& __y)
492 {
return __x != __y.real() || _Tp() != __y.imag(); }
496 template<
typename _Tp,
typename _CharT,
class _Traits>
497 basic_istream<_CharT, _Traits>&
504 if (_Traits::eq(__ch, __is.widen(
'(')))
507 if (__is >> __u >> __ch)
509 const _CharT __rparen = __is.widen(
')');
510 if (_Traits::eq(__ch, __rparen))
515 else if (_Traits::eq(__ch, __is.widen(
',')))
518 if (__is >> __v >> __ch)
520 if (_Traits::eq(__ch, __rparen))
550 template<
typename _Tp,
typename _CharT,
class _Traits>
551 basic_ostream<_CharT, _Traits>&
555 __s.flags(__os.flags());
556 __s.imbue(__os.getloc());
557 __s.precision(__os.precision());
558 __s <<
'(' << __x.real() <<
',' << __x.imag() <<
')';
559 return __os << __s.
str();
563 #if __cplusplus >= 201103L
564 template<
typename _Tp>
566 real(
const complex<_Tp>& __z)
567 {
return __z.real(); }
569 template<
typename _Tp>
571 imag(
const complex<_Tp>& __z)
572 {
return __z.imag(); }
574 template<
typename _Tp>
576 real(complex<_Tp>& __z)
577 {
return __z.real(); }
579 template<
typename _Tp>
581 real(
const complex<_Tp>& __z)
582 {
return __z.real(); }
584 template<
typename _Tp>
586 imag(complex<_Tp>& __z)
587 {
return __z.imag(); }
589 template<
typename _Tp>
591 imag(
const complex<_Tp>& __z)
592 {
return __z.imag(); }
596 template<
typename _Tp>
598 __complex_abs(
const complex<_Tp>& __z)
600 _Tp __x = __z.real();
601 _Tp __y = __z.imag();
607 return __s *
sqrt(__x * __x + __y * __y);
610 #if _GLIBCXX_USE_C99_COMPLEX
612 __complex_abs(__complex__
float __z) {
return __builtin_cabsf(__z); }
615 __complex_abs(__complex__
double __z) {
return __builtin_cabs(__z); }
618 __complex_abs(
const __complex__
long double& __z)
619 {
return __builtin_cabsl(__z); }
621 template<
typename _Tp>
623 abs(
const complex<_Tp>& __z) {
return __complex_abs(__z.__rep()); }
625 template<
typename _Tp>
632 template<
typename _Tp>
634 __complex_arg(
const complex<_Tp>& __z)
635 {
return atan2(__z.imag(), __z.real()); }
637 #if _GLIBCXX_USE_C99_COMPLEX
639 __complex_arg(__complex__
float __z) {
return __builtin_cargf(__z); }
642 __complex_arg(__complex__
double __z) {
return __builtin_carg(__z); }
645 __complex_arg(
const __complex__
long double& __z)
646 {
return __builtin_cargl(__z); }
648 template<
typename _Tp>
650 arg(
const complex<_Tp>& __z) {
return __complex_arg(__z.__rep()); }
652 template<
typename _Tp>
665 template<
typename _Tp>
666 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
668 const _Tp __x = __z.real();
669 const _Tp __y = __z.imag();
670 return __x * __x + __y * __y;
675 struct _Norm_helper<true>
677 template<
typename _Tp>
678 static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(
const complex<_Tp>& __z)
682 const _Tp __x = __z.real();
683 const _Tp __y = __z.imag();
684 return __x * __x + __y * __y;
688 template<
typename _Tp>
689 inline _GLIBCXX20_CONSTEXPR _Tp
692 return _Norm_helper<__is_floating<_Tp>::__value
693 && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
696 template<
typename _Tp>
698 polar(
const _Tp& __rho,
const _Tp& __theta)
700 __glibcxx_assert( __rho >= 0 );
704 template<
typename _Tp>
705 inline _GLIBCXX20_CONSTEXPR complex<_Tp>
712 template<
typename _Tp>
714 __complex_cos(
const complex<_Tp>& __z)
716 const _Tp __x = __z.real();
717 const _Tp __y = __z.imag();
721 #if _GLIBCXX_USE_C99_COMPLEX
722 inline __complex__
float
723 __complex_cos(__complex__
float __z) {
return __builtin_ccosf(__z); }
725 inline __complex__
double
726 __complex_cos(__complex__
double __z) {
return __builtin_ccos(__z); }
728 inline __complex__
long double
729 __complex_cos(
const __complex__
long double& __z)
730 {
return __builtin_ccosl(__z); }
732 template<
typename _Tp>
734 cos(
const complex<_Tp>& __z) {
return __complex_cos(__z.__rep()); }
736 template<
typename _Tp>
742 template<
typename _Tp>
744 __complex_cosh(
const complex<_Tp>& __z)
746 const _Tp __x = __z.real();
747 const _Tp __y = __z.imag();
751 #if _GLIBCXX_USE_C99_COMPLEX
752 inline __complex__
float
753 __complex_cosh(__complex__
float __z) {
return __builtin_ccoshf(__z); }
755 inline __complex__
double
756 __complex_cosh(__complex__
double __z) {
return __builtin_ccosh(__z); }
758 inline __complex__
long double
759 __complex_cosh(
const __complex__
long double& __z)
760 {
return __builtin_ccoshl(__z); }
762 template<
typename _Tp>
764 cosh(
const complex<_Tp>& __z) {
return __complex_cosh(__z.__rep()); }
766 template<
typename _Tp>
772 template<
typename _Tp>
774 __complex_exp(
const complex<_Tp>& __z)
775 {
return std::polar<_Tp>(
exp(__z.real()), __z.imag()); }
777 #if _GLIBCXX_USE_C99_COMPLEX
778 inline __complex__
float
779 __complex_exp(__complex__
float __z) {
return __builtin_cexpf(__z); }
781 inline __complex__
double
782 __complex_exp(__complex__
double __z) {
return __builtin_cexp(__z); }
784 inline __complex__
long double
785 __complex_exp(
const __complex__
long double& __z)
786 {
return __builtin_cexpl(__z); }
788 template<
typename _Tp>
790 exp(
const complex<_Tp>& __z) {
return __complex_exp(__z.__rep()); }
792 template<
typename _Tp>
799 template<
typename _Tp>
801 __complex_log(
const complex<_Tp>& __z)
804 #if _GLIBCXX_USE_C99_COMPLEX
805 inline __complex__
float
806 __complex_log(__complex__
float __z) {
return __builtin_clogf(__z); }
808 inline __complex__
double
809 __complex_log(__complex__
double __z) {
return __builtin_clog(__z); }
811 inline __complex__
long double
812 __complex_log(
const __complex__
long double& __z)
813 {
return __builtin_clogl(__z); }
815 template<
typename _Tp>
817 log(
const complex<_Tp>& __z) {
return __complex_log(__z.__rep()); }
819 template<
typename _Tp>
824 template<
typename _Tp>
830 template<
typename _Tp>
832 __complex_sin(
const complex<_Tp>& __z)
834 const _Tp __x = __z.real();
835 const _Tp __y = __z.imag();
839 #if _GLIBCXX_USE_C99_COMPLEX
840 inline __complex__
float
841 __complex_sin(__complex__
float __z) {
return __builtin_csinf(__z); }
843 inline __complex__
double
844 __complex_sin(__complex__
double __z) {
return __builtin_csin(__z); }
846 inline __complex__
long double
847 __complex_sin(
const __complex__
long double& __z)
848 {
return __builtin_csinl(__z); }
850 template<
typename _Tp>
852 sin(
const complex<_Tp>& __z) {
return __complex_sin(__z.__rep()); }
854 template<
typename _Tp>
860 template<
typename _Tp>
862 __complex_sinh(
const complex<_Tp>& __z)
864 const _Tp __x = __z.real();
865 const _Tp __y = __z.imag();
869 #if _GLIBCXX_USE_C99_COMPLEX
870 inline __complex__
float
871 __complex_sinh(__complex__
float __z) {
return __builtin_csinhf(__z); }
873 inline __complex__
double
874 __complex_sinh(__complex__
double __z) {
return __builtin_csinh(__z); }
876 inline __complex__
long double
877 __complex_sinh(
const __complex__
long double& __z)
878 {
return __builtin_csinhl(__z); }
880 template<
typename _Tp>
882 sinh(
const complex<_Tp>& __z) {
return __complex_sinh(__z.__rep()); }
884 template<
typename _Tp>
891 template<
typename _Tp>
893 __complex_sqrt(
const complex<_Tp>& __z)
895 _Tp __x = __z.real();
896 _Tp __y = __z.imag();
901 return complex<_Tp>(__t, __y < _Tp() ? -__t : __t);
908 ? complex<_Tp>(__u, __y / __t)
909 : complex<_Tp>(
abs(__y) / __t, __y < _Tp() ? -__u : __u);
913 #if _GLIBCXX_USE_C99_COMPLEX
914 inline __complex__
float
915 __complex_sqrt(__complex__
float __z) {
return __builtin_csqrtf(__z); }
917 inline __complex__
double
918 __complex_sqrt(__complex__
double __z) {
return __builtin_csqrt(__z); }
920 inline __complex__
long double
921 __complex_sqrt(
const __complex__
long double& __z)
922 {
return __builtin_csqrtl(__z); }
924 template<
typename _Tp>
926 sqrt(
const complex<_Tp>& __z) {
return __complex_sqrt(__z.__rep()); }
928 template<
typename _Tp>
935 template<
typename _Tp>
937 __complex_tan(
const complex<_Tp>& __z)
940 #if _GLIBCXX_USE_C99_COMPLEX
941 inline __complex__
float
942 __complex_tan(__complex__
float __z) {
return __builtin_ctanf(__z); }
944 inline __complex__
double
945 __complex_tan(__complex__
double __z) {
return __builtin_ctan(__z); }
947 inline __complex__
long double
948 __complex_tan(
const __complex__
long double& __z)
949 {
return __builtin_ctanl(__z); }
951 template<
typename _Tp>
953 tan(
const complex<_Tp>& __z) {
return __complex_tan(__z.__rep()); }
955 template<
typename _Tp>
963 template<
typename _Tp>
965 __complex_tanh(
const complex<_Tp>& __z)
968 #if _GLIBCXX_USE_C99_COMPLEX
969 inline __complex__
float
970 __complex_tanh(__complex__
float __z) {
return __builtin_ctanhf(__z); }
972 inline __complex__
double
973 __complex_tanh(__complex__
double __z) {
return __builtin_ctanh(__z); }
975 inline __complex__
long double
976 __complex_tanh(
const __complex__
long double& __z)
977 {
return __builtin_ctanhl(__z); }
979 template<
typename _Tp>
981 tanh(
const complex<_Tp>& __z) {
return __complex_tanh(__z.__rep()); }
983 template<
typename _Tp>
992 template<
typename _Tp>
994 __complex_pow_unsigned(complex<_Tp> __x,
unsigned __n)
996 complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1);
1014 template<
typename _Tp>
1019 ?
complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(
unsigned)__n)
1020 : std::__complex_pow_unsigned(__z, __n);
1023 template<
typename _Tp>
1027 #if ! _GLIBCXX_USE_C99_COMPLEX
1031 if (__x.imag() == _Tp() && __x.real() > _Tp())
1032 return pow(__x.real(), __y);
1035 return std::polar<_Tp>(
exp(__y * __t.real()), __y * __t.imag());
1038 template<
typename _Tp>
1040 __complex_pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1041 {
return __x == _Tp() ? _Tp() :
std::
exp(__y *
std::
log(__x)); }
1043 #if _GLIBCXX_USE_C99_COMPLEX
1044 inline __complex__
float
1045 __complex_pow(__complex__
float __x, __complex__
float __y)
1046 {
return __builtin_cpowf(__x, __y); }
1048 inline __complex__
double
1049 __complex_pow(__complex__
double __x, __complex__
double __y)
1050 {
return __builtin_cpow(__x, __y); }
1052 inline __complex__
long double
1053 __complex_pow(
const __complex__
long double& __x,
1054 const __complex__
long double& __y)
1055 {
return __builtin_cpowl(__x, __y); }
1057 template<
typename _Tp>
1059 pow(
const complex<_Tp>& __x,
const complex<_Tp>& __y)
1060 {
return __complex_pow(__x.__rep(), __y.__rep()); }
1062 template<
typename _Tp>
1065 {
return __complex_pow(__x, __y); }
1068 template<
typename _Tp>
1072 return __x > _Tp() ? std::polar<_Tp>(
pow(__x, __y.real()),
1073 __y.imag() *
log(__x))
1083 typedef __complex__
float _ComplexT;
1085 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1087 _GLIBCXX_CONSTEXPR
complex(
float __r = 0.0f,
float __i = 0.0f)
1088 #if __cplusplus >= 201103L
1089 : _M_value{ __r, __i } { }
1092 __real__ _M_value = __r;
1093 __imag__ _M_value = __i;
1100 #if __cplusplus >= 201103L
1103 __attribute ((__abi_tag__ (
"cxx11")))
1105 real()
const {
return __real__ _M_value; }
1107 __attribute ((__abi_tag__ (
"cxx11")))
1109 imag()
const {
return __imag__ _M_value; }
1112 real() {
return __real__ _M_value; }
1115 real()
const {
return __real__ _M_value; }
1118 imag() {
return __imag__ _M_value; }
1121 imag()
const {
return __imag__ _M_value; }
1126 _GLIBCXX20_CONSTEXPR
void
1127 real(
float __val) { __real__ _M_value = __val; }
1129 _GLIBCXX20_CONSTEXPR
void
1130 imag(
float __val) { __imag__ _M_value = __val; }
1169 #if __cplusplus >= 201103L
1173 template<
typename _Tp>
1177 __real__ _M_value = __z.real();
1178 __imag__ _M_value = __z.imag();
1182 template<
typename _Tp>
1186 _M_value += __z.__rep();
1194 _M_value -= __z.__rep();
1202 const _ComplexT __t = __z.__rep();
1211 const _ComplexT __t = __z.__rep();
1216 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1228 typedef __complex__
double _ComplexT;
1230 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1232 _GLIBCXX_CONSTEXPR
complex(
double __r = 0.0,
double __i = 0.0)
1233 #if __cplusplus >= 201103L
1234 : _M_value{ __r, __i } { }
1237 __real__ _M_value = __r;
1238 __imag__ _M_value = __i;
1243 : _M_value(__z.__rep()) { }
1247 #if __cplusplus >= 201103L
1250 __attribute ((__abi_tag__ (
"cxx11")))
1252 real()
const {
return __real__ _M_value; }
1254 __attribute ((__abi_tag__ (
"cxx11")))
1256 imag()
const {
return __imag__ _M_value; }
1259 real() {
return __real__ _M_value; }
1262 real()
const {
return __real__ _M_value; }
1265 imag() {
return __imag__ _M_value; }
1268 imag()
const {
return __imag__ _M_value; }
1273 _GLIBCXX20_CONSTEXPR
void
1274 real(
double __val) { __real__ _M_value = __val; }
1276 _GLIBCXX20_CONSTEXPR
void
1277 imag(
double __val) { __imag__ _M_value = __val; }
1315 #if __cplusplus >= 201103L
1319 template<
typename _Tp>
1323 _M_value = __z.__rep();
1327 template<
typename _Tp>
1331 _M_value += __z.__rep();
1335 template<
typename _Tp>
1339 _M_value -= __z.__rep();
1343 template<
typename _Tp>
1347 const _ComplexT __t = __z.__rep();
1352 template<
typename _Tp>
1356 const _ComplexT __t = __z.__rep();
1361 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1373 typedef __complex__
long double _ComplexT;
1375 _GLIBCXX_CONSTEXPR
complex(_ComplexT __z) : _M_value(__z) { }
1377 _GLIBCXX_CONSTEXPR
complex(
long double __r = 0.0L,
1378 long double __i = 0.0L)
1379 #if __cplusplus >= 201103L
1380 : _M_value{ __r, __i } { }
1383 __real__ _M_value = __r;
1384 __imag__ _M_value = __i;
1389 : _M_value(__z.__rep()) { }
1392 : _M_value(__z.__rep()) { }
1394 #if __cplusplus >= 201103L
1397 __attribute ((__abi_tag__ (
"cxx11")))
1398 constexpr
long double
1399 real()
const {
return __real__ _M_value; }
1401 __attribute ((__abi_tag__ (
"cxx11")))
1402 constexpr
long double
1403 imag()
const {
return __imag__ _M_value; }
1406 real() {
return __real__ _M_value; }
1409 real()
const {
return __real__ _M_value; }
1412 imag() {
return __imag__ _M_value; }
1415 imag()
const {
return __imag__ _M_value; }
1420 _GLIBCXX20_CONSTEXPR
void
1421 real(
long double __val) { __real__ _M_value = __val; }
1423 _GLIBCXX20_CONSTEXPR
void
1424 imag(
long double __val) { __imag__ _M_value = __val; }
1462 #if __cplusplus >= 201103L
1466 template<
typename _Tp>
1470 _M_value = __z.__rep();
1474 template<
typename _Tp>
1478 _M_value += __z.__rep();
1482 template<
typename _Tp>
1486 _M_value -= __z.__rep();
1490 template<
typename _Tp>
1494 const _ComplexT __t = __z.__rep();
1499 template<
typename _Tp>
1503 const _ComplexT __t = __z.__rep();
1508 _GLIBCXX_CONSTEXPR _ComplexT __rep()
const {
return _M_value; }
1516 inline _GLIBCXX_CONSTEXPR
1518 : _M_value(__z.__rep()) { }
1520 inline _GLIBCXX_CONSTEXPR
1522 : _M_value(__z.__rep()) { }
1524 inline _GLIBCXX_CONSTEXPR
1526 : _M_value(__z.__rep()) { }
1531 #if _GLIBCXX_EXTERN_TEMPLATE
1533 extern template ostream& operator<<(
ostream&,
const complex<float>&);
1535 extern template ostream& operator<<(
ostream&,
const complex<double>&);
1537 extern template ostream& operator<<(
ostream&,
const complex<long double>&);
1539 #ifdef _GLIBCXX_USE_WCHAR_T
1545 extern template wostream& operator<<(
wostream&,
const complex<long double>&);
1551 _GLIBCXX_END_NAMESPACE_VERSION
1554 namespace __gnu_cxx _GLIBCXX_VISIBILITY(
default)
1556 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1559 template<
typename _Tp,
typename _Up>
1560 struct __promote_2<std::complex<_Tp>, _Up>
1566 template<
typename _Tp,
typename _Up>
1567 struct __promote_2<_Tp,
std::complex<_Up> >
1573 template<
typename _Tp,
typename _Up>
1580 _GLIBCXX_END_NAMESPACE_VERSION
1583 #if __cplusplus >= 201103L
1585 namespace std _GLIBCXX_VISIBILITY(default)
1587 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1600 template<
typename _Tp>
1605 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
1609 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1610 inline __complex__
float
1611 __complex_acos(__complex__
float __z)
1612 {
return __builtin_cacosf(__z); }
1614 inline __complex__
double
1615 __complex_acos(__complex__
double __z)
1616 {
return __builtin_cacos(__z); }
1618 inline __complex__
long double
1619 __complex_acos(
const __complex__
long double& __z)
1620 {
return __builtin_cacosl(__z); }
1622 template<
typename _Tp>
1625 {
return __complex_acos(__z.__rep()); }
1630 template<
typename _Tp>
1633 {
return __complex_acos(__z); }
1636 template<
typename _Tp>
1645 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1646 inline __complex__
float
1647 __complex_asin(__complex__
float __z)
1648 {
return __builtin_casinf(__z); }
1650 inline __complex__
double
1651 __complex_asin(__complex__
double __z)
1652 {
return __builtin_casin(__z); }
1654 inline __complex__
long double
1655 __complex_asin(
const __complex__
long double& __z)
1656 {
return __builtin_casinl(__z); }
1658 template<
typename _Tp>
1661 {
return __complex_asin(__z.__rep()); }
1666 template<
typename _Tp>
1669 {
return __complex_asin(__z); }
1672 template<
typename _Tp>
1676 const _Tp __r2 = __z.real() * __z.real();
1677 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
1679 _Tp __num = __z.imag() + _Tp(1.0);
1680 _Tp __den = __z.imag() - _Tp(1.0);
1682 __num = __r2 + __num * __num;
1683 __den = __r2 + __den * __den;
1686 _Tp(0.25) *
log(__num / __den));
1689 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1690 inline __complex__
float
1691 __complex_atan(__complex__
float __z)
1692 {
return __builtin_catanf(__z); }
1694 inline __complex__
double
1695 __complex_atan(__complex__
double __z)
1696 {
return __builtin_catan(__z); }
1698 inline __complex__
long double
1699 __complex_atan(
const __complex__
long double& __z)
1700 {
return __builtin_catanl(__z); }
1702 template<
typename _Tp>
1705 {
return __complex_atan(__z.__rep()); }
1710 template<
typename _Tp>
1713 {
return __complex_atan(__z); }
1716 template<
typename _Tp>
1722 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
1725 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1726 inline __complex__
float
1727 __complex_acosh(__complex__
float __z)
1728 {
return __builtin_cacoshf(__z); }
1730 inline __complex__
double
1731 __complex_acosh(__complex__
double __z)
1732 {
return __builtin_cacosh(__z); }
1734 inline __complex__
long double
1735 __complex_acosh(
const __complex__
long double& __z)
1736 {
return __builtin_cacoshl(__z); }
1738 template<
typename _Tp>
1741 {
return __complex_acosh(__z.__rep()); }
1746 template<
typename _Tp>
1749 {
return __complex_acosh(__z); }
1752 template<
typename _Tp>
1757 * (__z.real() + __z.imag()) + _Tp(1.0),
1758 _Tp(2.0) * __z.real() * __z.imag());
1764 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1765 inline __complex__
float
1766 __complex_asinh(__complex__
float __z)
1767 {
return __builtin_casinhf(__z); }
1769 inline __complex__
double
1770 __complex_asinh(__complex__
double __z)
1771 {
return __builtin_casinh(__z); }
1773 inline __complex__
long double
1774 __complex_asinh(
const __complex__
long double& __z)
1775 {
return __builtin_casinhl(__z); }
1777 template<
typename _Tp>
1780 {
return __complex_asinh(__z.__rep()); }
1785 template<
typename _Tp>
1788 {
return __complex_asinh(__z); }
1791 template<
typename _Tp>
1795 const _Tp __i2 = __z.imag() * __z.imag();
1796 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
1798 _Tp __num = _Tp(1.0) + __z.real();
1799 _Tp __den = _Tp(1.0) - __z.real();
1801 __num = __i2 + __num * __num;
1802 __den = __i2 + __den * __den;
1805 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
1808 #if _GLIBCXX_USE_C99_COMPLEX_TR1
1809 inline __complex__
float
1810 __complex_atanh(__complex__
float __z)
1811 {
return __builtin_catanhf(__z); }
1813 inline __complex__
double
1814 __complex_atanh(__complex__
double __z)
1815 {
return __builtin_catanh(__z); }
1817 inline __complex__
long double
1818 __complex_atanh(
const __complex__
long double& __z)
1819 {
return __builtin_catanhl(__z); }
1821 template<
typename _Tp>
1824 {
return __complex_atanh(__z.__rep()); }
1829 template<
typename _Tp>
1832 {
return __complex_atanh(__z); }
1835 template<
typename _Tp>
1844 template<
typename _Tp>
1845 inline typename __gnu_cxx::__promote<_Tp>::__type
1848 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1849 #if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
1850 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
1857 template<
typename _Tp>
1858 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1862 template<
typename _Tp>
1863 _GLIBCXX20_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1866 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1867 return __type(__x) * __type(__x);
1870 template<
typename _Tp>
1871 _GLIBCXX_CONSTEXPR
inline typename __gnu_cxx::__promote<_Tp>::__type
1875 template<
typename _Tp,
typename _Up>
1879 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1883 template<
typename _Tp,
typename _Up>
1887 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1891 template<
typename _Tp,
typename _Up>
1895 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1902 template<
typename _Tp>
1906 template<
typename _Tp>
1911 #if _GLIBCXX_USE_C99_COMPLEX
1912 inline complex<float>
1913 __complex_proj(
const complex<float>& __z)
1914 {
return __builtin_cprojf(__z.__rep()); }
1916 inline complex<double>
1917 __complex_proj(
const complex<double>& __z)
1918 {
return __builtin_cproj(__z.__rep()); }
1920 inline complex<long double>
1921 __complex_proj(
const complex<long double>& __z)
1922 {
return __builtin_cprojl(__z.__rep()); }
1923 #elif defined _GLIBCXX_USE_C99_MATH_TR1
1924 inline complex<float>
1925 __complex_proj(
const complex<float>& __z)
1927 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
1928 return complex<float>(__builtin_inff(),
1929 __builtin_copysignf(0.0f, __z.imag()));
1933 inline complex<double>
1934 __complex_proj(
const complex<double>& __z)
1936 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
1937 return complex<double>(__builtin_inf(),
1938 __builtin_copysign(0.0, __z.imag()));
1942 inline complex<long double>
1943 __complex_proj(
const complex<long double>& __z)
1945 if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag()))
1946 return complex<long double>(__builtin_infl(),
1947 __builtin_copysignl(0.0l, __z.imag()));
1952 template<
typename _Tp>
1955 {
return __complex_proj(__z); }
1958 template<
typename _Tp>
1962 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1966 template<
typename _Tp>
1967 inline _GLIBCXX20_CONSTEXPR
1971 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1975 #if __cplusplus > 201103L
1977 inline namespace literals {
1978 inline namespace complex_literals {
1979 #pragma GCC diagnostic push
1980 #pragma GCC diagnostic ignored "-Wliteral-suffix"
1981 #define __cpp_lib_complex_udls 201309
1984 operator""if(
long double __num)
1988 operator""if(
unsigned long long __num)
1992 operator""i(
long double __num)
1996 operator""i(
unsigned long long __num)
2000 operator""il(
long double __num)
2004 operator""il(
unsigned long long __num)
2007 #pragma GCC diagnostic pop
2013 _GLIBCXX_END_NAMESPACE_VERSION