29 #ifndef _GLIBCXX_TR1_COMPLEX
30 #define _GLIBCXX_TR1_COMPLEX 1
32 #pragma GCC system_header
36 namespace std _GLIBCXX_VISIBILITY(default)
40 _GLIBCXX_BEGIN_NAMESPACE_VERSION
47 #if __cplusplus >= 201103L
64 #if __cplusplus < 201103L
65 template<
typename _Tp>
70 const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
74 #if _GLIBCXX_USE_C99_COMPLEX_TR1
75 inline __complex__
float
76 __complex_acos(__complex__
float __z)
77 {
return __builtin_cacosf(__z); }
79 inline __complex__
double
80 __complex_acos(__complex__
double __z)
81 {
return __builtin_cacos(__z); }
83 inline __complex__
long double
84 __complex_acos(
const __complex__
long double& __z)
85 {
return __builtin_cacosl(__z); }
87 template<
typename _Tp>
90 {
return __complex_acos(__z.__rep()); }
95 template<
typename _Tp>
98 {
return __complex_acos(__z); }
101 template<
typename _Tp>
110 #if _GLIBCXX_USE_C99_COMPLEX_TR1
111 inline __complex__
float
112 __complex_asin(__complex__
float __z)
113 {
return __builtin_casinf(__z); }
115 inline __complex__
double
116 __complex_asin(__complex__
double __z)
117 {
return __builtin_casin(__z); }
119 inline __complex__
long double
120 __complex_asin(
const __complex__
long double& __z)
121 {
return __builtin_casinl(__z); }
123 template<
typename _Tp>
126 {
return __complex_asin(__z.__rep()); }
131 template<
typename _Tp>
134 {
return __complex_asin(__z); }
137 template<
typename _Tp>
141 const _Tp __r2 = __z.real() * __z.real();
142 const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
144 _Tp __num = __z.imag() + _Tp(1.0);
145 _Tp __den = __z.imag() - _Tp(1.0);
147 __num = __r2 + __num * __num;
148 __den = __r2 + __den * __den;
151 _Tp(0.25) *
log(__num / __den));
154 #if _GLIBCXX_USE_C99_COMPLEX_TR1
155 inline __complex__
float
156 __complex_atan(__complex__
float __z)
157 {
return __builtin_catanf(__z); }
159 inline __complex__
double
160 __complex_atan(__complex__
double __z)
161 {
return __builtin_catan(__z); }
163 inline __complex__
long double
164 __complex_atan(
const __complex__
long double& __z)
165 {
return __builtin_catanl(__z); }
167 template<
typename _Tp>
170 {
return __complex_atan(__z.__rep()); }
175 template<
typename _Tp>
178 {
return __complex_atan(__z); }
183 template<
typename _Tp>
189 +
std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
192 #if _GLIBCXX_USE_C99_COMPLEX_TR1
193 inline __complex__
float
194 __complex_acosh(__complex__
float __z)
195 {
return __builtin_cacoshf(__z); }
197 inline __complex__
double
198 __complex_acosh(__complex__
double __z)
199 {
return __builtin_cacosh(__z); }
201 inline __complex__
long double
202 __complex_acosh(
const __complex__
long double& __z)
203 {
return __builtin_cacoshl(__z); }
205 template<
typename _Tp>
208 {
return __complex_acosh(__z.__rep()); }
213 template<
typename _Tp>
216 {
return __complex_acosh(__z); }
219 template<
typename _Tp>
224 * (__z.real() + __z.imag()) + _Tp(1.0),
225 _Tp(2.0) * __z.real() * __z.imag());
231 #if _GLIBCXX_USE_C99_COMPLEX_TR1
232 inline __complex__
float
233 __complex_asinh(__complex__
float __z)
234 {
return __builtin_casinhf(__z); }
236 inline __complex__
double
237 __complex_asinh(__complex__
double __z)
238 {
return __builtin_casinh(__z); }
240 inline __complex__
long double
241 __complex_asinh(
const __complex__
long double& __z)
242 {
return __builtin_casinhl(__z); }
244 template<
typename _Tp>
247 {
return __complex_asinh(__z.__rep()); }
252 template<
typename _Tp>
255 {
return __complex_asinh(__z); }
258 template<
typename _Tp>
262 const _Tp __i2 = __z.imag() * __z.imag();
263 const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
265 _Tp __num = _Tp(1.0) + __z.real();
266 _Tp __den = _Tp(1.0) - __z.real();
268 __num = __i2 + __num * __num;
269 __den = __i2 + __den * __den;
272 _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
275 #if _GLIBCXX_USE_C99_COMPLEX_TR1
276 inline __complex__
float
277 __complex_atanh(__complex__
float __z)
278 {
return __builtin_catanhf(__z); }
280 inline __complex__
double
281 __complex_atanh(__complex__
double __z)
282 {
return __builtin_catanh(__z); }
284 inline __complex__
long double
285 __complex_atanh(
const __complex__
long double& __z)
286 {
return __builtin_catanhl(__z); }
288 template<
typename _Tp>
291 {
return __complex_atanh(__z.__rep()); }
296 template<
typename _Tp>
299 {
return __complex_atanh(__z); }
302 template<
typename _Tp>
311 #if __cplusplus < 201103L
313 template<
typename _Tp>
314 inline typename __gnu_cxx::__promote<_Tp>::__type
317 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
318 #if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
319 return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
326 template<
typename _Tp>
327 inline typename __gnu_cxx::__promote<_Tp>::__type
331 template<
typename _Tp>
332 inline typename __gnu_cxx::__promote<_Tp>::__type
335 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
336 return __type(__x) * __type(__x);
339 template<
typename _Tp>
340 inline typename __gnu_cxx::__promote<_Tp>::__type
346 template<
typename _Tp,
typename _Up>
350 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
354 template<
typename _Tp,
typename _Up>
358 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
362 template<
typename _Tp,
typename _Up>
366 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
373 template<
typename _Tp>
378 template<
typename _Tp>
387 template<
typename _Tp,
typename _Up>
389 polar(
const _Tp& __rho,
const _Up& __theta)
391 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
392 return std::polar(__type(__rho), __type(__theta));
397 template<
typename _Tp>
402 template<
typename _Tp>
407 template<
typename _Tp>
414 _GLIBCXX_END_NAMESPACE_VERSION
418 #endif // _GLIBCXX_TR1_COMPLEX
std::complex< _Tp > atanh(const std::complex< _Tp > &)
atanh(__z) [8.1.7].
std::complex< _Tp > acosh(const std::complex< _Tp > &)
acosh(__z) [8.1.5].
std::complex< _Tp > asin(const std::complex< _Tp > &)
asin(__z) [8.1.3].
std::complex< _Tp > fabs(const std::complex< _Tp > &)
fabs(__z) [8.1.8].
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
_Tp norm(const complex< _Tp > &)
Return z magnitude squared.
std::complex< _Tp > asinh(const std::complex< _Tp > &)
asinh(__z) [8.1.6].
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.
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
_Tp arg(const complex< _Tp > &)
Return phase angle of z.
complex< _Tp > conj(const complex< _Tp > &)
Return complex conjugate of z.
std::complex< _Tp > atan(const std::complex< _Tp > &)
atan(__z) [8.1.4].
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.