29#ifndef _GLIBCXX_TR1_COMPLEX
30#define _GLIBCXX_TR1_COMPLEX 1
32#pragma GCC system_header
38namespace std _GLIBCXX_VISIBILITY(default)
40_GLIBCXX_BEGIN_NAMESPACE_VERSION
49#if __cplusplus >= 201103L
57 template<
typename _Tp> std::complex<_Tp> acos(
const std::complex<_Tp>&);
58 template<
typename _Tp> std::complex<_Tp> asin(
const std::complex<_Tp>&);
59 template<
typename _Tp> std::complex<_Tp> atan(
const std::complex<_Tp>&);
60 template<
typename _Tp> std::complex<_Tp> acosh(
const std::complex<_Tp>&);
61 template<
typename _Tp> std::complex<_Tp> asinh(
const std::complex<_Tp>&);
62 template<
typename _Tp> std::complex<_Tp> atanh(
const std::complex<_Tp>&);
66 template<
typename _Tp> std::complex<_Tp> fabs(
const std::complex<_Tp>&);
68#if __cplusplus < 201103L
69 template<
typename _Tp>
70 inline std::complex<_Tp>
71 __complex_acos(
const std::complex<_Tp>& __z)
73 const std::complex<_Tp> __t = std::tr1::asin(__z);
74 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
75 return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag());
78#if _GLIBCXX_USE_C99_COMPLEX_TR1
79 inline __complex__
float
80 __complex_acos(__complex__
float __z)
81 {
return __builtin_cacosf(__z); }
83 inline __complex__
double
84 __complex_acos(__complex__
double __z)
85 {
return __builtin_cacos(__z); }
87 inline __complex__
long double
88 __complex_acos(
const __complex__
long double& __z)
89 {
return __builtin_cacosl(__z); }
91 template<
typename _Tp>
92 inline std::complex<_Tp>
93 acos(
const std::complex<_Tp>& __z)
94 {
return __complex_acos(__z.__rep()); }
99 template<
typename _Tp>
100 inline std::complex<_Tp>
101 acos(
const std::complex<_Tp>& __z)
102 {
return __complex_acos(__z); }
105 template<
typename _Tp>
106 inline std::complex<_Tp>
107 __complex_asin(
const std::complex<_Tp>& __z)
109 std::complex<_Tp> __t(-__z.imag(), __z.real());
110 __t = std::tr1::asinh(__t);
111 return std::complex<_Tp>(__t.imag(), -__t.real());
114#if _GLIBCXX_USE_C99_COMPLEX_TR1
115 inline __complex__
float
116 __complex_asin(__complex__
float __z)
117 {
return __builtin_casinf(__z); }
119 inline __complex__
double
120 __complex_asin(__complex__
double __z)
121 {
return __builtin_casin(__z); }
123 inline __complex__
long double
124 __complex_asin(
const __complex__
long double& __z)
125 {
return __builtin_casinl(__z); }
127 template<
typename _Tp>
128 inline std::complex<_Tp>
129 asin(
const std::complex<_Tp>& __z)
130 {
return __complex_asin(__z.__rep()); }
135 template<
typename _Tp>
136 inline std::complex<_Tp>
137 asin(
const std::complex<_Tp>& __z)
138 {
return __complex_asin(__z); }
141 template<
typename _Tp>
143 __complex_atan(
const std::complex<_Tp>& __z)
145 const _Tp __r2 = __z.real() * __z.real();
146 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
148 _Tp __num = __z.imag() + _Tp(1.0);
149 _Tp __den = __z.imag() - _Tp(1.0);
151 __num = __r2 + __num * __num;
152 __den = __r2 + __den * __den;
154 return std::complex<_Tp>(_Tp(0.5) * atan2(_Tp(2.0) * __z.real(), __x),
155 _Tp(0.25) *
log(__num / __den));
158#if _GLIBCXX_USE_C99_COMPLEX_TR1
159 inline __complex__
float
160 __complex_atan(__complex__
float __z)
161 {
return __builtin_catanf(__z); }
163 inline __complex__
double
164 __complex_atan(__complex__
double __z)
165 {
return __builtin_catan(__z); }
167 inline __complex__
long double
168 __complex_atan(
const __complex__
long double& __z)
169 {
return __builtin_catanl(__z); }
171 template<
typename _Tp>
172 inline std::complex<_Tp>
173 atan(
const std::complex<_Tp>& __z)
174 {
return __complex_atan(__z.__rep()); }
179 template<
typename _Tp>
180 inline std::complex<_Tp>
181 atan(
const std::complex<_Tp>& __z)
182 {
return __complex_atan(__z); }
185 template<
typename _Tp>
187 __complex_acosh(
const std::complex<_Tp>& __z)
191 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
194#if _GLIBCXX_USE_C99_COMPLEX_TR1
195 inline __complex__
float
196 __complex_acosh(__complex__
float __z)
197 {
return __builtin_cacoshf(__z); }
199 inline __complex__
double
200 __complex_acosh(__complex__
double __z)
201 {
return __builtin_cacosh(__z); }
203 inline __complex__
long double
204 __complex_acosh(
const __complex__
long double& __z)
205 {
return __builtin_cacoshl(__z); }
207 template<
typename _Tp>
208 inline std::complex<_Tp>
209 acosh(
const std::complex<_Tp>& __z)
210 {
return __complex_acosh(__z.__rep()); }
215 template<
typename _Tp>
216 inline std::complex<_Tp>
217 acosh(
const std::complex<_Tp>& __z)
218 {
return __complex_acosh(__z); }
221 template<
typename _Tp>
223 __complex_asinh(
const std::complex<_Tp>& __z)
225 std::complex<_Tp> __t((__z.real() - __z.imag())
226 * (__z.real() + __z.imag()) + _Tp(1.0),
227 _Tp(2.0) * __z.real() * __z.imag());
233#if _GLIBCXX_USE_C99_COMPLEX_TR1
234 inline __complex__
float
235 __complex_asinh(__complex__
float __z)
236 {
return __builtin_casinhf(__z); }
238 inline __complex__
double
239 __complex_asinh(__complex__
double __z)
240 {
return __builtin_casinh(__z); }
242 inline __complex__
long double
243 __complex_asinh(
const __complex__
long double& __z)
244 {
return __builtin_casinhl(__z); }
246 template<
typename _Tp>
247 inline std::complex<_Tp>
248 asinh(
const std::complex<_Tp>& __z)
249 {
return __complex_asinh(__z.__rep()); }
254 template<
typename _Tp>
255 inline std::complex<_Tp>
256 asinh(
const std::complex<_Tp>& __z)
257 {
return __complex_asinh(__z); }
260 template<
typename _Tp>
262 __complex_atanh(
const std::complex<_Tp>& __z)
264 const _Tp __i2 = __z.imag() * __z.imag();
265 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
267 _Tp __num = _Tp(1.0) + __z.real();
268 _Tp __den = _Tp(1.0) - __z.real();
270 __num = __i2 + __num * __num;
271 __den = __i2 + __den * __den;
273 return std::complex<_Tp>(_Tp(0.25) * (
log(__num) -
log(__den)),
274 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
277#if _GLIBCXX_USE_C99_COMPLEX_TR1
278 inline __complex__
float
279 __complex_atanh(__complex__
float __z)
280 {
return __builtin_catanhf(__z); }
282 inline __complex__
double
283 __complex_atanh(__complex__
double __z)
284 {
return __builtin_catanh(__z); }
286 inline __complex__
long double
287 __complex_atanh(
const __complex__
long double& __z)
288 {
return __builtin_catanhl(__z); }
290 template<
typename _Tp>
291 inline std::complex<_Tp>
292 atanh(
const std::complex<_Tp>& __z)
293 {
return __complex_atanh(__z.__rep()); }
298 template<
typename _Tp>
299 inline std::complex<_Tp>
300 atanh(
const std::complex<_Tp>& __z)
301 {
return __complex_atanh(__z); }
306 template<
typename _Tp>
307 inline std::complex<_Tp>
315#if __cplusplus < 201103L
317 template<
typename _Tp>
318 inline typename __gnu_cxx::__promote<_Tp>::__type
321 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
322#if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
323 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
330 template<
typename _Tp>
331 inline typename __gnu_cxx::__promote<_Tp>::__type
335 template<
typename _Tp>
336 inline typename __gnu_cxx::__promote<_Tp>::__type
339 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
340 return __type(__x) * __type(__x);
343 template<
typename _Tp>
344 inline typename __gnu_cxx::__promote<_Tp>::__type
350 template<
typename _Tp,
typename _Up>
351 inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
354 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
358 template<
typename _Tp,
typename _Up>
362 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
366 template<
typename _Tp,
typename _Up>
370 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
377 template<
typename _Tp>
378 inline std::complex<_Tp>
379 conj(
const std::complex<_Tp>& __z)
382 template<
typename _Tp>
383 inline std::complex<typename __gnu_cxx::__promote<_Tp>::__type>
391 template<
typename _Tp,
typename _Up>
392 inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
393 polar(
const _Tp& __rho,
const _Up& __theta)
395 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
396 return std::polar(__type(__rho), __type(__theta));
401 template<
typename _Tp>
402 inline std::complex<_Tp>
403 pow(
const std::complex<_Tp>& __x,
const _Tp& __y)
406 template<
typename _Tp>
407 inline std::complex<_Tp>
408 pow(
const _Tp& __x,
const std::complex<_Tp>& __y)
411 template<
typename _Tp>
412 inline std::complex<_Tp>
413 pow(
const std::complex<_Tp>& __x,
const std::complex<_Tp>& __y)
419_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.