1 #ifndef __NPY_MATH_C99_H_
2 #define __NPY_MATH_C99_H_
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <numpy/npy_common.h>
9 
10 #include <math.h>
11 #ifdef __SUNPRO_CC
12 #include <sunmath.h>
13 #endif
14 
15 /* By adding static inline specifiers to npy_math function definitions when
16    appropriate, compiler is given the opportunity to optimize */
17 #if NPY_INLINE_MATH
18 #define NPY_INPLACE NPY_INLINE static
19 #else
20 #define NPY_INPLACE
21 #endif
22 
23 
24 /*
25  * NAN and INFINITY like macros (same behavior as glibc for NAN, same as C99
26  * for INFINITY)
27  *
28  * XXX: I should test whether INFINITY and NAN are available on the platform
29  */
__npy_inff(void)30 NPY_INLINE static float __npy_inff(void)
31 {
32     const union { npy_uint32 __i; float __f;} __bint = {0x7f800000UL};
33     return __bint.__f;
34 }
35 
__npy_nanf(void)36 NPY_INLINE static float __npy_nanf(void)
37 {
38     const union { npy_uint32 __i; float __f;} __bint = {0x7fc00000UL};
39     return __bint.__f;
40 }
41 
__npy_pzerof(void)42 NPY_INLINE static float __npy_pzerof(void)
43 {
44     const union { npy_uint32 __i; float __f;} __bint = {0x00000000UL};
45     return __bint.__f;
46 }
47 
__npy_nzerof(void)48 NPY_INLINE static float __npy_nzerof(void)
49 {
50     const union { npy_uint32 __i; float __f;} __bint = {0x80000000UL};
51     return __bint.__f;
52 }
53 
54 #define NPY_INFINITYF __npy_inff()
55 #define NPY_NANF __npy_nanf()
56 #define NPY_PZEROF __npy_pzerof()
57 #define NPY_NZEROF __npy_nzerof()
58 
59 #define NPY_INFINITY ((npy_double)NPY_INFINITYF)
60 #define NPY_NAN ((npy_double)NPY_NANF)
61 #define NPY_PZERO ((npy_double)NPY_PZEROF)
62 #define NPY_NZERO ((npy_double)NPY_NZEROF)
63 
64 #define NPY_INFINITYL ((npy_longdouble)NPY_INFINITYF)
65 #define NPY_NANL ((npy_longdouble)NPY_NANF)
66 #define NPY_PZEROL ((npy_longdouble)NPY_PZEROF)
67 #define NPY_NZEROL ((npy_longdouble)NPY_NZEROF)
68 
69 /*
70  * Useful constants
71  */
72 #define NPY_E         2.718281828459045235360287471352662498  /* e */
73 #define NPY_LOG2E     1.442695040888963407359924681001892137  /* log_2 e */
74 #define NPY_LOG10E    0.434294481903251827651128918916605082  /* log_10 e */
75 #define NPY_LOGE2     0.693147180559945309417232121458176568  /* log_e 2 */
76 #define NPY_LOGE10    2.302585092994045684017991454684364208  /* log_e 10 */
77 #define NPY_PI        3.141592653589793238462643383279502884  /* pi */
78 #define NPY_PI_2      1.570796326794896619231321691639751442  /* pi/2 */
79 #define NPY_PI_4      0.785398163397448309615660845819875721  /* pi/4 */
80 #define NPY_1_PI      0.318309886183790671537767526745028724  /* 1/pi */
81 #define NPY_2_PI      0.636619772367581343075535053490057448  /* 2/pi */
82 #define NPY_EULER     0.577215664901532860606512090082402431  /* Euler constant */
83 #define NPY_SQRT2     1.414213562373095048801688724209698079  /* sqrt(2) */
84 #define NPY_SQRT1_2   0.707106781186547524400844362104849039  /* 1/sqrt(2) */
85 
86 #define NPY_Ef        2.718281828459045235360287471352662498F /* e */
87 #define NPY_LOG2Ef    1.442695040888963407359924681001892137F /* log_2 e */
88 #define NPY_LOG10Ef   0.434294481903251827651128918916605082F /* log_10 e */
89 #define NPY_LOGE2f    0.693147180559945309417232121458176568F /* log_e 2 */
90 #define NPY_LOGE10f   2.302585092994045684017991454684364208F /* log_e 10 */
91 #define NPY_PIf       3.141592653589793238462643383279502884F /* pi */
92 #define NPY_PI_2f     1.570796326794896619231321691639751442F /* pi/2 */
93 #define NPY_PI_4f     0.785398163397448309615660845819875721F /* pi/4 */
94 #define NPY_1_PIf     0.318309886183790671537767526745028724F /* 1/pi */
95 #define NPY_2_PIf     0.636619772367581343075535053490057448F /* 2/pi */
96 #define NPY_EULERf    0.577215664901532860606512090082402431F /* Euler constant */
97 #define NPY_SQRT2f    1.414213562373095048801688724209698079F /* sqrt(2) */
98 #define NPY_SQRT1_2f  0.707106781186547524400844362104849039F /* 1/sqrt(2) */
99 
100 #define NPY_El        2.718281828459045235360287471352662498L /* e */
101 #define NPY_LOG2El    1.442695040888963407359924681001892137L /* log_2 e */
102 #define NPY_LOG10El   0.434294481903251827651128918916605082L /* log_10 e */
103 #define NPY_LOGE2l    0.693147180559945309417232121458176568L /* log_e 2 */
104 #define NPY_LOGE10l   2.302585092994045684017991454684364208L /* log_e 10 */
105 #define NPY_PIl       3.141592653589793238462643383279502884L /* pi */
106 #define NPY_PI_2l     1.570796326794896619231321691639751442L /* pi/2 */
107 #define NPY_PI_4l     0.785398163397448309615660845819875721L /* pi/4 */
108 #define NPY_1_PIl     0.318309886183790671537767526745028724L /* 1/pi */
109 #define NPY_2_PIl     0.636619772367581343075535053490057448L /* 2/pi */
110 #define NPY_EULERl    0.577215664901532860606512090082402431L /* Euler constant */
111 #define NPY_SQRT2l    1.414213562373095048801688724209698079L /* sqrt(2) */
112 #define NPY_SQRT1_2l  0.707106781186547524400844362104849039L /* 1/sqrt(2) */
113 
114 /*
115  * Integer functions.
116  */
117 NPY_INPLACE npy_uint npy_gcdu(npy_uint a, npy_uint b);
118 NPY_INPLACE npy_uint npy_lcmu(npy_uint a, npy_uint b);
119 NPY_INPLACE npy_ulong npy_gcdul(npy_ulong a, npy_ulong b);
120 NPY_INPLACE npy_ulong npy_lcmul(npy_ulong a, npy_ulong b);
121 NPY_INPLACE npy_ulonglong npy_gcdull(npy_ulonglong a, npy_ulonglong b);
122 NPY_INPLACE npy_ulonglong npy_lcmull(npy_ulonglong a, npy_ulonglong b);
123 
124 NPY_INPLACE npy_int npy_gcd(npy_int a, npy_int b);
125 NPY_INPLACE npy_int npy_lcm(npy_int a, npy_int b);
126 NPY_INPLACE npy_long npy_gcdl(npy_long a, npy_long b);
127 NPY_INPLACE npy_long npy_lcml(npy_long a, npy_long b);
128 NPY_INPLACE npy_longlong npy_gcdll(npy_longlong a, npy_longlong b);
129 NPY_INPLACE npy_longlong npy_lcmll(npy_longlong a, npy_longlong b);
130 
131 NPY_INPLACE npy_ubyte npy_rshiftuhh(npy_ubyte a, npy_ubyte b);
132 NPY_INPLACE npy_ubyte npy_lshiftuhh(npy_ubyte a, npy_ubyte b);
133 NPY_INPLACE npy_ushort npy_rshiftuh(npy_ushort a, npy_ushort b);
134 NPY_INPLACE npy_ushort npy_lshiftuh(npy_ushort a, npy_ushort b);
135 NPY_INPLACE npy_uint npy_rshiftu(npy_uint a, npy_uint b);
136 NPY_INPLACE npy_uint npy_lshiftu(npy_uint a, npy_uint b);
137 NPY_INPLACE npy_ulong npy_rshiftul(npy_ulong a, npy_ulong b);
138 NPY_INPLACE npy_ulong npy_lshiftul(npy_ulong a, npy_ulong b);
139 NPY_INPLACE npy_ulonglong npy_rshiftull(npy_ulonglong a, npy_ulonglong b);
140 NPY_INPLACE npy_ulonglong npy_lshiftull(npy_ulonglong a, npy_ulonglong b);
141 
142 NPY_INPLACE npy_byte npy_rshifthh(npy_byte a, npy_byte b);
143 NPY_INPLACE npy_byte npy_lshifthh(npy_byte a, npy_byte b);
144 NPY_INPLACE npy_short npy_rshifth(npy_short a, npy_short b);
145 NPY_INPLACE npy_short npy_lshifth(npy_short a, npy_short b);
146 NPY_INPLACE npy_int npy_rshift(npy_int a, npy_int b);
147 NPY_INPLACE npy_int npy_lshift(npy_int a, npy_int b);
148 NPY_INPLACE npy_long npy_rshiftl(npy_long a, npy_long b);
149 NPY_INPLACE npy_long npy_lshiftl(npy_long a, npy_long b);
150 NPY_INPLACE npy_longlong npy_rshiftll(npy_longlong a, npy_longlong b);
151 NPY_INPLACE npy_longlong npy_lshiftll(npy_longlong a, npy_longlong b);
152 
153 /*
154  * avx function has a common API for both sin & cos. This enum is used to
155  * distinguish between the two
156  */
157 typedef enum {
158     npy_compute_sin,
159     npy_compute_cos
160 } NPY_TRIG_OP;
161 
162 /*
163  * C99 double math funcs
164  */
165 NPY_INPLACE double npy_sin(double x);
166 NPY_INPLACE double npy_cos(double x);
167 NPY_INPLACE double npy_tan(double x);
168 NPY_INPLACE double npy_sinh(double x);
169 NPY_INPLACE double npy_cosh(double x);
170 NPY_INPLACE double npy_tanh(double x);
171 
172 NPY_INPLACE double npy_asin(double x);
173 NPY_INPLACE double npy_acos(double x);
174 NPY_INPLACE double npy_atan(double x);
175 
176 NPY_INPLACE double npy_log(double x);
177 NPY_INPLACE double npy_log10(double x);
178 NPY_INPLACE double npy_exp(double x);
179 NPY_INPLACE double npy_sqrt(double x);
180 NPY_INPLACE double npy_cbrt(double x);
181 
182 NPY_INPLACE double npy_fabs(double x);
183 NPY_INPLACE double npy_ceil(double x);
184 NPY_INPLACE double npy_fmod(double x, double y);
185 NPY_INPLACE double npy_floor(double x);
186 
187 NPY_INPLACE double npy_expm1(double x);
188 NPY_INPLACE double npy_log1p(double x);
189 NPY_INPLACE double npy_hypot(double x, double y);
190 NPY_INPLACE double npy_acosh(double x);
191 NPY_INPLACE double npy_asinh(double xx);
192 NPY_INPLACE double npy_atanh(double x);
193 NPY_INPLACE double npy_rint(double x);
194 NPY_INPLACE double npy_trunc(double x);
195 NPY_INPLACE double npy_exp2(double x);
196 NPY_INPLACE double npy_log2(double x);
197 
198 NPY_INPLACE double npy_atan2(double x, double y);
199 NPY_INPLACE double npy_pow(double x, double y);
200 NPY_INPLACE double npy_modf(double x, double* y);
201 NPY_INPLACE double npy_frexp(double x, int* y);
202 NPY_INPLACE double npy_ldexp(double n, int y);
203 
204 NPY_INPLACE double npy_copysign(double x, double y);
205 double npy_nextafter(double x, double y);
206 double npy_spacing(double x);
207 
208 /*
209  * IEEE 754 fpu handling. Those are guaranteed to be macros
210  */
211 
212 /* use builtins to avoid function calls in tight loops
213  * only available if npy_config.h is available (= numpys own build) */
214 #if HAVE___BUILTIN_ISNAN
215     #define npy_isnan(x) __builtin_isnan(x)
216 #else
217     #ifndef NPY_HAVE_DECL_ISNAN
218         #define npy_isnan(x) ((x) != (x))
219     #else
220         #if defined(_MSC_VER) && (_MSC_VER < 1900)
221             #define npy_isnan(x) _isnan((x))
222         #else
223             #define npy_isnan(x) isnan(x)
224         #endif
225     #endif
226 #endif
227 
228 
229 /* only available if npy_config.h is available (= numpys own build) */
230 #if HAVE___BUILTIN_ISFINITE
231     #define npy_isfinite(x) __builtin_isfinite(x)
232 #else
233     #ifndef NPY_HAVE_DECL_ISFINITE
234         #ifdef _MSC_VER
235             #define npy_isfinite(x) _finite((x))
236         #else
237             #define npy_isfinite(x) !npy_isnan((x) + (-x))
238         #endif
239     #else
240         #define npy_isfinite(x) isfinite((x))
241     #endif
242 #endif
243 
244 /* only available if npy_config.h is available (= numpys own build) */
245 #if HAVE___BUILTIN_ISINF
246     #define npy_isinf(x) __builtin_isinf(x)
247 #else
248     #ifndef NPY_HAVE_DECL_ISINF
249         #define npy_isinf(x) (!npy_isfinite(x) && !npy_isnan(x))
250     #else
251         #if defined(_MSC_VER) && (_MSC_VER < 1900)
252             #define npy_isinf(x) (!_finite((x)) && !_isnan((x)))
253         #else
254             #define npy_isinf(x) isinf((x))
255         #endif
256     #endif
257 #endif
258 
259 #ifndef NPY_HAVE_DECL_SIGNBIT
260     int _npy_signbit_f(float x);
261     int _npy_signbit_d(double x);
262     int _npy_signbit_ld(long double x);
263     #define npy_signbit(x) \
264         (sizeof (x) == sizeof (long double) ? _npy_signbit_ld (x) \
265          : sizeof (x) == sizeof (double) ? _npy_signbit_d (x) \
266          : _npy_signbit_f (x))
267 #else
268     #define npy_signbit(x) signbit((x))
269 #endif
270 
271 /*
272  * float C99 math functions
273  */
274 NPY_INPLACE float npy_sinf(float x);
275 NPY_INPLACE float npy_cosf(float x);
276 NPY_INPLACE float npy_tanf(float x);
277 NPY_INPLACE float npy_sinhf(float x);
278 NPY_INPLACE float npy_coshf(float x);
279 NPY_INPLACE float npy_tanhf(float x);
280 NPY_INPLACE float npy_fabsf(float x);
281 NPY_INPLACE float npy_floorf(float x);
282 NPY_INPLACE float npy_ceilf(float x);
283 NPY_INPLACE float npy_rintf(float x);
284 NPY_INPLACE float npy_truncf(float x);
285 NPY_INPLACE float npy_sqrtf(float x);
286 NPY_INPLACE float npy_cbrtf(float x);
287 NPY_INPLACE float npy_log10f(float x);
288 NPY_INPLACE float npy_logf(float x);
289 NPY_INPLACE float npy_expf(float x);
290 NPY_INPLACE float npy_expm1f(float x);
291 NPY_INPLACE float npy_asinf(float x);
292 NPY_INPLACE float npy_acosf(float x);
293 NPY_INPLACE float npy_atanf(float x);
294 NPY_INPLACE float npy_asinhf(float x);
295 NPY_INPLACE float npy_acoshf(float x);
296 NPY_INPLACE float npy_atanhf(float x);
297 NPY_INPLACE float npy_log1pf(float x);
298 NPY_INPLACE float npy_exp2f(float x);
299 NPY_INPLACE float npy_log2f(float x);
300 
301 NPY_INPLACE float npy_atan2f(float x, float y);
302 NPY_INPLACE float npy_hypotf(float x, float y);
303 NPY_INPLACE float npy_powf(float x, float y);
304 NPY_INPLACE float npy_fmodf(float x, float y);
305 
306 NPY_INPLACE float npy_modff(float x, float* y);
307 NPY_INPLACE float npy_frexpf(float x, int* y);
308 NPY_INPLACE float npy_ldexpf(float x, int y);
309 
310 NPY_INPLACE float npy_copysignf(float x, float y);
311 float npy_nextafterf(float x, float y);
312 float npy_spacingf(float x);
313 
314 /*
315  * long double C99 math functions
316  */
317 NPY_INPLACE npy_longdouble npy_sinl(npy_longdouble x);
318 NPY_INPLACE npy_longdouble npy_cosl(npy_longdouble x);
319 NPY_INPLACE npy_longdouble npy_tanl(npy_longdouble x);
320 NPY_INPLACE npy_longdouble npy_sinhl(npy_longdouble x);
321 NPY_INPLACE npy_longdouble npy_coshl(npy_longdouble x);
322 NPY_INPLACE npy_longdouble npy_tanhl(npy_longdouble x);
323 NPY_INPLACE npy_longdouble npy_fabsl(npy_longdouble x);
324 NPY_INPLACE npy_longdouble npy_floorl(npy_longdouble x);
325 NPY_INPLACE npy_longdouble npy_ceill(npy_longdouble x);
326 NPY_INPLACE npy_longdouble npy_rintl(npy_longdouble x);
327 NPY_INPLACE npy_longdouble npy_truncl(npy_longdouble x);
328 NPY_INPLACE npy_longdouble npy_sqrtl(npy_longdouble x);
329 NPY_INPLACE npy_longdouble npy_cbrtl(npy_longdouble x);
330 NPY_INPLACE npy_longdouble npy_log10l(npy_longdouble x);
331 NPY_INPLACE npy_longdouble npy_logl(npy_longdouble x);
332 NPY_INPLACE npy_longdouble npy_expl(npy_longdouble x);
333 NPY_INPLACE npy_longdouble npy_expm1l(npy_longdouble x);
334 NPY_INPLACE npy_longdouble npy_asinl(npy_longdouble x);
335 NPY_INPLACE npy_longdouble npy_acosl(npy_longdouble x);
336 NPY_INPLACE npy_longdouble npy_atanl(npy_longdouble x);
337 NPY_INPLACE npy_longdouble npy_asinhl(npy_longdouble x);
338 NPY_INPLACE npy_longdouble npy_acoshl(npy_longdouble x);
339 NPY_INPLACE npy_longdouble npy_atanhl(npy_longdouble x);
340 NPY_INPLACE npy_longdouble npy_log1pl(npy_longdouble x);
341 NPY_INPLACE npy_longdouble npy_exp2l(npy_longdouble x);
342 NPY_INPLACE npy_longdouble npy_log2l(npy_longdouble x);
343 
344 NPY_INPLACE npy_longdouble npy_atan2l(npy_longdouble x, npy_longdouble y);
345 NPY_INPLACE npy_longdouble npy_hypotl(npy_longdouble x, npy_longdouble y);
346 NPY_INPLACE npy_longdouble npy_powl(npy_longdouble x, npy_longdouble y);
347 NPY_INPLACE npy_longdouble npy_fmodl(npy_longdouble x, npy_longdouble y);
348 
349 NPY_INPLACE npy_longdouble npy_modfl(npy_longdouble x, npy_longdouble* y);
350 NPY_INPLACE npy_longdouble npy_frexpl(npy_longdouble x, int* y);
351 NPY_INPLACE npy_longdouble npy_ldexpl(npy_longdouble x, int y);
352 
353 NPY_INPLACE npy_longdouble npy_copysignl(npy_longdouble x, npy_longdouble y);
354 npy_longdouble npy_nextafterl(npy_longdouble x, npy_longdouble y);
355 npy_longdouble npy_spacingl(npy_longdouble x);
356 
357 /*
358  * Non standard functions
359  */
360 NPY_INPLACE double npy_deg2rad(double x);
361 NPY_INPLACE double npy_rad2deg(double x);
362 NPY_INPLACE double npy_logaddexp(double x, double y);
363 NPY_INPLACE double npy_logaddexp2(double x, double y);
364 NPY_INPLACE double npy_divmod(double x, double y, double *modulus);
365 NPY_INPLACE double npy_heaviside(double x, double h0);
366 
367 NPY_INPLACE float npy_deg2radf(float x);
368 NPY_INPLACE float npy_rad2degf(float x);
369 NPY_INPLACE float npy_logaddexpf(float x, float y);
370 NPY_INPLACE float npy_logaddexp2f(float x, float y);
371 NPY_INPLACE float npy_divmodf(float x, float y, float *modulus);
372 NPY_INPLACE float npy_heavisidef(float x, float h0);
373 
374 NPY_INPLACE npy_longdouble npy_deg2radl(npy_longdouble x);
375 NPY_INPLACE npy_longdouble npy_rad2degl(npy_longdouble x);
376 NPY_INPLACE npy_longdouble npy_logaddexpl(npy_longdouble x, npy_longdouble y);
377 NPY_INPLACE npy_longdouble npy_logaddexp2l(npy_longdouble x, npy_longdouble y);
378 NPY_INPLACE npy_longdouble npy_divmodl(npy_longdouble x, npy_longdouble y,
379                            npy_longdouble *modulus);
380 NPY_INPLACE npy_longdouble npy_heavisidel(npy_longdouble x, npy_longdouble h0);
381 
382 #define npy_degrees npy_rad2deg
383 #define npy_degreesf npy_rad2degf
384 #define npy_degreesl npy_rad2degl
385 
386 #define npy_radians npy_deg2rad
387 #define npy_radiansf npy_deg2radf
388 #define npy_radiansl npy_deg2radl
389 
390 /*
391  * Complex declarations
392  */
393 
394 /*
395  * C99 specifies that complex numbers have the same representation as
396  * an array of two elements, where the first element is the real part
397  * and the second element is the imaginary part.
398  */
399 #define __NPY_CPACK_IMP(x, y, type, ctype)   \
400     union {                                  \
401         ctype z;                             \
402         type a[2];                           \
403     } z1;;                                   \
404                                              \
405     z1.a[0] = (x);                           \
406     z1.a[1] = (y);                           \
407                                              \
408     return z1.z;
409 
npy_cpack(double x,double y)410 static NPY_INLINE npy_cdouble npy_cpack(double x, double y)
411 {
412     __NPY_CPACK_IMP(x, y, double, npy_cdouble);
413 }
414 
npy_cpackf(float x,float y)415 static NPY_INLINE npy_cfloat npy_cpackf(float x, float y)
416 {
417     __NPY_CPACK_IMP(x, y, float, npy_cfloat);
418 }
419 
npy_cpackl(npy_longdouble x,npy_longdouble y)420 static NPY_INLINE npy_clongdouble npy_cpackl(npy_longdouble x, npy_longdouble y)
421 {
422     __NPY_CPACK_IMP(x, y, npy_longdouble, npy_clongdouble);
423 }
424 #undef __NPY_CPACK_IMP
425 
426 /*
427  * Same remark as above, but in the other direction: extract first/second
428  * member of complex number, assuming a C99-compatible representation
429  *
430  * Those are defineds as static inline, and such as a reasonable compiler would
431  * most likely compile this to one or two instructions (on CISC at least)
432  */
433 #define __NPY_CEXTRACT_IMP(z, index, type, ctype)   \
434     union {                                         \
435         ctype z;                                    \
436         type a[2];                                  \
437     } __z_repr;                                     \
438     __z_repr.z = z;                                 \
439                                                     \
440     return __z_repr.a[index];
441 
npy_creal(npy_cdouble z)442 static NPY_INLINE double npy_creal(npy_cdouble z)
443 {
444     __NPY_CEXTRACT_IMP(z, 0, double, npy_cdouble);
445 }
446 
npy_cimag(npy_cdouble z)447 static NPY_INLINE double npy_cimag(npy_cdouble z)
448 {
449     __NPY_CEXTRACT_IMP(z, 1, double, npy_cdouble);
450 }
451 
npy_crealf(npy_cfloat z)452 static NPY_INLINE float npy_crealf(npy_cfloat z)
453 {
454     __NPY_CEXTRACT_IMP(z, 0, float, npy_cfloat);
455 }
456 
npy_cimagf(npy_cfloat z)457 static NPY_INLINE float npy_cimagf(npy_cfloat z)
458 {
459     __NPY_CEXTRACT_IMP(z, 1, float, npy_cfloat);
460 }
461 
npy_creall(npy_clongdouble z)462 static NPY_INLINE npy_longdouble npy_creall(npy_clongdouble z)
463 {
464     __NPY_CEXTRACT_IMP(z, 0, npy_longdouble, npy_clongdouble);
465 }
466 
npy_cimagl(npy_clongdouble z)467 static NPY_INLINE npy_longdouble npy_cimagl(npy_clongdouble z)
468 {
469     __NPY_CEXTRACT_IMP(z, 1, npy_longdouble, npy_clongdouble);
470 }
471 #undef __NPY_CEXTRACT_IMP
472 
473 /*
474  * Double precision complex functions
475  */
476 double npy_cabs(npy_cdouble z);
477 double npy_carg(npy_cdouble z);
478 
479 npy_cdouble npy_cexp(npy_cdouble z);
480 npy_cdouble npy_clog(npy_cdouble z);
481 npy_cdouble npy_cpow(npy_cdouble x, npy_cdouble y);
482 
483 npy_cdouble npy_csqrt(npy_cdouble z);
484 
485 npy_cdouble npy_ccos(npy_cdouble z);
486 npy_cdouble npy_csin(npy_cdouble z);
487 npy_cdouble npy_ctan(npy_cdouble z);
488 
489 npy_cdouble npy_ccosh(npy_cdouble z);
490 npy_cdouble npy_csinh(npy_cdouble z);
491 npy_cdouble npy_ctanh(npy_cdouble z);
492 
493 npy_cdouble npy_cacos(npy_cdouble z);
494 npy_cdouble npy_casin(npy_cdouble z);
495 npy_cdouble npy_catan(npy_cdouble z);
496 
497 npy_cdouble npy_cacosh(npy_cdouble z);
498 npy_cdouble npy_casinh(npy_cdouble z);
499 npy_cdouble npy_catanh(npy_cdouble z);
500 
501 /*
502  * Single precision complex functions
503  */
504 float npy_cabsf(npy_cfloat z);
505 float npy_cargf(npy_cfloat z);
506 
507 npy_cfloat npy_cexpf(npy_cfloat z);
508 npy_cfloat npy_clogf(npy_cfloat z);
509 npy_cfloat npy_cpowf(npy_cfloat x, npy_cfloat y);
510 
511 npy_cfloat npy_csqrtf(npy_cfloat z);
512 
513 npy_cfloat npy_ccosf(npy_cfloat z);
514 npy_cfloat npy_csinf(npy_cfloat z);
515 npy_cfloat npy_ctanf(npy_cfloat z);
516 
517 npy_cfloat npy_ccoshf(npy_cfloat z);
518 npy_cfloat npy_csinhf(npy_cfloat z);
519 npy_cfloat npy_ctanhf(npy_cfloat z);
520 
521 npy_cfloat npy_cacosf(npy_cfloat z);
522 npy_cfloat npy_casinf(npy_cfloat z);
523 npy_cfloat npy_catanf(npy_cfloat z);
524 
525 npy_cfloat npy_cacoshf(npy_cfloat z);
526 npy_cfloat npy_casinhf(npy_cfloat z);
527 npy_cfloat npy_catanhf(npy_cfloat z);
528 
529 
530 /*
531  * Extended precision complex functions
532  */
533 npy_longdouble npy_cabsl(npy_clongdouble z);
534 npy_longdouble npy_cargl(npy_clongdouble z);
535 
536 npy_clongdouble npy_cexpl(npy_clongdouble z);
537 npy_clongdouble npy_clogl(npy_clongdouble z);
538 npy_clongdouble npy_cpowl(npy_clongdouble x, npy_clongdouble y);
539 
540 npy_clongdouble npy_csqrtl(npy_clongdouble z);
541 
542 npy_clongdouble npy_ccosl(npy_clongdouble z);
543 npy_clongdouble npy_csinl(npy_clongdouble z);
544 npy_clongdouble npy_ctanl(npy_clongdouble z);
545 
546 npy_clongdouble npy_ccoshl(npy_clongdouble z);
547 npy_clongdouble npy_csinhl(npy_clongdouble z);
548 npy_clongdouble npy_ctanhl(npy_clongdouble z);
549 
550 npy_clongdouble npy_cacosl(npy_clongdouble z);
551 npy_clongdouble npy_casinl(npy_clongdouble z);
552 npy_clongdouble npy_catanl(npy_clongdouble z);
553 
554 npy_clongdouble npy_cacoshl(npy_clongdouble z);
555 npy_clongdouble npy_casinhl(npy_clongdouble z);
556 npy_clongdouble npy_catanhl(npy_clongdouble z);
557 
558 
559 /*
560  * Functions that set the floating point error
561  * status word.
562  */
563 
564 /*
565  * platform-dependent code translates floating point
566  * status to an integer sum of these values
567  */
568 #define NPY_FPE_DIVIDEBYZERO  1
569 #define NPY_FPE_OVERFLOW      2
570 #define NPY_FPE_UNDERFLOW     4
571 #define NPY_FPE_INVALID       8
572 
573 int npy_clear_floatstatus_barrier(char*);
574 int npy_get_floatstatus_barrier(char*);
575 /*
576  * use caution with these - clang and gcc8.1 are known to reorder calls
577  * to this form of the function which can defeat the check. The _barrier
578  * form of the call is preferable, where the argument is
579  * (char*)&local_variable
580  */
581 int npy_clear_floatstatus(void);
582 int npy_get_floatstatus(void);
583 
584 void npy_set_floatstatus_divbyzero(void);
585 void npy_set_floatstatus_overflow(void);
586 void npy_set_floatstatus_underflow(void);
587 void npy_set_floatstatus_invalid(void);
588 
589 #ifdef __cplusplus
590 }
591 #endif
592 
593 #if NPY_INLINE_MATH
594 #include "npy_math_internal.h"
595 #endif
596 
597 #endif
598