29#ifndef _GLIBCXX_TR1_COMPLEX
30#define _GLIBCXX_TR1_COMPLEX 1
33#pragma GCC system_header
40namespace std _GLIBCXX_VISIBILITY(default)
42_GLIBCXX_BEGIN_NAMESPACE_VERSION
51#if __cplusplus >= 201103L
59 template<
typename _Tp> std::complex<_Tp> acos(
const std::complex<_Tp>&);
60 template<
typename _Tp> std::complex<_Tp> asin(
const std::complex<_Tp>&);
61 template<
typename _Tp> std::complex<_Tp> atan(
const std::complex<_Tp>&);
62 template<
typename _Tp> std::complex<_Tp> acosh(
const std::complex<_Tp>&);
63 template<
typename _Tp> std::complex<_Tp> asinh(
const std::complex<_Tp>&);
64 template<
typename _Tp> std::complex<_Tp> atanh(
const std::complex<_Tp>&);
68 template<
typename _Tp> std::complex<_Tp> fabs(
const std::complex<_Tp>&);
70#if __cplusplus < 201103L
71 template<
typename _Tp>
72 inline std::complex<_Tp>
73 __complex_acos(
const std::complex<_Tp>& __z)
75 const std::complex<_Tp> __t = std::tr1::asin(__z);
76 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
77 return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag());
80#if _GLIBCXX_USE_C99_COMPLEX_TR1
81 inline __complex__
float
82 __complex_acos(__complex__
float __z)
83 {
return __builtin_cacosf(__z); }
85 inline __complex__
double
86 __complex_acos(__complex__
double __z)
87 {
return __builtin_cacos(__z); }
89 inline __complex__
long double
90 __complex_acos(
const __complex__
long double& __z)
91 {
return __builtin_cacosl(__z); }
93 template<
typename _Tp>
94 inline std::complex<_Tp>
95 acos(
const std::complex<_Tp>& __z)
96 {
return __complex_acos(__z.__rep()); }
101 template<
typename _Tp>
102 inline std::complex<_Tp>
103 acos(
const std::complex<_Tp>& __z)
104 {
return __complex_acos(__z); }
107 template<
typename _Tp>
108 inline std::complex<_Tp>
109 __complex_asin(
const std::complex<_Tp>& __z)
111 std::complex<_Tp> __t(-__z.imag(), __z.real());
112 __t = std::tr1::asinh(__t);
113 return std::complex<_Tp>(__t.imag(), -__t.real());
116#if _GLIBCXX_USE_C99_COMPLEX_TR1
117 inline __complex__
float
118 __complex_asin(__complex__
float __z)
119 {
return __builtin_casinf(__z); }
121 inline __complex__
double
122 __complex_asin(__complex__
double __z)
123 {
return __builtin_casin(__z); }
125 inline __complex__
long double
126 __complex_asin(
const __complex__
long double& __z)
127 {
return __builtin_casinl(__z); }
129 template<
typename _Tp>
130 inline std::complex<_Tp>
131 asin(
const std::complex<_Tp>& __z)
132 {
return __complex_asin(__z.__rep()); }
137 template<
typename _Tp>
138 inline std::complex<_Tp>
139 asin(
const std::complex<_Tp>& __z)
140 {
return __complex_asin(__z); }
143 template<
typename _Tp>
145 __complex_atan(
const std::complex<_Tp>& __z)
147 const _Tp __r2 = __z.real() * __z.real();
148 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
150 _Tp __num = __z.imag() + _Tp(1.0);
151 _Tp __den = __z.imag() - _Tp(1.0);
153 __num = __r2 + __num * __num;
154 __den = __r2 + __den * __den;
156 return std::complex<_Tp>(_Tp(0.5) * atan2(_Tp(2.0) * __z.real(), __x),
157 _Tp(0.25) *
log(__num / __den));
160#if _GLIBCXX_USE_C99_COMPLEX_TR1
161 inline __complex__
float
162 __complex_atan(__complex__
float __z)
163 {
return __builtin_catanf(__z); }
165 inline __complex__
double
166 __complex_atan(__complex__
double __z)
167 {
return __builtin_catan(__z); }
169 inline __complex__
long double
170 __complex_atan(
const __complex__
long double& __z)
171 {
return __builtin_catanl(__z); }
173 template<
typename _Tp>
174 inline std::complex<_Tp>
175 atan(
const std::complex<_Tp>& __z)
176 {
return __complex_atan(__z.__rep()); }
181 template<
typename _Tp>
182 inline std::complex<_Tp>
183 atan(
const std::complex<_Tp>& __z)
184 {
return __complex_atan(__z); }
187 template<
typename _Tp>
189 __complex_acosh(
const std::complex<_Tp>& __z)
193 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
196#if _GLIBCXX_USE_C99_COMPLEX_TR1
197 inline __complex__
float
198 __complex_acosh(__complex__
float __z)
199 {
return __builtin_cacoshf(__z); }
201 inline __complex__
double
202 __complex_acosh(__complex__
double __z)
203 {
return __builtin_cacosh(__z); }
205 inline __complex__
long double
206 __complex_acosh(
const __complex__
long double& __z)
207 {
return __builtin_cacoshl(__z); }
209 template<
typename _Tp>
210 inline std::complex<_Tp>
211 acosh(
const std::complex<_Tp>& __z)
212 {
return __complex_acosh(__z.__rep()); }
217 template<
typename _Tp>
218 inline std::complex<_Tp>
219 acosh(
const std::complex<_Tp>& __z)
220 {
return __complex_acosh(__z); }
223 template<
typename _Tp>
225 __complex_asinh(
const std::complex<_Tp>& __z)
227 std::complex<_Tp> __t((__z.real() - __z.imag())
228 * (__z.real() + __z.imag()) + _Tp(1.0),
229 _Tp(2.0) * __z.real() * __z.imag());
235#if _GLIBCXX_USE_C99_COMPLEX_TR1
236 inline __complex__
float
237 __complex_asinh(__complex__
float __z)
238 {
return __builtin_casinhf(__z); }
240 inline __complex__
double
241 __complex_asinh(__complex__
double __z)
242 {
return __builtin_casinh(__z); }
244 inline __complex__
long double
245 __complex_asinh(
const __complex__
long double& __z)
246 {
return __builtin_casinhl(__z); }
248 template<
typename _Tp>
249 inline std::complex<_Tp>
250 asinh(
const std::complex<_Tp>& __z)
251 {
return __complex_asinh(__z.__rep()); }
256 template<
typename _Tp>
257 inline std::complex<_Tp>
258 asinh(
const std::complex<_Tp>& __z)
259 {
return __complex_asinh(__z); }
262 template<
typename _Tp>
264 __complex_atanh(
const std::complex<_Tp>& __z)
266 const _Tp __i2 = __z.imag() * __z.imag();
267 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
269 _Tp __num = _Tp(1.0) + __z.real();
270 _Tp __den = _Tp(1.0) - __z.real();
272 __num = __i2 + __num * __num;
273 __den = __i2 + __den * __den;
275 return std::complex<_Tp>(_Tp(0.25) * (
log(__num) -
log(__den)),
276 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
279#if _GLIBCXX_USE_C99_COMPLEX_TR1
280 inline __complex__
float
281 __complex_atanh(__complex__
float __z)
282 {
return __builtin_catanhf(__z); }
284 inline __complex__
double
285 __complex_atanh(__complex__
double __z)
286 {
return __builtin_catanh(__z); }
288 inline __complex__
long double
289 __complex_atanh(
const __complex__
long double& __z)
290 {
return __builtin_catanhl(__z); }
292 template<
typename _Tp>
293 inline std::complex<_Tp>
294 atanh(
const std::complex<_Tp>& __z)
295 {
return __complex_atanh(__z.__rep()); }
300 template<
typename _Tp>
301 inline std::complex<_Tp>
302 atanh(
const std::complex<_Tp>& __z)
303 {
return __complex_atanh(__z); }
308 template<
typename _Tp>
309 inline std::complex<_Tp>
317#if __cplusplus < 201103L
319 template<
typename _Tp>
320 inline typename __gnu_cxx::__promote<_Tp>::__type
323 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
324#if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
325 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
332 template<
typename _Tp>
333 inline typename __gnu_cxx::__promote<_Tp>::__type
337 template<
typename _Tp>
338 inline typename __gnu_cxx::__promote<_Tp>::__type
341 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
342 return __type(__x) * __type(__x);
345 template<
typename _Tp>
346 inline typename __gnu_cxx::__promote<_Tp>::__type
352 template<
typename _Tp,
typename _Up>
353 inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
356 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
360 template<
typename _Tp,
typename _Up>
364 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
368 template<
typename _Tp,
typename _Up>
372 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
379 template<
typename _Tp>
380 inline std::complex<_Tp>
381 conj(
const std::complex<_Tp>& __z)
384 template<
typename _Tp>
385 inline std::complex<typename __gnu_cxx::__promote<_Tp>::__type>
393 template<
typename _Tp,
typename _Up>
394 inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
395 polar(
const _Tp& __rho,
const _Up& __theta)
397 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
398 return std::polar(__type(__rho), __type(__theta));
403 template<
typename _Tp>
404 inline std::complex<_Tp>
405 pow(
const std::complex<_Tp>& __x,
const _Tp& __y)
408 template<
typename _Tp>
409 inline std::complex<_Tp>
410 pow(
const _Tp& __x,
const std::complex<_Tp>& __y)
413 template<
typename _Tp>
414 inline std::complex<_Tp>
415 pow(
const std::complex<_Tp>& __x,
const std::complex<_Tp>& __y)
421_GLIBCXX_END_NAMESPACE_VERSION
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
complex< _Tp > polar(const _Tp &, const _Tp &=0)
Return complex with magnitude rho and angle theta.
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
_Tp arg(const complex< _Tp > &)
Return phase angle of z.
constexpr complex< _Tp > conj(const complex< _Tp > &)
Return complex conjugate of z.
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
_Tp constexpr norm(const complex< _Tp > &)
Return z magnitude squared.
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
ISO C++ entities toplevel namespace is std.
ISO C++ TR1 entities toplevel namespace is std::tr1.
_Tp arg(const complex< _Tp > &)
Return phase angle of z.
_Tp constexpr norm(const complex< _Tp > &)
Return z magnitude squared.