30 #ifndef _GLIBCXX_TR1_COMPLEX
31 #define _GLIBCXX_TR1_COMPLEX 1
33 #pragma GCC system_header
37 namespace std _GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
48 #ifdef __GXX_EXPERIMENTAL_CXX0X__
65 #ifndef __GXX_EXPERIMENTAL_CXX0X__
66 template<
typename _Tp>
71 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
75 #if _GLIBCXX_USE_C99_COMPLEX_TR1
76 inline __complex__
float
77 __complex_acos(__complex__
float __z)
78 {
return __builtin_cacosf(__z); }
80 inline __complex__
double
81 __complex_acos(__complex__
double __z)
82 {
return __builtin_cacos(__z); }
84 inline __complex__
long double
85 __complex_acos(
const __complex__
long double& __z)
86 {
return __builtin_cacosl(__z); }
88 template<
typename _Tp>
91 {
return __complex_acos(__z.__rep()); }
96 template<
typename _Tp>
99 {
return __complex_acos(__z); }
102 template<
typename _Tp>
111 #if _GLIBCXX_USE_C99_COMPLEX_TR1
112 inline __complex__
float
113 __complex_asin(__complex__
float __z)
114 {
return __builtin_casinf(__z); }
116 inline __complex__
double
117 __complex_asin(__complex__
double __z)
118 {
return __builtin_casin(__z); }
120 inline __complex__
long double
121 __complex_asin(
const __complex__
long double& __z)
122 {
return __builtin_casinl(__z); }
124 template<
typename _Tp>
127 {
return __complex_asin(__z.__rep()); }
132 template<
typename _Tp>
135 {
return __complex_asin(__z); }
138 template<
typename _Tp>
142 const _Tp __r2 = __z.real() * __z.real();
143 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
145 _Tp __num = __z.imag() + _Tp(1.0);
146 _Tp __den = __z.imag() - _Tp(1.0);
148 __num = __r2 + __num * __num;
149 __den = __r2 + __den * __den;
152 _Tp(0.25) *
log(__num / __den));
155 #if _GLIBCXX_USE_C99_COMPLEX_TR1
156 inline __complex__
float
157 __complex_atan(__complex__
float __z)
158 {
return __builtin_catanf(__z); }
160 inline __complex__
double
161 __complex_atan(__complex__
double __z)
162 {
return __builtin_catan(__z); }
164 inline __complex__
long double
165 __complex_atan(
const __complex__
long double& __z)
166 {
return __builtin_catanl(__z); }
168 template<
typename _Tp>
171 {
return __complex_atan(__z.__rep()); }
176 template<
typename _Tp>
179 {
return __complex_atan(__z); }
182 #endif // __GXX_EXPERIMENTAL_CXX0X__
184 template<
typename _Tp>
190 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
193 #if _GLIBCXX_USE_C99_COMPLEX_TR1
194 inline __complex__
float
195 __complex_acosh(__complex__
float __z)
196 {
return __builtin_cacoshf(__z); }
198 inline __complex__
double
199 __complex_acosh(__complex__
double __z)
200 {
return __builtin_cacosh(__z); }
202 inline __complex__
long double
203 __complex_acosh(
const __complex__
long double& __z)
204 {
return __builtin_cacoshl(__z); }
206 template<
typename _Tp>
209 {
return __complex_acosh(__z.__rep()); }
214 template<
typename _Tp>
217 {
return __complex_acosh(__z); }
220 template<
typename _Tp>
225 * (__z.real() + __z.imag()) + _Tp(1.0),
226 _Tp(2.0) * __z.real() * __z.imag());
232 #if _GLIBCXX_USE_C99_COMPLEX_TR1
233 inline __complex__
float
234 __complex_asinh(__complex__
float __z)
235 {
return __builtin_casinhf(__z); }
237 inline __complex__
double
238 __complex_asinh(__complex__
double __z)
239 {
return __builtin_casinh(__z); }
241 inline __complex__
long double
242 __complex_asinh(
const __complex__
long double& __z)
243 {
return __builtin_casinhl(__z); }
245 template<
typename _Tp>
248 {
return __complex_asinh(__z.__rep()); }
253 template<
typename _Tp>
256 {
return __complex_asinh(__z); }
259 template<
typename _Tp>
263 const _Tp __i2 = __z.imag() * __z.imag();
264 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
266 _Tp __num = _Tp(1.0) + __z.real();
267 _Tp __den = _Tp(1.0) - __z.real();
269 __num = __i2 + __num * __num;
270 __den = __i2 + __den * __den;
273 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
276 #if _GLIBCXX_USE_C99_COMPLEX_TR1
277 inline __complex__
float
278 __complex_atanh(__complex__
float __z)
279 {
return __builtin_catanhf(__z); }
281 inline __complex__
double
282 __complex_atanh(__complex__
double __z)
283 {
return __builtin_catanh(__z); }
285 inline __complex__
long double
286 __complex_atanh(
const __complex__
long double& __z)
287 {
return __builtin_catanhl(__z); }
289 template<
typename _Tp>
292 {
return __complex_atanh(__z.__rep()); }
297 template<
typename _Tp>
300 {
return __complex_atanh(__z); }
303 template<
typename _Tp>
312 #ifndef __GXX_EXPERIMENTAL_CXX0X__
314 template<
typename _Tp>
315 inline typename __gnu_cxx::__promote<_Tp>::__type
318 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
319 #if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
320 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
327 template<
typename _Tp>
328 inline typename __gnu_cxx::__promote<_Tp>::__type
332 template<
typename _Tp>
333 inline typename __gnu_cxx::__promote<_Tp>::__type
336 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
337 return __type(__x) * __type(__x);
340 template<
typename _Tp>
341 inline typename __gnu_cxx::__promote<_Tp>::__type
347 template<
typename _Tp,
typename _Up>
351 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
355 template<
typename _Tp,
typename _Up>
359 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
363 template<
typename _Tp,
typename _Up>
367 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
374 template<
typename _Tp>
379 template<
typename _Tp>
388 template<
typename _Tp,
typename _Up>
390 polar(
const _Tp& __rho,
const _Up& __theta)
392 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
393 return std::polar(__type(__rho), __type(__theta));
398 template<
typename _Tp>
403 template<
typename _Tp>
408 template<
typename _Tp>
415 _GLIBCXX_END_NAMESPACE_VERSION
419 #endif // _GLIBCXX_TR1_COMPLEX
_Tp norm(const complex< _Tp > &)
Return z magnitude squared.
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
std::complex< _Tp > fabs(const std::complex< _Tp > &)
fabs(__z) [8.1.8].
complex< _Tp > conj(const complex< _Tp > &)
Return complex conjugate of z.
complex< _Tp > pow(const complex< _Tp > &, const _Tp &)
Return x to the y'th power.
std::complex< _Tp > asin(const std::complex< _Tp > &)
asin(__z) [8.1.3].
std::complex< _Tp > acos(const std::complex< _Tp > &)
acos(__z) [8.1.2].
complex< _Tp > polar(const _Tp &, const _Tp &=0)
Return complex with magnitude rho and angle theta.
std::complex< _Tp > asinh(const std::complex< _Tp > &)
asinh(__z) [8.1.6].
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
std::complex< _Tp > atan(const std::complex< _Tp > &)
atan(__z) [8.1.4].
std::complex< _Tp > acosh(const std::complex< _Tp > &)
acosh(__z) [8.1.5].
_Tp arg(const complex< _Tp > &)
Return phase angle of z.
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
std::complex< _Tp > atanh(const std::complex< _Tp > &)
atanh(__z) [8.1.7].