1*700637cbSDimitry Andric// -*- C++ -*- 2*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 3*700637cbSDimitry Andric// 4*700637cbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*700637cbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 6*700637cbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*700637cbSDimitry Andric// 8*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 9*700637cbSDimitry Andric 10*700637cbSDimitry Andric#ifndef _LIBCPP___CXX03_COMPLEX 11*700637cbSDimitry Andric#define _LIBCPP___CXX03_COMPLEX 12*700637cbSDimitry Andric 13*700637cbSDimitry Andric/* 14*700637cbSDimitry Andric complex synopsis 15*700637cbSDimitry Andric 16*700637cbSDimitry Andricnamespace std 17*700637cbSDimitry Andric{ 18*700637cbSDimitry Andric 19*700637cbSDimitry Andrictemplate<class T> 20*700637cbSDimitry Andricclass complex 21*700637cbSDimitry Andric{ 22*700637cbSDimitry Andricpublic: 23*700637cbSDimitry Andric typedef T value_type; 24*700637cbSDimitry Andric 25*700637cbSDimitry Andric complex(const T& re = T(), const T& im = T()); // constexpr in C++14 26*700637cbSDimitry Andric complex(const complex&); // constexpr in C++14 27*700637cbSDimitry Andric template<class X> complex(const complex<X>&); // constexpr in C++14 28*700637cbSDimitry Andric 29*700637cbSDimitry Andric T real() const; // constexpr in C++14 30*700637cbSDimitry Andric T imag() const; // constexpr in C++14 31*700637cbSDimitry Andric 32*700637cbSDimitry Andric void real(T); // constexpr in C++20 33*700637cbSDimitry Andric void imag(T); // constexpr in C++20 34*700637cbSDimitry Andric 35*700637cbSDimitry Andric complex<T>& operator= (const T&); // constexpr in C++20 36*700637cbSDimitry Andric complex<T>& operator+=(const T&); // constexpr in C++20 37*700637cbSDimitry Andric complex<T>& operator-=(const T&); // constexpr in C++20 38*700637cbSDimitry Andric complex<T>& operator*=(const T&); // constexpr in C++20 39*700637cbSDimitry Andric complex<T>& operator/=(const T&); // constexpr in C++20 40*700637cbSDimitry Andric 41*700637cbSDimitry Andric complex& operator=(const complex&); // constexpr in C++20 42*700637cbSDimitry Andric template<class X> complex<T>& operator= (const complex<X>&); // constexpr in C++20 43*700637cbSDimitry Andric template<class X> complex<T>& operator+=(const complex<X>&); // constexpr in C++20 44*700637cbSDimitry Andric template<class X> complex<T>& operator-=(const complex<X>&); // constexpr in C++20 45*700637cbSDimitry Andric template<class X> complex<T>& operator*=(const complex<X>&); // constexpr in C++20 46*700637cbSDimitry Andric template<class X> complex<T>& operator/=(const complex<X>&); // constexpr in C++20 47*700637cbSDimitry Andric}; 48*700637cbSDimitry Andric 49*700637cbSDimitry Andrictemplate<> 50*700637cbSDimitry Andricclass complex<float> 51*700637cbSDimitry Andric{ 52*700637cbSDimitry Andricpublic: 53*700637cbSDimitry Andric typedef float value_type; 54*700637cbSDimitry Andric 55*700637cbSDimitry Andric constexpr complex(float re = 0.0f, float im = 0.0f); 56*700637cbSDimitry Andric explicit constexpr complex(const complex<double>&); 57*700637cbSDimitry Andric explicit constexpr complex(const complex<long double>&); 58*700637cbSDimitry Andric 59*700637cbSDimitry Andric constexpr float real() const; 60*700637cbSDimitry Andric void real(float); // constexpr in C++20 61*700637cbSDimitry Andric constexpr float imag() const; 62*700637cbSDimitry Andric void imag(float); // constexpr in C++20 63*700637cbSDimitry Andric 64*700637cbSDimitry Andric complex<float>& operator= (float); // constexpr in C++20 65*700637cbSDimitry Andric complex<float>& operator+=(float); // constexpr in C++20 66*700637cbSDimitry Andric complex<float>& operator-=(float); // constexpr in C++20 67*700637cbSDimitry Andric complex<float>& operator*=(float); // constexpr in C++20 68*700637cbSDimitry Andric complex<float>& operator/=(float); // constexpr in C++20 69*700637cbSDimitry Andric 70*700637cbSDimitry Andric complex<float>& operator=(const complex<float>&); // constexpr in C++20 71*700637cbSDimitry Andric template<class X> complex<float>& operator= (const complex<X>&); // constexpr in C++20 72*700637cbSDimitry Andric template<class X> complex<float>& operator+=(const complex<X>&); // constexpr in C++20 73*700637cbSDimitry Andric template<class X> complex<float>& operator-=(const complex<X>&); // constexpr in C++20 74*700637cbSDimitry Andric template<class X> complex<float>& operator*=(const complex<X>&); // constexpr in C++20 75*700637cbSDimitry Andric template<class X> complex<float>& operator/=(const complex<X>&); // constexpr in C++20 76*700637cbSDimitry Andric}; 77*700637cbSDimitry Andric 78*700637cbSDimitry Andrictemplate<> 79*700637cbSDimitry Andricclass complex<double> 80*700637cbSDimitry Andric{ 81*700637cbSDimitry Andricpublic: 82*700637cbSDimitry Andric typedef double value_type; 83*700637cbSDimitry Andric 84*700637cbSDimitry Andric constexpr complex(double re = 0.0, double im = 0.0); 85*700637cbSDimitry Andric constexpr complex(const complex<float>&); 86*700637cbSDimitry Andric explicit constexpr complex(const complex<long double>&); 87*700637cbSDimitry Andric 88*700637cbSDimitry Andric constexpr double real() const; 89*700637cbSDimitry Andric void real(double); // constexpr in C++20 90*700637cbSDimitry Andric constexpr double imag() const; 91*700637cbSDimitry Andric void imag(double); // constexpr in C++20 92*700637cbSDimitry Andric 93*700637cbSDimitry Andric complex<double>& operator= (double); // constexpr in C++20 94*700637cbSDimitry Andric complex<double>& operator+=(double); // constexpr in C++20 95*700637cbSDimitry Andric complex<double>& operator-=(double); // constexpr in C++20 96*700637cbSDimitry Andric complex<double>& operator*=(double); // constexpr in C++20 97*700637cbSDimitry Andric complex<double>& operator/=(double); // constexpr in C++20 98*700637cbSDimitry Andric complex<double>& operator=(const complex<double>&); // constexpr in C++20 99*700637cbSDimitry Andric 100*700637cbSDimitry Andric template<class X> complex<double>& operator= (const complex<X>&); // constexpr in C++20 101*700637cbSDimitry Andric template<class X> complex<double>& operator+=(const complex<X>&); // constexpr in C++20 102*700637cbSDimitry Andric template<class X> complex<double>& operator-=(const complex<X>&); // constexpr in C++20 103*700637cbSDimitry Andric template<class X> complex<double>& operator*=(const complex<X>&); // constexpr in C++20 104*700637cbSDimitry Andric template<class X> complex<double>& operator/=(const complex<X>&); // constexpr in C++20 105*700637cbSDimitry Andric}; 106*700637cbSDimitry Andric 107*700637cbSDimitry Andrictemplate<> 108*700637cbSDimitry Andricclass complex<long double> 109*700637cbSDimitry Andric{ 110*700637cbSDimitry Andricpublic: 111*700637cbSDimitry Andric typedef long double value_type; 112*700637cbSDimitry Andric 113*700637cbSDimitry Andric constexpr complex(long double re = 0.0L, long double im = 0.0L); 114*700637cbSDimitry Andric constexpr complex(const complex<float>&); 115*700637cbSDimitry Andric constexpr complex(const complex<double>&); 116*700637cbSDimitry Andric 117*700637cbSDimitry Andric constexpr long double real() const; 118*700637cbSDimitry Andric void real(long double); // constexpr in C++20 119*700637cbSDimitry Andric constexpr long double imag() const; 120*700637cbSDimitry Andric void imag(long double); // constexpr in C++20 121*700637cbSDimitry Andric 122*700637cbSDimitry Andric complex<long double>& operator=(const complex<long double>&); // constexpr in C++20 123*700637cbSDimitry Andric complex<long double>& operator= (long double); // constexpr in C++20 124*700637cbSDimitry Andric complex<long double>& operator+=(long double); // constexpr in C++20 125*700637cbSDimitry Andric complex<long double>& operator-=(long double); // constexpr in C++20 126*700637cbSDimitry Andric complex<long double>& operator*=(long double); // constexpr in C++20 127*700637cbSDimitry Andric complex<long double>& operator/=(long double); // constexpr in C++20 128*700637cbSDimitry Andric 129*700637cbSDimitry Andric template<class X> complex<long double>& operator= (const complex<X>&); // constexpr in C++20 130*700637cbSDimitry Andric template<class X> complex<long double>& operator+=(const complex<X>&); // constexpr in C++20 131*700637cbSDimitry Andric template<class X> complex<long double>& operator-=(const complex<X>&); // constexpr in C++20 132*700637cbSDimitry Andric template<class X> complex<long double>& operator*=(const complex<X>&); // constexpr in C++20 133*700637cbSDimitry Andric template<class X> complex<long double>& operator/=(const complex<X>&); // constexpr in C++20 134*700637cbSDimitry Andric}; 135*700637cbSDimitry Andric 136*700637cbSDimitry Andric// 26.3.6 operators: 137*700637cbSDimitry Andrictemplate<class T> complex<T> operator+(const complex<T>&, const complex<T>&); // constexpr in C++20 138*700637cbSDimitry Andrictemplate<class T> complex<T> operator+(const complex<T>&, const T&); // constexpr in C++20 139*700637cbSDimitry Andrictemplate<class T> complex<T> operator+(const T&, const complex<T>&); // constexpr in C++20 140*700637cbSDimitry Andrictemplate<class T> complex<T> operator-(const complex<T>&, const complex<T>&); // constexpr in C++20 141*700637cbSDimitry Andrictemplate<class T> complex<T> operator-(const complex<T>&, const T&); // constexpr in C++20 142*700637cbSDimitry Andrictemplate<class T> complex<T> operator-(const T&, const complex<T>&); // constexpr in C++20 143*700637cbSDimitry Andrictemplate<class T> complex<T> operator*(const complex<T>&, const complex<T>&); // constexpr in C++20 144*700637cbSDimitry Andrictemplate<class T> complex<T> operator*(const complex<T>&, const T&); // constexpr in C++20 145*700637cbSDimitry Andrictemplate<class T> complex<T> operator*(const T&, const complex<T>&); // constexpr in C++20 146*700637cbSDimitry Andrictemplate<class T> complex<T> operator/(const complex<T>&, const complex<T>&); // constexpr in C++20 147*700637cbSDimitry Andrictemplate<class T> complex<T> operator/(const complex<T>&, const T&); // constexpr in C++20 148*700637cbSDimitry Andrictemplate<class T> complex<T> operator/(const T&, const complex<T>&); // constexpr in C++20 149*700637cbSDimitry Andrictemplate<class T> complex<T> operator+(const complex<T>&); // constexpr in C++20 150*700637cbSDimitry Andrictemplate<class T> complex<T> operator-(const complex<T>&); // constexpr in C++20 151*700637cbSDimitry Andrictemplate<class T> bool operator==(const complex<T>&, const complex<T>&); // constexpr in C++14 152*700637cbSDimitry Andrictemplate<class T> bool operator==(const complex<T>&, const T&); // constexpr in C++14 153*700637cbSDimitry Andrictemplate<class T> bool operator==(const T&, const complex<T>&); // constexpr in C++14, removed in C++20 154*700637cbSDimitry Andrictemplate<class T> bool operator!=(const complex<T>&, const complex<T>&); // constexpr in C++14, removed in C++20 155*700637cbSDimitry Andrictemplate<class T> bool operator!=(const complex<T>&, const T&); // constexpr in C++14, removed in C++20 156*700637cbSDimitry Andrictemplate<class T> bool operator!=(const T&, const complex<T>&); // constexpr in C++14, removed in C++20 157*700637cbSDimitry Andric 158*700637cbSDimitry Andrictemplate<class T, class charT, class traits> 159*700637cbSDimitry Andric basic_istream<charT, traits>& 160*700637cbSDimitry Andric operator>>(basic_istream<charT, traits>&, complex<T>&); 161*700637cbSDimitry Andrictemplate<class T, class charT, class traits> 162*700637cbSDimitry Andric basic_ostream<charT, traits>& 163*700637cbSDimitry Andric operator<<(basic_ostream<charT, traits>&, const complex<T>&); 164*700637cbSDimitry Andric 165*700637cbSDimitry Andric// 26.3.7 values: 166*700637cbSDimitry Andric 167*700637cbSDimitry Andrictemplate<class T> T real(const complex<T>&); // constexpr in C++14 168*700637cbSDimitry Andric long double real(long double); // constexpr in C++14 169*700637cbSDimitry Andric double real(double); // constexpr in C++14 170*700637cbSDimitry Andrictemplate<Integral T> double real(T); // constexpr in C++14 171*700637cbSDimitry Andric float real(float); // constexpr in C++14 172*700637cbSDimitry Andric 173*700637cbSDimitry Andrictemplate<class T> T imag(const complex<T>&); // constexpr in C++14 174*700637cbSDimitry Andric long double imag(long double); // constexpr in C++14 175*700637cbSDimitry Andric double imag(double); // constexpr in C++14 176*700637cbSDimitry Andrictemplate<Integral T> double imag(T); // constexpr in C++14 177*700637cbSDimitry Andric float imag(float); // constexpr in C++14 178*700637cbSDimitry Andric 179*700637cbSDimitry Andrictemplate<class T> T abs(const complex<T>&); 180*700637cbSDimitry Andric 181*700637cbSDimitry Andrictemplate<class T> T arg(const complex<T>&); 182*700637cbSDimitry Andric long double arg(long double); 183*700637cbSDimitry Andric double arg(double); 184*700637cbSDimitry Andrictemplate<Integral T> double arg(T); 185*700637cbSDimitry Andric float arg(float); 186*700637cbSDimitry Andric 187*700637cbSDimitry Andrictemplate<class T> T norm(const complex<T>&); // constexpr in C++20 188*700637cbSDimitry Andric long double norm(long double); // constexpr in C++20 189*700637cbSDimitry Andric double norm(double); // constexpr in C++20 190*700637cbSDimitry Andrictemplate<Integral T> double norm(T); // constexpr in C++20 191*700637cbSDimitry Andric float norm(float); // constexpr in C++20 192*700637cbSDimitry Andric 193*700637cbSDimitry Andrictemplate<class T> complex<T> conj(const complex<T>&); // constexpr in C++20 194*700637cbSDimitry Andric complex<long double> conj(long double); // constexpr in C++20 195*700637cbSDimitry Andric complex<double> conj(double); // constexpr in C++20 196*700637cbSDimitry Andrictemplate<Integral T> complex<double> conj(T); // constexpr in C++20 197*700637cbSDimitry Andric complex<float> conj(float); // constexpr in C++20 198*700637cbSDimitry Andric 199*700637cbSDimitry Andrictemplate<class T> complex<T> proj(const complex<T>&); 200*700637cbSDimitry Andric complex<long double> proj(long double); 201*700637cbSDimitry Andric complex<double> proj(double); 202*700637cbSDimitry Andrictemplate<Integral T> complex<double> proj(T); 203*700637cbSDimitry Andric complex<float> proj(float); 204*700637cbSDimitry Andric 205*700637cbSDimitry Andrictemplate<class T> complex<T> polar(const T&, const T& = T()); 206*700637cbSDimitry Andric 207*700637cbSDimitry Andric// 26.3.8 transcendentals: 208*700637cbSDimitry Andrictemplate<class T> complex<T> acos(const complex<T>&); 209*700637cbSDimitry Andrictemplate<class T> complex<T> asin(const complex<T>&); 210*700637cbSDimitry Andrictemplate<class T> complex<T> atan(const complex<T>&); 211*700637cbSDimitry Andrictemplate<class T> complex<T> acosh(const complex<T>&); 212*700637cbSDimitry Andrictemplate<class T> complex<T> asinh(const complex<T>&); 213*700637cbSDimitry Andrictemplate<class T> complex<T> atanh(const complex<T>&); 214*700637cbSDimitry Andrictemplate<class T> complex<T> cos (const complex<T>&); 215*700637cbSDimitry Andrictemplate<class T> complex<T> cosh (const complex<T>&); 216*700637cbSDimitry Andrictemplate<class T> complex<T> exp (const complex<T>&); 217*700637cbSDimitry Andrictemplate<class T> complex<T> log (const complex<T>&); 218*700637cbSDimitry Andrictemplate<class T> complex<T> log10(const complex<T>&); 219*700637cbSDimitry Andric 220*700637cbSDimitry Andrictemplate<class T> complex<T> pow(const complex<T>&, const T&); 221*700637cbSDimitry Andrictemplate<class T> complex<T> pow(const complex<T>&, const complex<T>&); 222*700637cbSDimitry Andrictemplate<class T> complex<T> pow(const T&, const complex<T>&); 223*700637cbSDimitry Andric 224*700637cbSDimitry Andrictemplate<class T> complex<T> sin (const complex<T>&); 225*700637cbSDimitry Andrictemplate<class T> complex<T> sinh (const complex<T>&); 226*700637cbSDimitry Andrictemplate<class T> complex<T> sqrt (const complex<T>&); 227*700637cbSDimitry Andrictemplate<class T> complex<T> tan (const complex<T>&); 228*700637cbSDimitry Andrictemplate<class T> complex<T> tanh (const complex<T>&); 229*700637cbSDimitry Andric 230*700637cbSDimitry Andric // [complex.tuple], tuple interface 231*700637cbSDimitry Andric template<class T> struct tuple_size; // Since C++26 232*700637cbSDimitry Andric template<size_t I, class T> struct tuple_element; // Since C++26 233*700637cbSDimitry Andric template<class T> struct tuple_size<complex<T>>; // Since C++26 234*700637cbSDimitry Andric template<size_t I, class T> struct tuple_element<I, complex<T>>; // Since C++26 235*700637cbSDimitry Andric template<size_t I, class T> 236*700637cbSDimitry Andric constexpr T& get(complex<T>&) noexcept; // Since C++26 237*700637cbSDimitry Andric template<size_t I, class T> 238*700637cbSDimitry Andric constexpr T&& get(complex<T>&&) noexcept; // Since C++26 239*700637cbSDimitry Andric template<size_t I, class T> 240*700637cbSDimitry Andric constexpr const T& get(const complex<T>&) noexcept; // Since C++26 241*700637cbSDimitry Andric template<size_t I, class T> 242*700637cbSDimitry Andric constexpr const T&& get(const complex<T>&&) noexcept; // Since C++26 243*700637cbSDimitry Andric 244*700637cbSDimitry Andric // [complex.literals], complex literals 245*700637cbSDimitry Andric inline namespace literals { 246*700637cbSDimitry Andric inline namespace complex_literals { 247*700637cbSDimitry Andric constexpr complex<long double> operator""il(long double); // Since C++14 248*700637cbSDimitry Andric constexpr complex<long double> operator""il(unsigned long long); // Since C++14 249*700637cbSDimitry Andric constexpr complex<double> operator""i(long double); // Since C++14 250*700637cbSDimitry Andric constexpr complex<double> operator""i(unsigned long long); // Since C++14 251*700637cbSDimitry Andric constexpr complex<float> operator""if(long double); // Since C++14 252*700637cbSDimitry Andric constexpr complex<float> operator""if(unsigned long long); // Since C++14 253*700637cbSDimitry Andric } 254*700637cbSDimitry Andric } 255*700637cbSDimitry Andric} // std 256*700637cbSDimitry Andric 257*700637cbSDimitry Andric*/ 258*700637cbSDimitry Andric 259*700637cbSDimitry Andric#include <__cxx03/__config> 260*700637cbSDimitry Andric#include <__cxx03/__fwd/complex.h> 261*700637cbSDimitry Andric#include <__cxx03/__fwd/tuple.h> 262*700637cbSDimitry Andric#include <__cxx03/__tuple/tuple_element.h> 263*700637cbSDimitry Andric#include <__cxx03/__tuple/tuple_size.h> 264*700637cbSDimitry Andric#include <__cxx03/__type_traits/conditional.h> 265*700637cbSDimitry Andric#include <__cxx03/__utility/move.h> 266*700637cbSDimitry Andric#include <__cxx03/cmath> 267*700637cbSDimitry Andric#include <__cxx03/version> 268*700637cbSDimitry Andric 269*700637cbSDimitry Andric#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) 270*700637cbSDimitry Andric# include <__cxx03/sstream> // for std::basic_ostringstream 271*700637cbSDimitry Andric#endif 272*700637cbSDimitry Andric 273*700637cbSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 274*700637cbSDimitry Andric# pragma GCC system_header 275*700637cbSDimitry Andric#endif 276*700637cbSDimitry Andric 277*700637cbSDimitry Andric_LIBCPP_PUSH_MACROS 278*700637cbSDimitry Andric#include <__cxx03/__undef_macros> 279*700637cbSDimitry Andric 280*700637cbSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 281*700637cbSDimitry Andric 282*700637cbSDimitry Andrictemplate <class _Tp> 283*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS complex; 284*700637cbSDimitry Andric 285*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> 286*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w); 287*700637cbSDimitry Andric 288*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> = 0> 289*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w); 290*700637cbSDimitry Andric 291*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> 292*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); 293*700637cbSDimitry Andric 294*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> = 0> 295*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); 296*700637cbSDimitry Andric 297*700637cbSDimitry Andrictemplate <class _Tp> 298*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS complex { 299*700637cbSDimitry Andricpublic: 300*700637cbSDimitry Andric typedef _Tp value_type; 301*700637cbSDimitry Andric 302*700637cbSDimitry Andricprivate: 303*700637cbSDimitry Andric value_type __re_; 304*700637cbSDimitry Andric value_type __im_; 305*700637cbSDimitry Andric 306*700637cbSDimitry Andricpublic: 307*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex(const value_type& __re = value_type(), const value_type& __im = value_type()) 308*700637cbSDimitry Andric : __re_(__re), __im_(__im) {} 309*700637cbSDimitry Andric template <class _Xp> 310*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex(const complex<_Xp>& __c) : __re_(__c.real()), __im_(__c.imag()) {} 311*700637cbSDimitry Andric 312*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI value_type real() const { return __re_; } 313*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI value_type imag() const { return __im_; } 314*700637cbSDimitry Andric 315*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void real(value_type __re) { __re_ = __re; } 316*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void imag(value_type __im) { __im_ = __im; } 317*700637cbSDimitry Andric 318*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator=(const value_type& __re) { 319*700637cbSDimitry Andric __re_ = __re; 320*700637cbSDimitry Andric __im_ = value_type(); 321*700637cbSDimitry Andric return *this; 322*700637cbSDimitry Andric } 323*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator+=(const value_type& __re) { 324*700637cbSDimitry Andric __re_ += __re; 325*700637cbSDimitry Andric return *this; 326*700637cbSDimitry Andric } 327*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator-=(const value_type& __re) { 328*700637cbSDimitry Andric __re_ -= __re; 329*700637cbSDimitry Andric return *this; 330*700637cbSDimitry Andric } 331*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator*=(const value_type& __re) { 332*700637cbSDimitry Andric __re_ *= __re; 333*700637cbSDimitry Andric __im_ *= __re; 334*700637cbSDimitry Andric return *this; 335*700637cbSDimitry Andric } 336*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator/=(const value_type& __re) { 337*700637cbSDimitry Andric __re_ /= __re; 338*700637cbSDimitry Andric __im_ /= __re; 339*700637cbSDimitry Andric return *this; 340*700637cbSDimitry Andric } 341*700637cbSDimitry Andric 342*700637cbSDimitry Andric template <class _Xp> 343*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator=(const complex<_Xp>& __c) { 344*700637cbSDimitry Andric __re_ = __c.real(); 345*700637cbSDimitry Andric __im_ = __c.imag(); 346*700637cbSDimitry Andric return *this; 347*700637cbSDimitry Andric } 348*700637cbSDimitry Andric template <class _Xp> 349*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator+=(const complex<_Xp>& __c) { 350*700637cbSDimitry Andric __re_ += __c.real(); 351*700637cbSDimitry Andric __im_ += __c.imag(); 352*700637cbSDimitry Andric return *this; 353*700637cbSDimitry Andric } 354*700637cbSDimitry Andric template <class _Xp> 355*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator-=(const complex<_Xp>& __c) { 356*700637cbSDimitry Andric __re_ -= __c.real(); 357*700637cbSDimitry Andric __im_ -= __c.imag(); 358*700637cbSDimitry Andric return *this; 359*700637cbSDimitry Andric } 360*700637cbSDimitry Andric template <class _Xp> 361*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator*=(const complex<_Xp>& __c) { 362*700637cbSDimitry Andric *this = *this * complex(__c.real(), __c.imag()); 363*700637cbSDimitry Andric return *this; 364*700637cbSDimitry Andric } 365*700637cbSDimitry Andric template <class _Xp> 366*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator/=(const complex<_Xp>& __c) { 367*700637cbSDimitry Andric *this = *this / complex(__c.real(), __c.imag()); 368*700637cbSDimitry Andric return *this; 369*700637cbSDimitry Andric } 370*700637cbSDimitry Andric}; 371*700637cbSDimitry Andric 372*700637cbSDimitry Andrictemplate <> 373*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS complex<double>; 374*700637cbSDimitry Andrictemplate <> 375*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS complex<long double>; 376*700637cbSDimitry Andric 377*700637cbSDimitry Andricstruct __from_builtin_tag {}; 378*700637cbSDimitry Andric 379*700637cbSDimitry Andrictemplate <class _Tp> 380*700637cbSDimitry Andricusing __complex_t = 381*700637cbSDimitry Andric __conditional_t<is_same<_Tp, float>::value, 382*700637cbSDimitry Andric _Complex float, 383*700637cbSDimitry Andric __conditional_t<is_same<_Tp, double>::value, _Complex double, _Complex long double> >; 384*700637cbSDimitry Andric 385*700637cbSDimitry Andrictemplate <class _Tp> 386*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI __complex_t<_Tp> __make_complex(_Tp __re, _Tp __im) { 387*700637cbSDimitry Andric#if __has_builtin(__builtin_complex) 388*700637cbSDimitry Andric return __builtin_complex(__re, __im); 389*700637cbSDimitry Andric#else 390*700637cbSDimitry Andric return __complex_t<_Tp>{__re, __im}; 391*700637cbSDimitry Andric#endif 392*700637cbSDimitry Andric} 393*700637cbSDimitry Andric 394*700637cbSDimitry Andrictemplate <> 395*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS complex<float> { 396*700637cbSDimitry Andric float __re_; 397*700637cbSDimitry Andric float __im_; 398*700637cbSDimitry Andric 399*700637cbSDimitry Andricpublic: 400*700637cbSDimitry Andric typedef float value_type; 401*700637cbSDimitry Andric 402*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex(float __re = 0.0f, float __im = 0.0f) : __re_(__re), __im_(__im) {} 403*700637cbSDimitry Andric 404*700637cbSDimitry Andric template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0> 405*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit complex(_Tag, _Complex float __v) : __re_(__real__ __v), __im_(__imag__ __v) {} 406*700637cbSDimitry Andric 407*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit complex(const complex<double>& __c); 408*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit complex(const complex<long double>& __c); 409*700637cbSDimitry Andric 410*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI float real() const { return __re_; } 411*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI float imag() const { return __im_; } 412*700637cbSDimitry Andric 413*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void real(value_type __re) { __re_ = __re; } 414*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void imag(value_type __im) { __im_ = __im; } 415*700637cbSDimitry Andric 416*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI _Complex float __builtin() const { return std::__make_complex(__re_, __im_); } 417*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void __builtin(_Complex float __f) { 418*700637cbSDimitry Andric __re_ = __real__ __f; 419*700637cbSDimitry Andric __im_ = __imag__ __f; 420*700637cbSDimitry Andric } 421*700637cbSDimitry Andric 422*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator=(float __re) { 423*700637cbSDimitry Andric __re_ = __re; 424*700637cbSDimitry Andric __im_ = value_type(); 425*700637cbSDimitry Andric return *this; 426*700637cbSDimitry Andric } 427*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator+=(float __re) { 428*700637cbSDimitry Andric __re_ += __re; 429*700637cbSDimitry Andric return *this; 430*700637cbSDimitry Andric } 431*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator-=(float __re) { 432*700637cbSDimitry Andric __re_ -= __re; 433*700637cbSDimitry Andric return *this; 434*700637cbSDimitry Andric } 435*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator*=(float __re) { 436*700637cbSDimitry Andric __re_ *= __re; 437*700637cbSDimitry Andric __im_ *= __re; 438*700637cbSDimitry Andric return *this; 439*700637cbSDimitry Andric } 440*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator/=(float __re) { 441*700637cbSDimitry Andric __re_ /= __re; 442*700637cbSDimitry Andric __im_ /= __re; 443*700637cbSDimitry Andric return *this; 444*700637cbSDimitry Andric } 445*700637cbSDimitry Andric 446*700637cbSDimitry Andric template <class _Xp> 447*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator=(const complex<_Xp>& __c) { 448*700637cbSDimitry Andric __re_ = __c.real(); 449*700637cbSDimitry Andric __im_ = __c.imag(); 450*700637cbSDimitry Andric return *this; 451*700637cbSDimitry Andric } 452*700637cbSDimitry Andric template <class _Xp> 453*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator+=(const complex<_Xp>& __c) { 454*700637cbSDimitry Andric __re_ += __c.real(); 455*700637cbSDimitry Andric __im_ += __c.imag(); 456*700637cbSDimitry Andric return *this; 457*700637cbSDimitry Andric } 458*700637cbSDimitry Andric template <class _Xp> 459*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator-=(const complex<_Xp>& __c) { 460*700637cbSDimitry Andric __re_ -= __c.real(); 461*700637cbSDimitry Andric __im_ -= __c.imag(); 462*700637cbSDimitry Andric return *this; 463*700637cbSDimitry Andric } 464*700637cbSDimitry Andric template <class _Xp> 465*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator*=(const complex<_Xp>& __c) { 466*700637cbSDimitry Andric *this = *this * complex(__c.real(), __c.imag()); 467*700637cbSDimitry Andric return *this; 468*700637cbSDimitry Andric } 469*700637cbSDimitry Andric template <class _Xp> 470*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator/=(const complex<_Xp>& __c) { 471*700637cbSDimitry Andric *this = *this / complex(__c.real(), __c.imag()); 472*700637cbSDimitry Andric return *this; 473*700637cbSDimitry Andric } 474*700637cbSDimitry Andric}; 475*700637cbSDimitry Andric 476*700637cbSDimitry Andrictemplate <> 477*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS complex<double> { 478*700637cbSDimitry Andric double __re_; 479*700637cbSDimitry Andric double __im_; 480*700637cbSDimitry Andric 481*700637cbSDimitry Andricpublic: 482*700637cbSDimitry Andric typedef double value_type; 483*700637cbSDimitry Andric 484*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex(double __re = 0.0, double __im = 0.0) : __re_(__re), __im_(__im) {} 485*700637cbSDimitry Andric 486*700637cbSDimitry Andric template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0> 487*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit complex(_Tag, _Complex double __v) : __re_(__real__ __v), __im_(__imag__ __v) {} 488*700637cbSDimitry Andric 489*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex(const complex<float>& __c); 490*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit complex(const complex<long double>& __c); 491*700637cbSDimitry Andric 492*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI double real() const { return __re_; } 493*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI double imag() const { return __im_; } 494*700637cbSDimitry Andric 495*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void real(value_type __re) { __re_ = __re; } 496*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void imag(value_type __im) { __im_ = __im; } 497*700637cbSDimitry Andric 498*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI _Complex double __builtin() const { return std::__make_complex(__re_, __im_); } 499*700637cbSDimitry Andric 500*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void __builtin(_Complex double __f) { 501*700637cbSDimitry Andric __re_ = __real__ __f; 502*700637cbSDimitry Andric __im_ = __imag__ __f; 503*700637cbSDimitry Andric } 504*700637cbSDimitry Andric 505*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator=(double __re) { 506*700637cbSDimitry Andric __re_ = __re; 507*700637cbSDimitry Andric __im_ = value_type(); 508*700637cbSDimitry Andric return *this; 509*700637cbSDimitry Andric } 510*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator+=(double __re) { 511*700637cbSDimitry Andric __re_ += __re; 512*700637cbSDimitry Andric return *this; 513*700637cbSDimitry Andric } 514*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator-=(double __re) { 515*700637cbSDimitry Andric __re_ -= __re; 516*700637cbSDimitry Andric return *this; 517*700637cbSDimitry Andric } 518*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator*=(double __re) { 519*700637cbSDimitry Andric __re_ *= __re; 520*700637cbSDimitry Andric __im_ *= __re; 521*700637cbSDimitry Andric return *this; 522*700637cbSDimitry Andric } 523*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator/=(double __re) { 524*700637cbSDimitry Andric __re_ /= __re; 525*700637cbSDimitry Andric __im_ /= __re; 526*700637cbSDimitry Andric return *this; 527*700637cbSDimitry Andric } 528*700637cbSDimitry Andric 529*700637cbSDimitry Andric template <class _Xp> 530*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator=(const complex<_Xp>& __c) { 531*700637cbSDimitry Andric __re_ = __c.real(); 532*700637cbSDimitry Andric __im_ = __c.imag(); 533*700637cbSDimitry Andric return *this; 534*700637cbSDimitry Andric } 535*700637cbSDimitry Andric template <class _Xp> 536*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator+=(const complex<_Xp>& __c) { 537*700637cbSDimitry Andric __re_ += __c.real(); 538*700637cbSDimitry Andric __im_ += __c.imag(); 539*700637cbSDimitry Andric return *this; 540*700637cbSDimitry Andric } 541*700637cbSDimitry Andric template <class _Xp> 542*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator-=(const complex<_Xp>& __c) { 543*700637cbSDimitry Andric __re_ -= __c.real(); 544*700637cbSDimitry Andric __im_ -= __c.imag(); 545*700637cbSDimitry Andric return *this; 546*700637cbSDimitry Andric } 547*700637cbSDimitry Andric template <class _Xp> 548*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator*=(const complex<_Xp>& __c) { 549*700637cbSDimitry Andric *this = *this * complex(__c.real(), __c.imag()); 550*700637cbSDimitry Andric return *this; 551*700637cbSDimitry Andric } 552*700637cbSDimitry Andric template <class _Xp> 553*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator/=(const complex<_Xp>& __c) { 554*700637cbSDimitry Andric *this = *this / complex(__c.real(), __c.imag()); 555*700637cbSDimitry Andric return *this; 556*700637cbSDimitry Andric } 557*700637cbSDimitry Andric}; 558*700637cbSDimitry Andric 559*700637cbSDimitry Andrictemplate <> 560*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS complex<long double> { 561*700637cbSDimitry Andric long double __re_; 562*700637cbSDimitry Andric long double __im_; 563*700637cbSDimitry Andric 564*700637cbSDimitry Andricpublic: 565*700637cbSDimitry Andric typedef long double value_type; 566*700637cbSDimitry Andric 567*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex(long double __re = 0.0L, long double __im = 0.0L) : __re_(__re), __im_(__im) {} 568*700637cbSDimitry Andric 569*700637cbSDimitry Andric template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0> 570*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit complex(_Tag, _Complex long double __v) : __re_(__real__ __v), __im_(__imag__ __v) {} 571*700637cbSDimitry Andric 572*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex(const complex<float>& __c); 573*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex(const complex<double>& __c); 574*700637cbSDimitry Andric 575*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI long double real() const { return __re_; } 576*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI long double imag() const { return __im_; } 577*700637cbSDimitry Andric 578*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void real(value_type __re) { __re_ = __re; } 579*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void imag(value_type __im) { __im_ = __im; } 580*700637cbSDimitry Andric 581*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI _Complex long double __builtin() const { return std::__make_complex(__re_, __im_); } 582*700637cbSDimitry Andric 583*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void __builtin(_Complex long double __f) { 584*700637cbSDimitry Andric __re_ = __real__ __f; 585*700637cbSDimitry Andric __im_ = __imag__ __f; 586*700637cbSDimitry Andric } 587*700637cbSDimitry Andric 588*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator=(long double __re) { 589*700637cbSDimitry Andric __re_ = __re; 590*700637cbSDimitry Andric __im_ = value_type(); 591*700637cbSDimitry Andric return *this; 592*700637cbSDimitry Andric } 593*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator+=(long double __re) { 594*700637cbSDimitry Andric __re_ += __re; 595*700637cbSDimitry Andric return *this; 596*700637cbSDimitry Andric } 597*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator-=(long double __re) { 598*700637cbSDimitry Andric __re_ -= __re; 599*700637cbSDimitry Andric return *this; 600*700637cbSDimitry Andric } 601*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator*=(long double __re) { 602*700637cbSDimitry Andric __re_ *= __re; 603*700637cbSDimitry Andric __im_ *= __re; 604*700637cbSDimitry Andric return *this; 605*700637cbSDimitry Andric } 606*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator/=(long double __re) { 607*700637cbSDimitry Andric __re_ /= __re; 608*700637cbSDimitry Andric __im_ /= __re; 609*700637cbSDimitry Andric return *this; 610*700637cbSDimitry Andric } 611*700637cbSDimitry Andric 612*700637cbSDimitry Andric template <class _Xp> 613*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator=(const complex<_Xp>& __c) { 614*700637cbSDimitry Andric __re_ = __c.real(); 615*700637cbSDimitry Andric __im_ = __c.imag(); 616*700637cbSDimitry Andric return *this; 617*700637cbSDimitry Andric } 618*700637cbSDimitry Andric template <class _Xp> 619*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator+=(const complex<_Xp>& __c) { 620*700637cbSDimitry Andric __re_ += __c.real(); 621*700637cbSDimitry Andric __im_ += __c.imag(); 622*700637cbSDimitry Andric return *this; 623*700637cbSDimitry Andric } 624*700637cbSDimitry Andric template <class _Xp> 625*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator-=(const complex<_Xp>& __c) { 626*700637cbSDimitry Andric __re_ -= __c.real(); 627*700637cbSDimitry Andric __im_ -= __c.imag(); 628*700637cbSDimitry Andric return *this; 629*700637cbSDimitry Andric } 630*700637cbSDimitry Andric template <class _Xp> 631*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator*=(const complex<_Xp>& __c) { 632*700637cbSDimitry Andric *this = *this * complex(__c.real(), __c.imag()); 633*700637cbSDimitry Andric return *this; 634*700637cbSDimitry Andric } 635*700637cbSDimitry Andric template <class _Xp> 636*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI complex& operator/=(const complex<_Xp>& __c) { 637*700637cbSDimitry Andric *this = *this / complex(__c.real(), __c.imag()); 638*700637cbSDimitry Andric return *this; 639*700637cbSDimitry Andric } 640*700637cbSDimitry Andric}; 641*700637cbSDimitry Andric 642*700637cbSDimitry Andricinline complex<float>::complex(const complex<double>& __c) : __re_(__c.real()), __im_(__c.imag()) {} 643*700637cbSDimitry Andric 644*700637cbSDimitry Andricinline complex<float>::complex(const complex<long double>& __c) : __re_(__c.real()), __im_(__c.imag()) {} 645*700637cbSDimitry Andric 646*700637cbSDimitry Andricinline complex<double>::complex(const complex<float>& __c) : __re_(__c.real()), __im_(__c.imag()) {} 647*700637cbSDimitry Andric 648*700637cbSDimitry Andricinline complex<double>::complex(const complex<long double>& __c) : __re_(__c.real()), __im_(__c.imag()) {} 649*700637cbSDimitry Andric 650*700637cbSDimitry Andricinline complex<long double>::complex(const complex<float>& __c) : __re_(__c.real()), __im_(__c.imag()) {} 651*700637cbSDimitry Andric 652*700637cbSDimitry Andricinline complex<long double>::complex(const complex<double>& __c) : __re_(__c.real()), __im_(__c.imag()) {} 653*700637cbSDimitry Andric 654*700637cbSDimitry Andric// 26.3.6 operators: 655*700637cbSDimitry Andric 656*700637cbSDimitry Andrictemplate <class _Tp> 657*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) { 658*700637cbSDimitry Andric complex<_Tp> __t(__x); 659*700637cbSDimitry Andric __t += __y; 660*700637cbSDimitry Andric return __t; 661*700637cbSDimitry Andric} 662*700637cbSDimitry Andric 663*700637cbSDimitry Andrictemplate <class _Tp> 664*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator+(const complex<_Tp>& __x, const _Tp& __y) { 665*700637cbSDimitry Andric complex<_Tp> __t(__x); 666*700637cbSDimitry Andric __t += __y; 667*700637cbSDimitry Andric return __t; 668*700637cbSDimitry Andric} 669*700637cbSDimitry Andric 670*700637cbSDimitry Andrictemplate <class _Tp> 671*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator+(const _Tp& __x, const complex<_Tp>& __y) { 672*700637cbSDimitry Andric complex<_Tp> __t(__y); 673*700637cbSDimitry Andric __t += __x; 674*700637cbSDimitry Andric return __t; 675*700637cbSDimitry Andric} 676*700637cbSDimitry Andric 677*700637cbSDimitry Andrictemplate <class _Tp> 678*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) { 679*700637cbSDimitry Andric complex<_Tp> __t(__x); 680*700637cbSDimitry Andric __t -= __y; 681*700637cbSDimitry Andric return __t; 682*700637cbSDimitry Andric} 683*700637cbSDimitry Andric 684*700637cbSDimitry Andrictemplate <class _Tp> 685*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator-(const complex<_Tp>& __x, const _Tp& __y) { 686*700637cbSDimitry Andric complex<_Tp> __t(__x); 687*700637cbSDimitry Andric __t -= __y; 688*700637cbSDimitry Andric return __t; 689*700637cbSDimitry Andric} 690*700637cbSDimitry Andric 691*700637cbSDimitry Andrictemplate <class _Tp> 692*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator-(const _Tp& __x, const complex<_Tp>& __y) { 693*700637cbSDimitry Andric complex<_Tp> __t(-__y); 694*700637cbSDimitry Andric __t += __x; 695*700637cbSDimitry Andric return __t; 696*700637cbSDimitry Andric} 697*700637cbSDimitry Andric 698*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> > 699*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> operator*(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { 700*700637cbSDimitry Andric return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() * __rhs.__builtin()); 701*700637cbSDimitry Andric} 702*700637cbSDimitry Andric 703*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> > 704*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) { 705*700637cbSDimitry Andric _Tp __a = __z.real(); 706*700637cbSDimitry Andric _Tp __b = __z.imag(); 707*700637cbSDimitry Andric _Tp __c = __w.real(); 708*700637cbSDimitry Andric _Tp __d = __w.imag(); 709*700637cbSDimitry Andric 710*700637cbSDimitry Andric return complex<_Tp>((__a * __c) - (__b * __d), (__a * __d) + (__b * __c)); 711*700637cbSDimitry Andric} 712*700637cbSDimitry Andric 713*700637cbSDimitry Andrictemplate <class _Tp> 714*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator*(const complex<_Tp>& __x, const _Tp& __y) { 715*700637cbSDimitry Andric complex<_Tp> __t(__x); 716*700637cbSDimitry Andric __t *= __y; 717*700637cbSDimitry Andric return __t; 718*700637cbSDimitry Andric} 719*700637cbSDimitry Andric 720*700637cbSDimitry Andrictemplate <class _Tp> 721*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator*(const _Tp& __x, const complex<_Tp>& __y) { 722*700637cbSDimitry Andric complex<_Tp> __t(__y); 723*700637cbSDimitry Andric __t *= __x; 724*700637cbSDimitry Andric return __t; 725*700637cbSDimitry Andric} 726*700637cbSDimitry Andric 727*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> > 728*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> operator/(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { 729*700637cbSDimitry Andric return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() / __rhs.__builtin()); 730*700637cbSDimitry Andric} 731*700637cbSDimitry Andric 732*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> > 733*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> operator/(const complex<_Tp>& __z, const complex<_Tp>& __w) { 734*700637cbSDimitry Andric _Tp __a = __z.real(); 735*700637cbSDimitry Andric _Tp __b = __z.imag(); 736*700637cbSDimitry Andric _Tp __c = __w.real(); 737*700637cbSDimitry Andric _Tp __d = __w.imag(); 738*700637cbSDimitry Andric 739*700637cbSDimitry Andric _Tp __denom = __c * __c + __d * __d; 740*700637cbSDimitry Andric return complex<_Tp>((__a * __c + __b * __d) / __denom, (__b * __c - __a * __d) / __denom); 741*700637cbSDimitry Andric} 742*700637cbSDimitry Andric 743*700637cbSDimitry Andrictemplate <class _Tp> 744*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator/(const complex<_Tp>& __x, const _Tp& __y) { 745*700637cbSDimitry Andric return complex<_Tp>(__x.real() / __y, __x.imag() / __y); 746*700637cbSDimitry Andric} 747*700637cbSDimitry Andric 748*700637cbSDimitry Andrictemplate <class _Tp> 749*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator/(const _Tp& __x, const complex<_Tp>& __y) { 750*700637cbSDimitry Andric complex<_Tp> __t(__x); 751*700637cbSDimitry Andric __t /= __y; 752*700637cbSDimitry Andric return __t; 753*700637cbSDimitry Andric} 754*700637cbSDimitry Andric 755*700637cbSDimitry Andrictemplate <class _Tp> 756*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator+(const complex<_Tp>& __x) { 757*700637cbSDimitry Andric return __x; 758*700637cbSDimitry Andric} 759*700637cbSDimitry Andric 760*700637cbSDimitry Andrictemplate <class _Tp> 761*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> operator-(const complex<_Tp>& __x) { 762*700637cbSDimitry Andric return complex<_Tp>(-__x.real(), -__x.imag()); 763*700637cbSDimitry Andric} 764*700637cbSDimitry Andric 765*700637cbSDimitry Andrictemplate <class _Tp> 766*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) { 767*700637cbSDimitry Andric return __x.real() == __y.real() && __x.imag() == __y.imag(); 768*700637cbSDimitry Andric} 769*700637cbSDimitry Andric 770*700637cbSDimitry Andrictemplate <class _Tp> 771*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator==(const complex<_Tp>& __x, const _Tp& __y) { 772*700637cbSDimitry Andric return __x.real() == __y && __x.imag() == 0; 773*700637cbSDimitry Andric} 774*700637cbSDimitry Andric 775*700637cbSDimitry Andrictemplate <class _Tp> 776*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator==(const _Tp& __x, const complex<_Tp>& __y) { 777*700637cbSDimitry Andric return __x == __y.real() && 0 == __y.imag(); 778*700637cbSDimitry Andric} 779*700637cbSDimitry Andric 780*700637cbSDimitry Andrictemplate <class _Tp> 781*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) { 782*700637cbSDimitry Andric return !(__x == __y); 783*700637cbSDimitry Andric} 784*700637cbSDimitry Andric 785*700637cbSDimitry Andrictemplate <class _Tp> 786*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const complex<_Tp>& __x, const _Tp& __y) { 787*700637cbSDimitry Andric return !(__x == __y); 788*700637cbSDimitry Andric} 789*700637cbSDimitry Andric 790*700637cbSDimitry Andrictemplate <class _Tp> 791*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const _Tp& __x, const complex<_Tp>& __y) { 792*700637cbSDimitry Andric return !(__x == __y); 793*700637cbSDimitry Andric} 794*700637cbSDimitry Andric 795*700637cbSDimitry Andric// 26.3.7 values: 796*700637cbSDimitry Andric 797*700637cbSDimitry Andrictemplate <class _Tp, bool = is_integral<_Tp>::value, bool = is_floating_point<_Tp>::value > 798*700637cbSDimitry Andricstruct __libcpp_complex_overload_traits {}; 799*700637cbSDimitry Andric 800*700637cbSDimitry Andric// Integral Types 801*700637cbSDimitry Andrictemplate <class _Tp> 802*700637cbSDimitry Andricstruct __libcpp_complex_overload_traits<_Tp, true, false> { 803*700637cbSDimitry Andric typedef double _ValueType; 804*700637cbSDimitry Andric typedef complex<double> _ComplexType; 805*700637cbSDimitry Andric}; 806*700637cbSDimitry Andric 807*700637cbSDimitry Andric// Floating point types 808*700637cbSDimitry Andrictemplate <class _Tp> 809*700637cbSDimitry Andricstruct __libcpp_complex_overload_traits<_Tp, false, true> { 810*700637cbSDimitry Andric typedef _Tp _ValueType; 811*700637cbSDimitry Andric typedef complex<_Tp> _ComplexType; 812*700637cbSDimitry Andric}; 813*700637cbSDimitry Andric 814*700637cbSDimitry Andric// real 815*700637cbSDimitry Andric 816*700637cbSDimitry Andrictemplate <class _Tp> 817*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI _Tp real(const complex<_Tp>& __c) { 818*700637cbSDimitry Andric return __c.real(); 819*700637cbSDimitry Andric} 820*700637cbSDimitry Andric 821*700637cbSDimitry Andrictemplate <class _Tp> 822*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ValueType real(_Tp __re) { 823*700637cbSDimitry Andric return __re; 824*700637cbSDimitry Andric} 825*700637cbSDimitry Andric 826*700637cbSDimitry Andric// imag 827*700637cbSDimitry Andric 828*700637cbSDimitry Andrictemplate <class _Tp> 829*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI _Tp imag(const complex<_Tp>& __c) { 830*700637cbSDimitry Andric return __c.imag(); 831*700637cbSDimitry Andric} 832*700637cbSDimitry Andric 833*700637cbSDimitry Andrictemplate <class _Tp> 834*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ValueType imag(_Tp) { 835*700637cbSDimitry Andric return 0; 836*700637cbSDimitry Andric} 837*700637cbSDimitry Andric 838*700637cbSDimitry Andric// abs 839*700637cbSDimitry Andric 840*700637cbSDimitry Andrictemplate <class _Tp> 841*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI _Tp abs(const complex<_Tp>& __c) { 842*700637cbSDimitry Andric return std::hypot(__c.real(), __c.imag()); 843*700637cbSDimitry Andric} 844*700637cbSDimitry Andric 845*700637cbSDimitry Andric// arg 846*700637cbSDimitry Andric 847*700637cbSDimitry Andrictemplate <class _Tp> 848*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI _Tp arg(const complex<_Tp>& __c) { 849*700637cbSDimitry Andric return std::atan2(__c.imag(), __c.real()); 850*700637cbSDimitry Andric} 851*700637cbSDimitry Andric 852*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<is_same<_Tp, long double>::value, int> = 0> 853*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI long double arg(_Tp __re) { 854*700637cbSDimitry Andric return std::atan2l(0.L, __re); 855*700637cbSDimitry Andric} 856*700637cbSDimitry Andric 857*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<is_integral<_Tp>::value || is_same<_Tp, double>::value, int> = 0> 858*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI double arg(_Tp __re) { 859*700637cbSDimitry Andric return std::atan2(0., __re); 860*700637cbSDimitry Andric} 861*700637cbSDimitry Andric 862*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<is_same<_Tp, float>::value, int> = 0> 863*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI float arg(_Tp __re) { 864*700637cbSDimitry Andric return std::atan2f(0.F, __re); 865*700637cbSDimitry Andric} 866*700637cbSDimitry Andric 867*700637cbSDimitry Andric// norm 868*700637cbSDimitry Andric 869*700637cbSDimitry Andrictemplate <class _Tp> 870*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI _Tp norm(const complex<_Tp>& __c) { 871*700637cbSDimitry Andric if (std::__constexpr_isinf(__c.real())) 872*700637cbSDimitry Andric return std::abs(__c.real()); 873*700637cbSDimitry Andric if (std::__constexpr_isinf(__c.imag())) 874*700637cbSDimitry Andric return std::abs(__c.imag()); 875*700637cbSDimitry Andric return __c.real() * __c.real() + __c.imag() * __c.imag(); 876*700637cbSDimitry Andric} 877*700637cbSDimitry Andric 878*700637cbSDimitry Andrictemplate <class _Tp> 879*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ValueType norm(_Tp __re) { 880*700637cbSDimitry Andric typedef typename __libcpp_complex_overload_traits<_Tp>::_ValueType _ValueType; 881*700637cbSDimitry Andric return static_cast<_ValueType>(__re) * __re; 882*700637cbSDimitry Andric} 883*700637cbSDimitry Andric 884*700637cbSDimitry Andric// conj 885*700637cbSDimitry Andric 886*700637cbSDimitry Andrictemplate <class _Tp> 887*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> conj(const complex<_Tp>& __c) { 888*700637cbSDimitry Andric return complex<_Tp>(__c.real(), -__c.imag()); 889*700637cbSDimitry Andric} 890*700637cbSDimitry Andric 891*700637cbSDimitry Andrictemplate <class _Tp> 892*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType conj(_Tp __re) { 893*700637cbSDimitry Andric typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType; 894*700637cbSDimitry Andric return _ComplexType(__re); 895*700637cbSDimitry Andric} 896*700637cbSDimitry Andric 897*700637cbSDimitry Andric// proj 898*700637cbSDimitry Andric 899*700637cbSDimitry Andrictemplate <class _Tp> 900*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) { 901*700637cbSDimitry Andric complex<_Tp> __r = __c; 902*700637cbSDimitry Andric if (std::__constexpr_isinf(__c.real()) || std::__constexpr_isinf(__c.imag())) 903*700637cbSDimitry Andric __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag())); 904*700637cbSDimitry Andric return __r; 905*700637cbSDimitry Andric} 906*700637cbSDimitry Andric 907*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> 908*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) { 909*700637cbSDimitry Andric if (std::__constexpr_isinf(__re)) 910*700637cbSDimitry Andric __re = std::abs(__re); 911*700637cbSDimitry Andric return complex<_Tp>(__re); 912*700637cbSDimitry Andric} 913*700637cbSDimitry Andric 914*700637cbSDimitry Andrictemplate <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> 915*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) { 916*700637cbSDimitry Andric typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType; 917*700637cbSDimitry Andric return _ComplexType(__re); 918*700637cbSDimitry Andric} 919*700637cbSDimitry Andric 920*700637cbSDimitry Andric// polar 921*700637cbSDimitry Andric 922*700637cbSDimitry Andrictemplate <class _Tp> 923*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta = _Tp()) { 924*700637cbSDimitry Andric if (std::__constexpr_isnan(__rho) || std::signbit(__rho)) 925*700637cbSDimitry Andric return complex<_Tp>(_Tp(NAN), _Tp(NAN)); 926*700637cbSDimitry Andric if (std::__constexpr_isnan(__theta)) { 927*700637cbSDimitry Andric if (std::__constexpr_isinf(__rho)) 928*700637cbSDimitry Andric return complex<_Tp>(__rho, __theta); 929*700637cbSDimitry Andric return complex<_Tp>(__theta, __theta); 930*700637cbSDimitry Andric } 931*700637cbSDimitry Andric if (std::__constexpr_isinf(__theta)) { 932*700637cbSDimitry Andric if (std::__constexpr_isinf(__rho)) 933*700637cbSDimitry Andric return complex<_Tp>(__rho, _Tp(NAN)); 934*700637cbSDimitry Andric return complex<_Tp>(_Tp(NAN), _Tp(NAN)); 935*700637cbSDimitry Andric } 936*700637cbSDimitry Andric _Tp __x = __rho * std::cos(__theta); 937*700637cbSDimitry Andric if (std::__constexpr_isnan(__x)) 938*700637cbSDimitry Andric __x = 0; 939*700637cbSDimitry Andric _Tp __y = __rho * std::sin(__theta); 940*700637cbSDimitry Andric if (std::__constexpr_isnan(__y)) 941*700637cbSDimitry Andric __y = 0; 942*700637cbSDimitry Andric return complex<_Tp>(__x, __y); 943*700637cbSDimitry Andric} 944*700637cbSDimitry Andric 945*700637cbSDimitry Andric// log 946*700637cbSDimitry Andric 947*700637cbSDimitry Andrictemplate <class _Tp> 948*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log(const complex<_Tp>& __x) { 949*700637cbSDimitry Andric return complex<_Tp>(std::log(std::abs(__x)), std::arg(__x)); 950*700637cbSDimitry Andric} 951*700637cbSDimitry Andric 952*700637cbSDimitry Andric// log10 953*700637cbSDimitry Andric 954*700637cbSDimitry Andrictemplate <class _Tp> 955*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log10(const complex<_Tp>& __x) { 956*700637cbSDimitry Andric return std::log(__x) / std::log(_Tp(10)); 957*700637cbSDimitry Andric} 958*700637cbSDimitry Andric 959*700637cbSDimitry Andric// sqrt 960*700637cbSDimitry Andric 961*700637cbSDimitry Andrictemplate <class _Tp> 962*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) { 963*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.imag())) 964*700637cbSDimitry Andric return complex<_Tp>(_Tp(INFINITY), __x.imag()); 965*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.real())) { 966*700637cbSDimitry Andric if (__x.real() > _Tp(0)) 967*700637cbSDimitry Andric return complex<_Tp>( 968*700637cbSDimitry Andric __x.real(), std::__constexpr_isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag())); 969*700637cbSDimitry Andric return complex<_Tp>( 970*700637cbSDimitry Andric std::__constexpr_isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag())); 971*700637cbSDimitry Andric } 972*700637cbSDimitry Andric return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2)); 973*700637cbSDimitry Andric} 974*700637cbSDimitry Andric 975*700637cbSDimitry Andric// exp 976*700637cbSDimitry Andric 977*700637cbSDimitry Andrictemplate <class _Tp> 978*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) { 979*700637cbSDimitry Andric _Tp __i = __x.imag(); 980*700637cbSDimitry Andric if (__i == 0) { 981*700637cbSDimitry Andric return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag())); 982*700637cbSDimitry Andric } 983*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.real())) { 984*700637cbSDimitry Andric if (__x.real() < _Tp(0)) { 985*700637cbSDimitry Andric if (!std::__constexpr_isfinite(__i)) 986*700637cbSDimitry Andric __i = _Tp(1); 987*700637cbSDimitry Andric } else if (__i == 0 || !std::__constexpr_isfinite(__i)) { 988*700637cbSDimitry Andric if (std::__constexpr_isinf(__i)) 989*700637cbSDimitry Andric __i = _Tp(NAN); 990*700637cbSDimitry Andric return complex<_Tp>(__x.real(), __i); 991*700637cbSDimitry Andric } 992*700637cbSDimitry Andric } 993*700637cbSDimitry Andric _Tp __e = std::exp(__x.real()); 994*700637cbSDimitry Andric return complex<_Tp>(__e * std::cos(__i), __e * std::sin(__i)); 995*700637cbSDimitry Andric} 996*700637cbSDimitry Andric 997*700637cbSDimitry Andric// pow 998*700637cbSDimitry Andric 999*700637cbSDimitry Andrictemplate <class _Tp> 1000*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const complex<_Tp>& __y) { 1001*700637cbSDimitry Andric return std::exp(__y * std::log(__x)); 1002*700637cbSDimitry Andric} 1003*700637cbSDimitry Andric 1004*700637cbSDimitry Andrictemplate <class _Tp, class _Up> 1005*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> 1006*700637cbSDimitry Andricpow(const complex<_Tp>& __x, const complex<_Up>& __y) { 1007*700637cbSDimitry Andric typedef complex<typename __promote<_Tp, _Up>::type> result_type; 1008*700637cbSDimitry Andric return std::pow(result_type(__x), result_type(__y)); 1009*700637cbSDimitry Andric} 1010*700637cbSDimitry Andric 1011*700637cbSDimitry Andrictemplate <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Up>::value, int> = 0> 1012*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const complex<_Tp>& __x, const _Up& __y) { 1013*700637cbSDimitry Andric typedef complex<typename __promote<_Tp, _Up>::type> result_type; 1014*700637cbSDimitry Andric return std::pow(result_type(__x), result_type(__y)); 1015*700637cbSDimitry Andric} 1016*700637cbSDimitry Andric 1017*700637cbSDimitry Andrictemplate <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value, int> = 0> 1018*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const _Tp& __x, const complex<_Up>& __y) { 1019*700637cbSDimitry Andric typedef complex<typename __promote<_Tp, _Up>::type> result_type; 1020*700637cbSDimitry Andric return std::pow(result_type(__x), result_type(__y)); 1021*700637cbSDimitry Andric} 1022*700637cbSDimitry Andric 1023*700637cbSDimitry Andric// __sqr, computes pow(x, 2) 1024*700637cbSDimitry Andric 1025*700637cbSDimitry Andrictemplate <class _Tp> 1026*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> __sqr(const complex<_Tp>& __x) { 1027*700637cbSDimitry Andric return complex<_Tp>((__x.real() - __x.imag()) * (__x.real() + __x.imag()), _Tp(2) * __x.real() * __x.imag()); 1028*700637cbSDimitry Andric} 1029*700637cbSDimitry Andric 1030*700637cbSDimitry Andric// asinh 1031*700637cbSDimitry Andric 1032*700637cbSDimitry Andrictemplate <class _Tp> 1033*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) { 1034*700637cbSDimitry Andric const _Tp __pi(atan2(+0., -0.)); 1035*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.real())) { 1036*700637cbSDimitry Andric if (std::__constexpr_isnan(__x.imag())) 1037*700637cbSDimitry Andric return __x; 1038*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.imag())) 1039*700637cbSDimitry Andric return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag())); 1040*700637cbSDimitry Andric return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag())); 1041*700637cbSDimitry Andric } 1042*700637cbSDimitry Andric if (std::__constexpr_isnan(__x.real())) { 1043*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.imag())) 1044*700637cbSDimitry Andric return complex<_Tp>(__x.imag(), __x.real()); 1045*700637cbSDimitry Andric if (__x.imag() == 0) 1046*700637cbSDimitry Andric return __x; 1047*700637cbSDimitry Andric return complex<_Tp>(__x.real(), __x.real()); 1048*700637cbSDimitry Andric } 1049*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.imag())) 1050*700637cbSDimitry Andric return complex<_Tp>(std::copysign(__x.imag(), __x.real()), std::copysign(__pi / _Tp(2), __x.imag())); 1051*700637cbSDimitry Andric complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) + _Tp(1))); 1052*700637cbSDimitry Andric return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag())); 1053*700637cbSDimitry Andric} 1054*700637cbSDimitry Andric 1055*700637cbSDimitry Andric// acosh 1056*700637cbSDimitry Andric 1057*700637cbSDimitry Andrictemplate <class _Tp> 1058*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { 1059*700637cbSDimitry Andric const _Tp __pi(atan2(+0., -0.)); 1060*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.real())) { 1061*700637cbSDimitry Andric if (std::__constexpr_isnan(__x.imag())) 1062*700637cbSDimitry Andric return complex<_Tp>(std::abs(__x.real()), __x.imag()); 1063*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.imag())) { 1064*700637cbSDimitry Andric if (__x.real() > 0) 1065*700637cbSDimitry Andric return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag())); 1066*700637cbSDimitry Andric else 1067*700637cbSDimitry Andric return complex<_Tp>(-__x.real(), std::copysign(__pi * _Tp(0.75), __x.imag())); 1068*700637cbSDimitry Andric } 1069*700637cbSDimitry Andric if (__x.real() < 0) 1070*700637cbSDimitry Andric return complex<_Tp>(-__x.real(), std::copysign(__pi, __x.imag())); 1071*700637cbSDimitry Andric return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag())); 1072*700637cbSDimitry Andric } 1073*700637cbSDimitry Andric if (std::__constexpr_isnan(__x.real())) { 1074*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.imag())) 1075*700637cbSDimitry Andric return complex<_Tp>(std::abs(__x.imag()), __x.real()); 1076*700637cbSDimitry Andric return complex<_Tp>(__x.real(), __x.real()); 1077*700637cbSDimitry Andric } 1078*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.imag())) 1079*700637cbSDimitry Andric return complex<_Tp>(std::abs(__x.imag()), std::copysign(__pi / _Tp(2), __x.imag())); 1080*700637cbSDimitry Andric complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1))); 1081*700637cbSDimitry Andric return complex<_Tp>(std::copysign(__z.real(), _Tp(0)), std::copysign(__z.imag(), __x.imag())); 1082*700637cbSDimitry Andric} 1083*700637cbSDimitry Andric 1084*700637cbSDimitry Andric// atanh 1085*700637cbSDimitry Andric 1086*700637cbSDimitry Andrictemplate <class _Tp> 1087*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) { 1088*700637cbSDimitry Andric const _Tp __pi(atan2(+0., -0.)); 1089*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.imag())) { 1090*700637cbSDimitry Andric return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag())); 1091*700637cbSDimitry Andric } 1092*700637cbSDimitry Andric if (std::__constexpr_isnan(__x.imag())) { 1093*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.real()) || __x.real() == 0) 1094*700637cbSDimitry Andric return complex<_Tp>(std::copysign(_Tp(0), __x.real()), __x.imag()); 1095*700637cbSDimitry Andric return complex<_Tp>(__x.imag(), __x.imag()); 1096*700637cbSDimitry Andric } 1097*700637cbSDimitry Andric if (std::__constexpr_isnan(__x.real())) { 1098*700637cbSDimitry Andric return complex<_Tp>(__x.real(), __x.real()); 1099*700637cbSDimitry Andric } 1100*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.real())) { 1101*700637cbSDimitry Andric return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag())); 1102*700637cbSDimitry Andric } 1103*700637cbSDimitry Andric if (std::abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0)) { 1104*700637cbSDimitry Andric return complex<_Tp>(std::copysign(_Tp(INFINITY), __x.real()), std::copysign(_Tp(0), __x.imag())); 1105*700637cbSDimitry Andric } 1106*700637cbSDimitry Andric complex<_Tp> __z = std::log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2); 1107*700637cbSDimitry Andric return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag())); 1108*700637cbSDimitry Andric} 1109*700637cbSDimitry Andric 1110*700637cbSDimitry Andric// sinh 1111*700637cbSDimitry Andric 1112*700637cbSDimitry Andrictemplate <class _Tp> 1113*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) { 1114*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag())) 1115*700637cbSDimitry Andric return complex<_Tp>(__x.real(), _Tp(NAN)); 1116*700637cbSDimitry Andric if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag())) 1117*700637cbSDimitry Andric return complex<_Tp>(__x.real(), _Tp(NAN)); 1118*700637cbSDimitry Andric if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real())) 1119*700637cbSDimitry Andric return __x; 1120*700637cbSDimitry Andric return complex<_Tp>(std::sinh(__x.real()) * std::cos(__x.imag()), std::cosh(__x.real()) * std::sin(__x.imag())); 1121*700637cbSDimitry Andric} 1122*700637cbSDimitry Andric 1123*700637cbSDimitry Andric// cosh 1124*700637cbSDimitry Andric 1125*700637cbSDimitry Andrictemplate <class _Tp> 1126*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) { 1127*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag())) 1128*700637cbSDimitry Andric return complex<_Tp>(std::abs(__x.real()), _Tp(NAN)); 1129*700637cbSDimitry Andric if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag())) 1130*700637cbSDimitry Andric return complex<_Tp>(_Tp(NAN), __x.real()); 1131*700637cbSDimitry Andric if (__x.real() == 0 && __x.imag() == 0) 1132*700637cbSDimitry Andric return complex<_Tp>(_Tp(1), __x.imag()); 1133*700637cbSDimitry Andric if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real())) 1134*700637cbSDimitry Andric return complex<_Tp>(std::abs(__x.real()), __x.imag()); 1135*700637cbSDimitry Andric return complex<_Tp>(std::cosh(__x.real()) * std::cos(__x.imag()), std::sinh(__x.real()) * std::sin(__x.imag())); 1136*700637cbSDimitry Andric} 1137*700637cbSDimitry Andric 1138*700637cbSDimitry Andric// tanh 1139*700637cbSDimitry Andric 1140*700637cbSDimitry Andrictemplate <class _Tp> 1141*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) { 1142*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.real())) { 1143*700637cbSDimitry Andric if (!std::__constexpr_isfinite(__x.imag())) 1144*700637cbSDimitry Andric return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0)); 1145*700637cbSDimitry Andric return complex<_Tp>(std::copysign(_Tp(1), __x.real()), std::copysign(_Tp(0), std::sin(_Tp(2) * __x.imag()))); 1146*700637cbSDimitry Andric } 1147*700637cbSDimitry Andric if (std::__constexpr_isnan(__x.real()) && __x.imag() == 0) 1148*700637cbSDimitry Andric return __x; 1149*700637cbSDimitry Andric _Tp __2r(_Tp(2) * __x.real()); 1150*700637cbSDimitry Andric _Tp __2i(_Tp(2) * __x.imag()); 1151*700637cbSDimitry Andric _Tp __d(std::cosh(__2r) + std::cos(__2i)); 1152*700637cbSDimitry Andric _Tp __2rsh(std::sinh(__2r)); 1153*700637cbSDimitry Andric if (std::__constexpr_isinf(__2rsh) && std::__constexpr_isinf(__d)) 1154*700637cbSDimitry Andric return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1), __2i > _Tp(0) ? _Tp(0) : _Tp(-0.)); 1155*700637cbSDimitry Andric return complex<_Tp>(__2rsh / __d, std::sin(__2i) / __d); 1156*700637cbSDimitry Andric} 1157*700637cbSDimitry Andric 1158*700637cbSDimitry Andric// asin 1159*700637cbSDimitry Andric 1160*700637cbSDimitry Andrictemplate <class _Tp> 1161*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) { 1162*700637cbSDimitry Andric complex<_Tp> __z = std::asinh(complex<_Tp>(-__x.imag(), __x.real())); 1163*700637cbSDimitry Andric return complex<_Tp>(__z.imag(), -__z.real()); 1164*700637cbSDimitry Andric} 1165*700637cbSDimitry Andric 1166*700637cbSDimitry Andric// acos 1167*700637cbSDimitry Andric 1168*700637cbSDimitry Andrictemplate <class _Tp> 1169*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) { 1170*700637cbSDimitry Andric const _Tp __pi(atan2(+0., -0.)); 1171*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.real())) { 1172*700637cbSDimitry Andric if (std::__constexpr_isnan(__x.imag())) 1173*700637cbSDimitry Andric return complex<_Tp>(__x.imag(), __x.real()); 1174*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.imag())) { 1175*700637cbSDimitry Andric if (__x.real() < _Tp(0)) 1176*700637cbSDimitry Andric return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag()); 1177*700637cbSDimitry Andric return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag()); 1178*700637cbSDimitry Andric } 1179*700637cbSDimitry Andric if (__x.real() < _Tp(0)) 1180*700637cbSDimitry Andric return complex<_Tp>(__pi, std::signbit(__x.imag()) ? -__x.real() : __x.real()); 1181*700637cbSDimitry Andric return complex<_Tp>(_Tp(0), std::signbit(__x.imag()) ? __x.real() : -__x.real()); 1182*700637cbSDimitry Andric } 1183*700637cbSDimitry Andric if (std::__constexpr_isnan(__x.real())) { 1184*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.imag())) 1185*700637cbSDimitry Andric return complex<_Tp>(__x.real(), -__x.imag()); 1186*700637cbSDimitry Andric return complex<_Tp>(__x.real(), __x.real()); 1187*700637cbSDimitry Andric } 1188*700637cbSDimitry Andric if (std::__constexpr_isinf(__x.imag())) 1189*700637cbSDimitry Andric return complex<_Tp>(__pi / _Tp(2), -__x.imag()); 1190*700637cbSDimitry Andric if (__x.real() == 0 && (__x.imag() == 0 || std::isnan(__x.imag()))) 1191*700637cbSDimitry Andric return complex<_Tp>(__pi / _Tp(2), -__x.imag()); 1192*700637cbSDimitry Andric complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1))); 1193*700637cbSDimitry Andric if (std::signbit(__x.imag())) 1194*700637cbSDimitry Andric return complex<_Tp>(std::abs(__z.imag()), std::abs(__z.real())); 1195*700637cbSDimitry Andric return complex<_Tp>(std::abs(__z.imag()), -std::abs(__z.real())); 1196*700637cbSDimitry Andric} 1197*700637cbSDimitry Andric 1198*700637cbSDimitry Andric// atan 1199*700637cbSDimitry Andric 1200*700637cbSDimitry Andrictemplate <class _Tp> 1201*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> atan(const complex<_Tp>& __x) { 1202*700637cbSDimitry Andric complex<_Tp> __z = std::atanh(complex<_Tp>(-__x.imag(), __x.real())); 1203*700637cbSDimitry Andric return complex<_Tp>(__z.imag(), -__z.real()); 1204*700637cbSDimitry Andric} 1205*700637cbSDimitry Andric 1206*700637cbSDimitry Andric// sin 1207*700637cbSDimitry Andric 1208*700637cbSDimitry Andrictemplate <class _Tp> 1209*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> sin(const complex<_Tp>& __x) { 1210*700637cbSDimitry Andric complex<_Tp> __z = std::sinh(complex<_Tp>(-__x.imag(), __x.real())); 1211*700637cbSDimitry Andric return complex<_Tp>(__z.imag(), -__z.real()); 1212*700637cbSDimitry Andric} 1213*700637cbSDimitry Andric 1214*700637cbSDimitry Andric// cos 1215*700637cbSDimitry Andric 1216*700637cbSDimitry Andrictemplate <class _Tp> 1217*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI complex<_Tp> cos(const complex<_Tp>& __x) { 1218*700637cbSDimitry Andric return std::cosh(complex<_Tp>(-__x.imag(), __x.real())); 1219*700637cbSDimitry Andric} 1220*700637cbSDimitry Andric 1221*700637cbSDimitry Andric// tan 1222*700637cbSDimitry Andric 1223*700637cbSDimitry Andrictemplate <class _Tp> 1224*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI complex<_Tp> tan(const complex<_Tp>& __x) { 1225*700637cbSDimitry Andric complex<_Tp> __z = std::tanh(complex<_Tp>(-__x.imag(), __x.real())); 1226*700637cbSDimitry Andric return complex<_Tp>(__z.imag(), -__z.real()); 1227*700637cbSDimitry Andric} 1228*700637cbSDimitry Andric 1229*700637cbSDimitry Andric#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) 1230*700637cbSDimitry Andrictemplate <class _Tp, class _CharT, class _Traits> 1231*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& 1232*700637cbSDimitry Andricoperator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) { 1233*700637cbSDimitry Andric if (__is.good()) { 1234*700637cbSDimitry Andric std::ws(__is); 1235*700637cbSDimitry Andric if (__is.peek() == _CharT('(')) { 1236*700637cbSDimitry Andric __is.get(); 1237*700637cbSDimitry Andric _Tp __r; 1238*700637cbSDimitry Andric __is >> __r; 1239*700637cbSDimitry Andric if (!__is.fail()) { 1240*700637cbSDimitry Andric std::ws(__is); 1241*700637cbSDimitry Andric _CharT __c = __is.peek(); 1242*700637cbSDimitry Andric if (__c == _CharT(',')) { 1243*700637cbSDimitry Andric __is.get(); 1244*700637cbSDimitry Andric _Tp __i; 1245*700637cbSDimitry Andric __is >> __i; 1246*700637cbSDimitry Andric if (!__is.fail()) { 1247*700637cbSDimitry Andric std::ws(__is); 1248*700637cbSDimitry Andric __c = __is.peek(); 1249*700637cbSDimitry Andric if (__c == _CharT(')')) { 1250*700637cbSDimitry Andric __is.get(); 1251*700637cbSDimitry Andric __x = complex<_Tp>(__r, __i); 1252*700637cbSDimitry Andric } else 1253*700637cbSDimitry Andric __is.setstate(__is.failbit); 1254*700637cbSDimitry Andric } else 1255*700637cbSDimitry Andric __is.setstate(__is.failbit); 1256*700637cbSDimitry Andric } else if (__c == _CharT(')')) { 1257*700637cbSDimitry Andric __is.get(); 1258*700637cbSDimitry Andric __x = complex<_Tp>(__r, _Tp(0)); 1259*700637cbSDimitry Andric } else 1260*700637cbSDimitry Andric __is.setstate(__is.failbit); 1261*700637cbSDimitry Andric } else 1262*700637cbSDimitry Andric __is.setstate(__is.failbit); 1263*700637cbSDimitry Andric } else { 1264*700637cbSDimitry Andric _Tp __r; 1265*700637cbSDimitry Andric __is >> __r; 1266*700637cbSDimitry Andric if (!__is.fail()) 1267*700637cbSDimitry Andric __x = complex<_Tp>(__r, _Tp(0)); 1268*700637cbSDimitry Andric else 1269*700637cbSDimitry Andric __is.setstate(__is.failbit); 1270*700637cbSDimitry Andric } 1271*700637cbSDimitry Andric } else 1272*700637cbSDimitry Andric __is.setstate(__is.failbit); 1273*700637cbSDimitry Andric return __is; 1274*700637cbSDimitry Andric} 1275*700637cbSDimitry Andric 1276*700637cbSDimitry Andrictemplate <class _Tp, class _CharT, class _Traits> 1277*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& 1278*700637cbSDimitry Andricoperator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) { 1279*700637cbSDimitry Andric basic_ostringstream<_CharT, _Traits> __s; 1280*700637cbSDimitry Andric __s.flags(__os.flags()); 1281*700637cbSDimitry Andric __s.imbue(__os.getloc()); 1282*700637cbSDimitry Andric __s.precision(__os.precision()); 1283*700637cbSDimitry Andric __s << '(' << __x.real() << ',' << __x.imag() << ')'; 1284*700637cbSDimitry Andric return __os << __s.str(); 1285*700637cbSDimitry Andric} 1286*700637cbSDimitry Andric#endif // !_LIBCPP_HAS_NO_LOCALIZATION 1287*700637cbSDimitry Andric 1288*700637cbSDimitry Andric_LIBCPP_END_NAMESPACE_STD 1289*700637cbSDimitry Andric 1290*700637cbSDimitry Andric_LIBCPP_POP_MACROS 1291*700637cbSDimitry Andric 1292*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) 1293*700637cbSDimitry Andric# include <__cxx03/iosfwd> 1294*700637cbSDimitry Andric# include <__cxx03/stdexcept> 1295*700637cbSDimitry Andric# include <__cxx03/type_traits> 1296*700637cbSDimitry Andric#endif 1297*700637cbSDimitry Andric 1298*700637cbSDimitry Andric#endif // _LIBCPP___CXX03_COMPLEX 1299