Cider Isn't Darwin Emulation, Really
Something went wrong. Try again.
46 kB · 1484 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485// -*- C++ -*-//===--------------------------- complex ----------------------------------===////// The LLVM Compiler Infrastructure//// This file is dual licensed under the MIT and the University of Illinois Open// Source Licenses. See LICENSE.TXT for details.////===----------------------------------------------------------------------===//#ifndef _LIBCPP_COMPLEX#define _LIBCPP_COMPLEX/* complex synopsisnamespace std{template<class T>class complex{public: typedef T value_type; complex(const T& re = T(), const T& im = T()); // constexpr in C++14 complex(const complex&); // constexpr in C++14 template<class X> complex(const complex<X>&); // constexpr in C++14 T real() const; // constexpr in C++14 T imag() const; // constexpr in C++14 void real(T); void imag(T); complex<T>& operator= (const T&); complex<T>& operator+=(const T&); complex<T>& operator-=(const T&); complex<T>& operator*=(const T&); complex<T>& operator/=(const T&); complex& operator=(const complex&); template<class X> complex<T>& operator= (const complex<X>&); template<class X> complex<T>& operator+=(const complex<X>&); template<class X> complex<T>& operator-=(const complex<X>&); template<class X> complex<T>& operator*=(const complex<X>&); template<class X> complex<T>& operator/=(const complex<X>&);};template<>class complex<float>{public: typedef float value_type; constexpr complex(float re = 0.0f, float im = 0.0f); explicit constexpr complex(const complex<double>&); explicit constexpr complex(const complex<long double>&); constexpr float real() const; void real(float); constexpr float imag() const; void imag(float); complex<float>& operator= (float); complex<float>& operator+=(float); complex<float>& operator-=(float); complex<float>& operator*=(float); complex<float>& operator/=(float); complex<float>& operator=(const complex<float>&); template<class X> complex<float>& operator= (const complex<X>&); template<class X> complex<float>& operator+=(const complex<X>&); template<class X> complex<float>& operator-=(const complex<X>&); template<class X> complex<float>& operator*=(const complex<X>&); template<class X> complex<float>& operator/=(const complex<X>&);};template<>class complex<double>{public: typedef double value_type; constexpr complex(double re = 0.0, double im = 0.0); constexpr complex(const complex<float>&); explicit constexpr complex(const complex<long double>&); constexpr double real() const; void real(double); constexpr double imag() const; void imag(double); complex<double>& operator= (double); complex<double>& operator+=(double); complex<double>& operator-=(double); complex<double>& operator*=(double); complex<double>& operator/=(double); complex<double>& operator=(const complex<double>&); template<class X> complex<double>& operator= (const complex<X>&); template<class X> complex<double>& operator+=(const complex<X>&); template<class X> complex<double>& operator-=(const complex<X>&); template<class X> complex<double>& operator*=(const complex<X>&); template<class X> complex<double>& operator/=(const complex<X>&);};template<>class complex<long double>{public: typedef long double value_type; constexpr complex(long double re = 0.0L, long double im = 0.0L); constexpr complex(const complex<float>&); constexpr complex(const complex<double>&); constexpr long double real() const; void real(long double); constexpr long double imag() const; void imag(long double); complex<long double>& operator=(const complex<long double>&); complex<long double>& operator= (long double); complex<long double>& operator+=(long double); complex<long double>& operator-=(long double); complex<long double>& operator*=(long double); complex<long double>& operator/=(long double); template<class X> complex<long double>& operator= (const complex<X>&); template<class X> complex<long double>& operator+=(const complex<X>&); template<class X> complex<long double>& operator-=(const complex<X>&); template<class X> complex<long double>& operator*=(const complex<X>&); template<class X> complex<long double>& operator/=(const complex<X>&);};// 26.3.6 operators:template<class T> complex<T> operator+(const complex<T>&, const complex<T>&);template<class T> complex<T> operator+(const complex<T>&, const T&);template<class T> complex<T> operator+(const T&, const complex<T>&);template<class T> complex<T> operator-(const complex<T>&, const complex<T>&);template<class T> complex<T> operator-(const complex<T>&, const T&);template<class T> complex<T> operator-(const T&, const complex<T>&);template<class T> complex<T> operator*(const complex<T>&, const complex<T>&);template<class T> complex<T> operator*(const complex<T>&, const T&);template<class T> complex<T> operator*(const T&, const complex<T>&);template<class T> complex<T> operator/(const complex<T>&, const complex<T>&);template<class T> complex<T> operator/(const complex<T>&, const T&);template<class T> complex<T> operator/(const T&, const complex<T>&);template<class T> complex<T> operator+(const complex<T>&);template<class T> complex<T> operator-(const complex<T>&);template<class T> bool operator==(const complex<T>&, const complex<T>&); // constexpr in C++14template<class T> bool operator==(const complex<T>&, const T&); // constexpr in C++14template<class T> bool operator==(const T&, const complex<T>&); // constexpr in C++14template<class T> bool operator!=(const complex<T>&, const complex<T>&); // constexpr in C++14template<class T> bool operator!=(const complex<T>&, const T&); // constexpr in C++14template<class T> bool operator!=(const T&, const complex<T>&); // constexpr in C++14template<class T, class charT, class traits> basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, complex<T>&);template<class T, class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const complex<T>&);// 26.3.7 values:template<class T> T real(const complex<T>&); // constexpr in C++14 long double real(long double); // constexpr in C++14 double real(double); // constexpr in C++14template<Integral T> double real(T); // constexpr in C++14 float real(float); // constexpr in C++14template<class T> T imag(const complex<T>&); // constexpr in C++14 long double imag(long double); // constexpr in C++14 double imag(double); // constexpr in C++14template<Integral T> double imag(T); // constexpr in C++14 float imag(float); // constexpr in C++14template<class T> T abs(const complex<T>&);template<class T> T arg(const complex<T>&); long double arg(long double); double arg(double);template<Integral T> double arg(T); float arg(float);template<class T> T norm(const complex<T>&); long double norm(long double); double norm(double);template<Integral T> double norm(T); float norm(float);template<class T> complex<T> conj(const complex<T>&); complex<long double> conj(long double); complex<double> conj(double);template<Integral T> complex<double> conj(T); complex<float> conj(float);template<class T> complex<T> proj(const complex<T>&); complex<long double> proj(long double); complex<double> proj(double);template<Integral T> complex<double> proj(T); complex<float> proj(float);template<class T> complex<T> polar(const T&, const T& = 0);// 26.3.8 transcendentals:template<class T> complex<T> acos(const complex<T>&);template<class T> complex<T> asin(const complex<T>&);template<class T> complex<T> atan(const complex<T>&);template<class T> complex<T> acosh(const complex<T>&);template<class T> complex<T> asinh(const complex<T>&);template<class T> complex<T> atanh(const complex<T>&);template<class T> complex<T> cos (const complex<T>&);template<class T> complex<T> cosh (const complex<T>&);template<class T> complex<T> exp (const complex<T>&);template<class T> complex<T> log (const complex<T>&);template<class T> complex<T> log10(const complex<T>&);template<class T> complex<T> pow(const complex<T>&, const T&);template<class T> complex<T> pow(const complex<T>&, const complex<T>&);template<class T> complex<T> pow(const T&, const complex<T>&);template<class T> complex<T> sin (const complex<T>&);template<class T> complex<T> sinh (const complex<T>&);template<class T> complex<T> sqrt (const complex<T>&);template<class T> complex<T> tan (const complex<T>&);template<class T> complex<T> tanh (const complex<T>&);template<class T, class charT, class traits> basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& is, complex<T>& x);template<class T, class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);} // std*/#include <__config>#include <type_traits>#include <stdexcept>#include <cmath>#include <sstream>#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)#pragma GCC system_header#endif_LIBCPP_BEGIN_NAMESPACE_STDtemplate<class _Tp> class _LIBCPP_TEMPLATE_VIS complex;template<class _Tp> complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);template<class _Tp> complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);template<class _Tp>class _LIBCPP_TEMPLATE_VIS complex{public: typedef _Tp value_type;private: value_type __re_; value_type __im_;public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 complex(const value_type& __re = value_type(), const value_type& __im = value_type()) : __re_(__re), __im_(__im) {} template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 complex(const complex<_Xp>& __c) : __re_(__c.real()), __im_(__c.imag()) {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type real() const {return __re_;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type imag() const {return __im_;} _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;} _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;} _LIBCPP_INLINE_VISIBILITY complex& operator= (const value_type& __re) {__re_ = __re; __im_ = value_type(); return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator+=(const value_type& __re) {__re_ += __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator-=(const value_type& __re) {__re_ -= __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator/=(const value_type& __re) {__re_ /= __re; __im_ /= __re; return *this;} template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c) { __re_ = __c.real(); __im_ = __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c) { __re_ += __c.real(); __im_ += __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c) { __re_ -= __c.real(); __im_ -= __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { *this = *this * complex(__c.real(), __c.imag()); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { *this = *this / complex(__c.real(), __c.imag()); return *this; }};template<> class _LIBCPP_TEMPLATE_VIS complex<double>;template<> class _LIBCPP_TEMPLATE_VIS complex<long double>;template<>class _LIBCPP_TEMPLATE_VIS complex<float>{ float __re_; float __im_;public: typedef float value_type; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f) : __re_(__re), __im_(__im) {} _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c); _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c); _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float real() const {return __re_;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float imag() const {return __im_;} _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;} _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;} _LIBCPP_INLINE_VISIBILITY complex& operator= (float __re) {__re_ = __re; __im_ = value_type(); return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator+=(float __re) {__re_ += __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator-=(float __re) {__re_ -= __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator*=(float __re) {__re_ *= __re; __im_ *= __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator/=(float __re) {__re_ /= __re; __im_ /= __re; return *this;} template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c) { __re_ = __c.real(); __im_ = __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c) { __re_ += __c.real(); __im_ += __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c) { __re_ -= __c.real(); __im_ -= __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { *this = *this * complex(__c.real(), __c.imag()); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { *this = *this / complex(__c.real(), __c.imag()); return *this; }};template<>class _LIBCPP_TEMPLATE_VIS complex<double>{ double __re_; double __im_;public: typedef double value_type; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0) : __re_(__re), __im_(__im) {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(const complex<float>& __c); _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c); _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double real() const {return __re_;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double imag() const {return __im_;} _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;} _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;} _LIBCPP_INLINE_VISIBILITY complex& operator= (double __re) {__re_ = __re; __im_ = value_type(); return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator+=(double __re) {__re_ += __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator-=(double __re) {__re_ -= __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator*=(double __re) {__re_ *= __re; __im_ *= __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator/=(double __re) {__re_ /= __re; __im_ /= __re; return *this;} template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c) { __re_ = __c.real(); __im_ = __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c) { __re_ += __c.real(); __im_ += __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c) { __re_ -= __c.real(); __im_ -= __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { *this = *this * complex(__c.real(), __c.imag()); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { *this = *this / complex(__c.real(), __c.imag()); return *this; }};template<>class _LIBCPP_TEMPLATE_VIS complex<long double>{ long double __re_; long double __im_;public: typedef long double value_type; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L) : __re_(__re), __im_(__im) {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(const complex<float>& __c); _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(const complex<double>& __c); _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double real() const {return __re_;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double imag() const {return __im_;} _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;} _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;} _LIBCPP_INLINE_VISIBILITY complex& operator= (long double __re) {__re_ = __re; __im_ = value_type(); return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator+=(long double __re) {__re_ += __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator-=(long double __re) {__re_ -= __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator*=(long double __re) {__re_ *= __re; __im_ *= __re; return *this;} _LIBCPP_INLINE_VISIBILITY complex& operator/=(long double __re) {__re_ /= __re; __im_ /= __re; return *this;} template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c) { __re_ = __c.real(); __im_ = __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c) { __re_ += __c.real(); __im_ += __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c) { __re_ -= __c.real(); __im_ -= __c.imag(); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c) { *this = *this * complex(__c.real(), __c.imag()); return *this; } template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c) { *this = *this / complex(__c.real(), __c.imag()); return *this; }};inline_LIBCPP_CONSTEXPRcomplex<float>::complex(const complex<double>& __c) : __re_(__c.real()), __im_(__c.imag()) {}inline_LIBCPP_CONSTEXPRcomplex<float>::complex(const complex<long double>& __c) : __re_(__c.real()), __im_(__c.imag()) {}inline_LIBCPP_CONSTEXPRcomplex<double>::complex(const complex<float>& __c) : __re_(__c.real()), __im_(__c.imag()) {}inline_LIBCPP_CONSTEXPRcomplex<double>::complex(const complex<long double>& __c) : __re_(__c.real()), __im_(__c.imag()) {}inline_LIBCPP_CONSTEXPRcomplex<long double>::complex(const complex<float>& __c) : __re_(__c.real()), __im_(__c.imag()) {}inline_LIBCPP_CONSTEXPRcomplex<long double>::complex(const complex<double>& __c) : __re_(__c.real()), __im_(__c.imag()) {}// 26.3.6 operators:template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator+(const complex<_Tp>& __x, const complex<_Tp>& __y){ complex<_Tp> __t(__x); __t += __y; return __t;}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator+(const complex<_Tp>& __x, const _Tp& __y){ complex<_Tp> __t(__x); __t += __y; return __t;}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator+(const _Tp& __x, const complex<_Tp>& __y){ complex<_Tp> __t(__y); __t += __x; return __t;}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator-(const complex<_Tp>& __x, const complex<_Tp>& __y){ complex<_Tp> __t(__x); __t -= __y; return __t;}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator-(const complex<_Tp>& __x, const _Tp& __y){ complex<_Tp> __t(__x); __t -= __y; return __t;}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator-(const _Tp& __x, const complex<_Tp>& __y){ complex<_Tp> __t(-__y); __t += __x; return __t;}template<class _Tp>complex<_Tp>operator*(const complex<_Tp>& __z, const complex<_Tp>& __w){ _Tp __a = __z.real(); _Tp __b = __z.imag(); _Tp __c = __w.real(); _Tp __d = __w.imag(); _Tp __ac = __a * __c; _Tp __bd = __b * __d; _Tp __ad = __a * __d; _Tp __bc = __b * __c; _Tp __x = __ac - __bd; _Tp __y = __ad + __bc; if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y)) { bool __recalc = false; if (__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b)) { __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a); __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b); if (__libcpp_isnan_or_builtin(__c)) __c = copysign(_Tp(0), __c); if (__libcpp_isnan_or_builtin(__d)) __d = copysign(_Tp(0), __d); __recalc = true; } if (__libcpp_isinf_or_builtin(__c) || __libcpp_isinf_or_builtin(__d)) { __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c); __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d); if (__libcpp_isnan_or_builtin(__a)) __a = copysign(_Tp(0), __a); if (__libcpp_isnan_or_builtin(__b)) __b = copysign(_Tp(0), __b); __recalc = true; } if (!__recalc && (__libcpp_isinf_or_builtin(__ac) || __libcpp_isinf_or_builtin(__bd) || __libcpp_isinf_or_builtin(__ad) || __libcpp_isinf_or_builtin(__bc))) { if (__libcpp_isnan_or_builtin(__a)) __a = copysign(_Tp(0), __a); if (__libcpp_isnan_or_builtin(__b)) __b = copysign(_Tp(0), __b); if (__libcpp_isnan_or_builtin(__c)) __c = copysign(_Tp(0), __c); if (__libcpp_isnan_or_builtin(__d)) __d = copysign(_Tp(0), __d); __recalc = true; } if (__recalc) { __x = _Tp(INFINITY) * (__a * __c - __b * __d); __y = _Tp(INFINITY) * (__a * __d + __b * __c); } } return complex<_Tp>(__x, __y);}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator*(const complex<_Tp>& __x, const _Tp& __y){ complex<_Tp> __t(__x); __t *= __y; return __t;}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator*(const _Tp& __x, const complex<_Tp>& __y){ complex<_Tp> __t(__y); __t *= __x; return __t;}template<class _Tp>complex<_Tp>operator/(const complex<_Tp>& __z, const complex<_Tp>& __w){ int __ilogbw = 0; _Tp __a = __z.real(); _Tp __b = __z.imag(); _Tp __c = __w.real(); _Tp __d = __w.imag(); _Tp __logbw = logb(fmax(fabs(__c), fabs(__d))); if (__libcpp_isfinite_or_builtin(__logbw)) { __ilogbw = static_cast<int>(__logbw); __c = scalbn(__c, -__ilogbw); __d = scalbn(__d, -__ilogbw); } _Tp __denom = __c * __c + __d * __d; _Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw); _Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw); if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y)) { if ((__denom == _Tp(0)) && (!__libcpp_isnan_or_builtin(__a) || !__libcpp_isnan_or_builtin(__b))) { __x = copysign(_Tp(INFINITY), __c) * __a; __y = copysign(_Tp(INFINITY), __c) * __b; } else if ((__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b)) && __libcpp_isfinite_or_builtin(__c) && __libcpp_isfinite_or_builtin(__d)) { __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a); __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b); __x = _Tp(INFINITY) * (__a * __c + __b * __d); __y = _Tp(INFINITY) * (__b * __c - __a * __d); } else if (__libcpp_isinf_or_builtin(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite_or_builtin(__a) && __libcpp_isfinite_or_builtin(__b)) { __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c); __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d); __x = _Tp(0) * (__a * __c + __b * __d); __y = _Tp(0) * (__b * __c - __a * __d); } } return complex<_Tp>(__x, __y);}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator/(const complex<_Tp>& __x, const _Tp& __y){ return complex<_Tp>(__x.real() / __y, __x.imag() / __y);}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator/(const _Tp& __x, const complex<_Tp>& __y){ complex<_Tp> __t(__x); __t /= __y; return __t;}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator+(const complex<_Tp>& __x){ return __x;}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>operator-(const complex<_Tp>& __x){ return complex<_Tp>(-__x.real(), -__x.imag());}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11booloperator==(const complex<_Tp>& __x, const complex<_Tp>& __y){ return __x.real() == __y.real() && __x.imag() == __y.imag();}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11booloperator==(const complex<_Tp>& __x, const _Tp& __y){ return __x.real() == __y && __x.imag() == 0;}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11booloperator==(const _Tp& __x, const complex<_Tp>& __y){ return __x == __y.real() && 0 == __y.imag();}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11booloperator!=(const complex<_Tp>& __x, const complex<_Tp>& __y){ return !(__x == __y);}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11booloperator!=(const complex<_Tp>& __x, const _Tp& __y){ return !(__x == __y);}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11booloperator!=(const _Tp& __x, const complex<_Tp>& __y){ return !(__x == __y);}// 26.3.7 values:template <class _Tp, bool = is_integral<_Tp>::value, bool = is_floating_point<_Tp>::value >struct __libcpp_complex_overload_traits {};// Integral Typestemplate <class _Tp>struct __libcpp_complex_overload_traits<_Tp, true, false>{ typedef double _ValueType; typedef complex<double> _ComplexType;};// Floating point typestemplate <class _Tp>struct __libcpp_complex_overload_traits<_Tp, false, true>{ typedef _Tp _ValueType; typedef complex<_Tp> _ComplexType;};// realtemplate<class _Tp>inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11_Tpreal(const complex<_Tp>& __c){ return __c.real();}template <class _Tp>inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11typename __libcpp_complex_overload_traits<_Tp>::_ValueTypereal(_Tp __re){ return __re;}// imagtemplate<class _Tp>inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11_Tpimag(const complex<_Tp>& __c){ return __c.imag();}template <class _Tp>inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11typename __libcpp_complex_overload_traits<_Tp>::_ValueTypeimag(_Tp){ return 0;}// abstemplate<class _Tp>inline _LIBCPP_INLINE_VISIBILITY_Tpabs(const complex<_Tp>& __c){ return hypot(__c.real(), __c.imag());}// argtemplate<class _Tp>inline _LIBCPP_INLINE_VISIBILITY_Tparg(const complex<_Tp>& __c){ return atan2(__c.imag(), __c.real());}template <class _Tp>inline _LIBCPP_INLINE_VISIBILITYtypename enable_if< is_same<_Tp, long double>::value, long double>::typearg(_Tp __re){ return atan2l(0.L, __re);}template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYtypename enable_if< is_integral<_Tp>::value || is_same<_Tp, double>::value, double>::typearg(_Tp __re){ return atan2(0., __re);}template <class _Tp>inline _LIBCPP_INLINE_VISIBILITYtypename enable_if< is_same<_Tp, float>::value, float>::typearg(_Tp __re){ return atan2f(0.F, __re);}// normtemplate<class _Tp>inline _LIBCPP_INLINE_VISIBILITY_Tpnorm(const complex<_Tp>& __c){ if (__libcpp_isinf_or_builtin(__c.real())) return abs(__c.real()); if (__libcpp_isinf_or_builtin(__c.imag())) return abs(__c.imag()); return __c.real() * __c.real() + __c.imag() * __c.imag();}template <class _Tp>inline _LIBCPP_INLINE_VISIBILITYtypename __libcpp_complex_overload_traits<_Tp>::_ValueTypenorm(_Tp __re){ typedef typename __libcpp_complex_overload_traits<_Tp>::_ValueType _ValueType; return static_cast<_ValueType>(__re) * __re;}// conjtemplate<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>conj(const complex<_Tp>& __c){ return complex<_Tp>(__c.real(), -__c.imag());}template <class _Tp>inline _LIBCPP_INLINE_VISIBILITYtypename __libcpp_complex_overload_traits<_Tp>::_ComplexTypeconj(_Tp __re){ typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType; return _ComplexType(__re);}// projtemplate<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>proj(const complex<_Tp>& __c){ std::complex<_Tp> __r = __c; if (__libcpp_isinf_or_builtin(__c.real()) || __libcpp_isinf_or_builtin(__c.imag())) __r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag())); return __r;}template <class _Tp>inline _LIBCPP_INLINE_VISIBILITYtypename enable_if< is_floating_point<_Tp>::value, typename __libcpp_complex_overload_traits<_Tp>::_ComplexType>::typeproj(_Tp __re){ if (__libcpp_isinf_or_builtin(__re)) __re = abs(__re); return complex<_Tp>(__re);}template <class _Tp>inline _LIBCPP_INLINE_VISIBILITYtypename enable_if< is_integral<_Tp>::value, typename __libcpp_complex_overload_traits<_Tp>::_ComplexType>::typeproj(_Tp __re){ typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType; return _ComplexType(__re);}// polartemplate<class _Tp>complex<_Tp>polar(const _Tp& __rho, const _Tp& __theta = _Tp(0)){ if (__libcpp_isnan_or_builtin(__rho) || signbit(__rho)) return complex<_Tp>(_Tp(NAN), _Tp(NAN)); if (__libcpp_isnan_or_builtin(__theta)) { if (__libcpp_isinf_or_builtin(__rho)) return complex<_Tp>(__rho, __theta); return complex<_Tp>(__theta, __theta); } if (__libcpp_isinf_or_builtin(__theta)) { if (__libcpp_isinf_or_builtin(__rho)) return complex<_Tp>(__rho, _Tp(NAN)); return complex<_Tp>(_Tp(NAN), _Tp(NAN)); } _Tp __x = __rho * cos(__theta); if (__libcpp_isnan_or_builtin(__x)) __x = 0; _Tp __y = __rho * sin(__theta); if (__libcpp_isnan_or_builtin(__y)) __y = 0; return complex<_Tp>(__x, __y);}// logtemplate<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>log(const complex<_Tp>& __x){ return complex<_Tp>(log(abs(__x)), arg(__x));}// log10template<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>log10(const complex<_Tp>& __x){ return log(__x) / log(_Tp(10));}// sqrttemplate<class _Tp>complex<_Tp>sqrt(const complex<_Tp>& __x){ if (__libcpp_isinf_or_builtin(__x.imag())) return complex<_Tp>(_Tp(INFINITY), __x.imag()); if (__libcpp_isinf_or_builtin(__x.real())) { if (__x.real() > _Tp(0)) return complex<_Tp>(__x.real(), __libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag())); return complex<_Tp>(__libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag())); } return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));}// exptemplate<class _Tp>complex<_Tp>exp(const complex<_Tp>& __x){ _Tp __i = __x.imag(); if (__libcpp_isinf_or_builtin(__x.real())) { if (__x.real() < _Tp(0)) { if (!__libcpp_isfinite_or_builtin(__i)) __i = _Tp(1); } else if (__i == 0 || !__libcpp_isfinite_or_builtin(__i)) { if (__libcpp_isinf_or_builtin(__i)) __i = _Tp(NAN); return complex<_Tp>(__x.real(), __i); } } else if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0) return __x; _Tp __e = exp(__x.real()); return complex<_Tp>(__e * cos(__i), __e * sin(__i));}// powtemplate<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>pow(const complex<_Tp>& __x, const complex<_Tp>& __y){ return exp(__y * log(__x));}template<class _Tp, class _Up>inline _LIBCPP_INLINE_VISIBILITYcomplex<typename __promote<_Tp, _Up>::type>pow(const complex<_Tp>& __x, const complex<_Up>& __y){ typedef complex<typename __promote<_Tp, _Up>::type> result_type; return _VSTD::pow(result_type(__x), result_type(__y));}template<class _Tp, class _Up>inline _LIBCPP_INLINE_VISIBILITYtypename enable_if< is_arithmetic<_Up>::value, complex<typename __promote<_Tp, _Up>::type>>::typepow(const complex<_Tp>& __x, const _Up& __y){ typedef complex<typename __promote<_Tp, _Up>::type> result_type; return _VSTD::pow(result_type(__x), result_type(__y));}template<class _Tp, class _Up>inline _LIBCPP_INLINE_VISIBILITYtypename enable_if< is_arithmetic<_Tp>::value, complex<typename __promote<_Tp, _Up>::type>>::typepow(const _Tp& __x, const complex<_Up>& __y){ typedef complex<typename __promote<_Tp, _Up>::type> result_type; return _VSTD::pow(result_type(__x), result_type(__y));}// asinhtemplate<class _Tp>complex<_Tp>asinh(const complex<_Tp>& __x){ const _Tp __pi(atan2(+0., -0.)); if (__libcpp_isinf_or_builtin(__x.real())) { if (__libcpp_isnan_or_builtin(__x.imag())) return __x; if (__libcpp_isinf_or_builtin(__x.imag())) return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag())); return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag())); } if (__libcpp_isnan_or_builtin(__x.real())) { if (__libcpp_isinf_or_builtin(__x.imag())) return complex<_Tp>(__x.imag(), __x.real()); if (__x.imag() == 0) return __x; return complex<_Tp>(__x.real(), __x.real()); } if (__libcpp_isinf_or_builtin(__x.imag())) return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag())); complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) + _Tp(1))); return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));}// acoshtemplate<class _Tp>complex<_Tp>acosh(const complex<_Tp>& __x){ const _Tp __pi(atan2(+0., -0.)); if (__libcpp_isinf_or_builtin(__x.real())) { if (__libcpp_isnan_or_builtin(__x.imag())) return complex<_Tp>(abs(__x.real()), __x.imag()); if (__libcpp_isinf_or_builtin(__x.imag())) { if (__x.real() > 0) return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag())); else return complex<_Tp>(-__x.real(), copysign(__pi * _Tp(0.75), __x.imag())); } if (__x.real() < 0) return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag())); return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag())); } if (__libcpp_isnan_or_builtin(__x.real())) { if (__libcpp_isinf_or_builtin(__x.imag())) return complex<_Tp>(abs(__x.imag()), __x.real()); return complex<_Tp>(__x.real(), __x.real()); } if (__libcpp_isinf_or_builtin(__x.imag())) return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag())); complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1))); return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));}// atanhtemplate<class _Tp>complex<_Tp>atanh(const complex<_Tp>& __x){ const _Tp __pi(atan2(+0., -0.)); if (__libcpp_isinf_or_builtin(__x.imag())) { return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag())); } if (__libcpp_isnan_or_builtin(__x.imag())) { if (__libcpp_isinf_or_builtin(__x.real()) || __x.real() == 0) return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag()); return complex<_Tp>(__x.imag(), __x.imag()); } if (__libcpp_isnan_or_builtin(__x.real())) { return complex<_Tp>(__x.real(), __x.real()); } if (__libcpp_isinf_or_builtin(__x.real())) { return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag())); } if (abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0)) { return complex<_Tp>(copysign(_Tp(INFINITY), __x.real()), copysign(_Tp(0), __x.imag())); } complex<_Tp> __z = log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2); return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));}// sinhtemplate<class _Tp>complex<_Tp>sinh(const complex<_Tp>& __x){ if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag())) return complex<_Tp>(__x.real(), _Tp(NAN)); if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag())) return complex<_Tp>(__x.real(), _Tp(NAN)); if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real())) return __x; return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));}// coshtemplate<class _Tp>complex<_Tp>cosh(const complex<_Tp>& __x){ if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag())) return complex<_Tp>(abs(__x.real()), _Tp(NAN)); if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag())) return complex<_Tp>(_Tp(NAN), __x.real()); if (__x.real() == 0 && __x.imag() == 0) return complex<_Tp>(_Tp(1), __x.imag()); if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real())) return complex<_Tp>(abs(__x.real()), __x.imag()); return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));}// tanhtemplate<class _Tp>complex<_Tp>tanh(const complex<_Tp>& __x){ if (__libcpp_isinf_or_builtin(__x.real())) { if (!__libcpp_isfinite_or_builtin(__x.imag())) return complex<_Tp>(_Tp(1), _Tp(0)); return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag()))); } if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0) return __x; _Tp __2r(_Tp(2) * __x.real()); _Tp __2i(_Tp(2) * __x.imag()); _Tp __d(cosh(__2r) + cos(__2i)); _Tp __2rsh(sinh(__2r)); if (__libcpp_isinf_or_builtin(__2rsh) && __libcpp_isinf_or_builtin(__d)) return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1), __2i > _Tp(0) ? _Tp(0) : _Tp(-0.)); return complex<_Tp>(__2rsh/__d, sin(__2i)/__d);}// asintemplate<class _Tp>complex<_Tp>asin(const complex<_Tp>& __x){ complex<_Tp> __z = asinh(complex<_Tp>(-__x.imag(), __x.real())); return complex<_Tp>(__z.imag(), -__z.real());}// acostemplate<class _Tp>complex<_Tp>acos(const complex<_Tp>& __x){ const _Tp __pi(atan2(+0., -0.)); if (__libcpp_isinf_or_builtin(__x.real())) { if (__libcpp_isnan_or_builtin(__x.imag())) return complex<_Tp>(__x.imag(), __x.real()); if (__libcpp_isinf_or_builtin(__x.imag())) { if (__x.real() < _Tp(0)) return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag()); return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag()); } if (__x.real() < _Tp(0)) return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real()); return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real()); } if (__libcpp_isnan_or_builtin(__x.real())) { if (__libcpp_isinf_or_builtin(__x.imag())) return complex<_Tp>(__x.real(), -__x.imag()); return complex<_Tp>(__x.real(), __x.real()); } if (__libcpp_isinf_or_builtin(__x.imag())) return complex<_Tp>(__pi/_Tp(2), -__x.imag()); if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag()))) return complex<_Tp>(__pi/_Tp(2), -__x.imag()); complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1))); if (signbit(__x.imag())) return complex<_Tp>(abs(__z.imag()), abs(__z.real())); return complex<_Tp>(abs(__z.imag()), -abs(__z.real()));}// atantemplate<class _Tp>complex<_Tp>atan(const complex<_Tp>& __x){ complex<_Tp> __z = atanh(complex<_Tp>(-__x.imag(), __x.real())); return complex<_Tp>(__z.imag(), -__z.real());}// sintemplate<class _Tp>complex<_Tp>sin(const complex<_Tp>& __x){ complex<_Tp> __z = sinh(complex<_Tp>(-__x.imag(), __x.real())); return complex<_Tp>(__z.imag(), -__z.real());}// costemplate<class _Tp>inline _LIBCPP_INLINE_VISIBILITYcomplex<_Tp>cos(const complex<_Tp>& __x){ return cosh(complex<_Tp>(-__x.imag(), __x.real()));}// tantemplate<class _Tp>complex<_Tp>tan(const complex<_Tp>& __x){ complex<_Tp> __z = tanh(complex<_Tp>(-__x.imag(), __x.real())); return complex<_Tp>(__z.imag(), -__z.real());}template<class _Tp, class _CharT, class _Traits>basic_istream<_CharT, _Traits>&operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x){ if (__is.good()) { ws(__is); if (__is.peek() == _CharT('(')) { __is.get(); _Tp __r; __is >> __r; if (!__is.fail()) { ws(__is); _CharT __c = __is.peek(); if (__c == _CharT(',')) { __is.get(); _Tp __i; __is >> __i; if (!__is.fail()) { ws(__is); __c = __is.peek(); if (__c == _CharT(')')) { __is.get(); __x = complex<_Tp>(__r, __i); } else __is.setstate(ios_base::failbit); } else __is.setstate(ios_base::failbit); } else if (__c == _CharT(')')) { __is.get(); __x = complex<_Tp>(__r, _Tp(0)); } else __is.setstate(ios_base::failbit); } else __is.setstate(ios_base::failbit); } else { _Tp __r; __is >> __r; if (!__is.fail()) __x = complex<_Tp>(__r, _Tp(0)); else __is.setstate(ios_base::failbit); } } else __is.setstate(ios_base::failbit); return __is;}template<class _Tp, class _CharT, class _Traits>basic_ostream<_CharT, _Traits>&operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x){ basic_ostringstream<_CharT, _Traits> __s; __s.flags(__os.flags()); __s.imbue(__os.getloc()); __s.precision(__os.precision()); __s << '(' << __x.real() << ',' << __x.imag() << ')'; return __os << __s.str();}#if _LIBCPP_STD_VER > 11 // Literal suffix for complex number literals [complex.literals]inline namespace literals{ inline namespace complex_literals { constexpr complex<long double> operator""il(long double __im) { return { 0.0l, __im }; } constexpr complex<long double> operator""il(unsigned long long __im) { return { 0.0l, static_cast<long double>(__im) }; } constexpr complex<double> operator""i(long double __im) { return { 0.0, static_cast<double>(__im) }; } constexpr complex<double> operator""i(unsigned long long __im) { return { 0.0, static_cast<double>(__im) }; } constexpr complex<float> operator""if(long double __im) { return { 0.0f, static_cast<float>(__im) }; } constexpr complex<float> operator""if(unsigned long long __im) { return { 0.0f, static_cast<float>(__im) }; } }}#endif_LIBCPP_END_NAMESPACE_STD#endif // _LIBCPP_COMPLEX