1
#ifndef __NPY_MATH_C99_H_
2
#define __NPY_MATH_C99_H_
3

4
#ifdef __cplusplus
5
extern "C" {
6
#endif
7

8
#include <math.h>
9
#ifdef __SUNPRO_CC
10
#include <sunmath.h>
11
#endif
12
#ifdef HAVE_NPY_CONFIG_H
13
#include <npy_config.h>
14
#endif
15
#include <numpy/npy_common.h>
16

17
/* By adding static inline specifiers to npy_math function definitions when
18
   appropriate, compiler is given the opportunity to optimize */
19
#if NPY_INLINE_MATH
20
#define NPY_INPLACE NPY_INLINE static
21
#else
22
#define NPY_INPLACE
23
#endif
24

25

26
/*
27
 * NAN and INFINITY like macros (same behavior as glibc for NAN, same as C99
28
 * for INFINITY)
29
 *
30
 * XXX: I should test whether INFINITY and NAN are available on the platform
31
 */
32
NPY_INLINE static float __npy_inff(void)
33
{
34 1
    const union { npy_uint32 __i; float __f;} __bint = {0x7f800000UL};
35
    return __bint.__f;
36
}
37

38
NPY_INLINE static float __npy_nanf(void)
39
{
40 1
    const union { npy_uint32 __i; float __f;} __bint = {0x7fc00000UL};
41
    return __bint.__f;
42
}
43

44
NPY_INLINE static float __npy_pzerof(void)
45
{
46 1
    const union { npy_uint32 __i; float __f;} __bint = {0x00000000UL};
47
    return __bint.__f;
48
}
49

50
NPY_INLINE static float __npy_nzerof(void)
51
{
52 1
    const union { npy_uint32 __i; float __f;} __bint = {0x80000000UL};
53
    return __bint.__f;
54
}
55

56
#define NPY_INFINITYF __npy_inff()
57
#define NPY_NANF __npy_nanf()
58
#define NPY_PZEROF __npy_pzerof()
59
#define NPY_NZEROF __npy_nzerof()
60

61
#define NPY_INFINITY ((npy_double)NPY_INFINITYF)
62
#define NPY_NAN ((npy_double)NPY_NANF)
63
#define NPY_PZERO ((npy_double)NPY_PZEROF)
64
#define NPY_NZERO ((npy_double)NPY_NZEROF)
65

66
#define NPY_INFINITYL ((npy_longdouble)NPY_INFINITYF)
67
#define NPY_NANL ((npy_longdouble)NPY_NANF)
68
#define NPY_PZEROL ((npy_longdouble)NPY_PZEROF)
69
#define NPY_NZEROL ((npy_longdouble)NPY_NZEROF)
70

71
/*
72
 * Useful constants
73
 */
74
#define NPY_E         2.718281828459045235360287471352662498  /* e */
75
#define NPY_LOG2E     1.442695040888963407359924681001892137  /* log_2 e */
76
#define NPY_LOG10E    0.434294481903251827651128918916605082  /* log_10 e */
77
#define NPY_LOGE2     0.693147180559945309417232121458176568  /* log_e 2 */
78
#define NPY_LOGE10    2.302585092994045684017991454684364208  /* log_e 10 */
79
#define NPY_PI        3.141592653589793238462643383279502884  /* pi */
80
#define NPY_PI_2      1.570796326794896619231321691639751442  /* pi/2 */
81
#define NPY_PI_4      0.785398163397448309615660845819875721  /* pi/4 */
82
#define NPY_1_PI      0.318309886183790671537767526745028724  /* 1/pi */
83
#define NPY_2_PI      0.636619772367581343075535053490057448  /* 2/pi */
84
#define NPY_EULER     0.577215664901532860606512090082402431  /* Euler constant */
85
#define NPY_SQRT2     1.414213562373095048801688724209698079  /* sqrt(2) */
86
#define NPY_SQRT1_2   0.707106781186547524400844362104849039  /* 1/sqrt(2) */
87

88
#define NPY_Ef        2.718281828459045235360287471352662498F /* e */
89
#define NPY_LOG2Ef    1.442695040888963407359924681001892137F /* log_2 e */
90
#define NPY_LOG10Ef   0.434294481903251827651128918916605082F /* log_10 e */
91
#define NPY_LOGE2f    0.693147180559945309417232121458176568F /* log_e 2 */
92
#define NPY_LOGE10f   2.302585092994045684017991454684364208F /* log_e 10 */
93
#define NPY_PIf       3.141592653589793238462643383279502884F /* pi */
94
#define NPY_PI_2f     1.570796326794896619231321691639751442F /* pi/2 */
95
#define NPY_PI_4f     0.785398163397448309615660845819875721F /* pi/4 */
96
#define NPY_1_PIf     0.318309886183790671537767526745028724F /* 1/pi */
97
#define NPY_2_PIf     0.636619772367581343075535053490057448F /* 2/pi */
98
#define NPY_EULERf    0.577215664901532860606512090082402431F /* Euler constant */
99
#define NPY_SQRT2f    1.414213562373095048801688724209698079F /* sqrt(2) */
100
#define NPY_SQRT1_2f  0.707106781186547524400844362104849039F /* 1/sqrt(2) */
101

102
#define NPY_El        2.718281828459045235360287471352662498L /* e */
103
#define NPY_LOG2El    1.442695040888963407359924681001892137L /* log_2 e */
104
#define NPY_LOG10El   0.434294481903251827651128918916605082L /* log_10 e */
105
#define NPY_LOGE2l    0.693147180559945309417232121458176568L /* log_e 2 */
106
#define NPY_LOGE10l   2.302585092994045684017991454684364208L /* log_e 10 */
107
#define NPY_PIl       3.141592653589793238462643383279502884L /* pi */
108
#define NPY_PI_2l     1.570796326794896619231321691639751442L /* pi/2 */
109
#define NPY_PI_4l     0.785398163397448309615660845819875721L /* pi/4 */
110
#define NPY_1_PIl     0.318309886183790671537767526745028724L /* 1/pi */
111
#define NPY_2_PIl     0.636619772367581343075535053490057448L /* 2/pi */
112
#define NPY_EULERl    0.577215664901532860606512090082402431L /* Euler constant */
113
#define NPY_SQRT2l    1.414213562373095048801688724209698079L /* sqrt(2) */
114
#define NPY_SQRT1_2l  0.707106781186547524400844362104849039L /* 1/sqrt(2) */
115

116
/*
117
 * Integer functions.
118
 */
119
NPY_INPLACE npy_uint npy_gcdu(npy_uint a, npy_uint b);
120
NPY_INPLACE npy_uint npy_lcmu(npy_uint a, npy_uint b);
121
NPY_INPLACE npy_ulong npy_gcdul(npy_ulong a, npy_ulong b);
122
NPY_INPLACE npy_ulong npy_lcmul(npy_ulong a, npy_ulong b);
123
NPY_INPLACE npy_ulonglong npy_gcdull(npy_ulonglong a, npy_ulonglong b);
124
NPY_INPLACE npy_ulonglong npy_lcmull(npy_ulonglong a, npy_ulonglong b);
125

126
NPY_INPLACE npy_int npy_gcd(npy_int a, npy_int b);
127
NPY_INPLACE npy_int npy_lcm(npy_int a, npy_int b);
128
NPY_INPLACE npy_long npy_gcdl(npy_long a, npy_long b);
129
NPY_INPLACE npy_long npy_lcml(npy_long a, npy_long b);
130
NPY_INPLACE npy_longlong npy_gcdll(npy_longlong a, npy_longlong b);
131
NPY_INPLACE npy_longlong npy_lcmll(npy_longlong a, npy_longlong b);
132

133
NPY_INPLACE npy_ubyte npy_rshiftuhh(npy_ubyte a, npy_ubyte b);
134
NPY_INPLACE npy_ubyte npy_lshiftuhh(npy_ubyte a, npy_ubyte b);
135
NPY_INPLACE npy_ushort npy_rshiftuh(npy_ushort a, npy_ushort b);
136
NPY_INPLACE npy_ushort npy_lshiftuh(npy_ushort a, npy_ushort b);
137
NPY_INPLACE npy_uint npy_rshiftu(npy_uint a, npy_uint b);
138
NPY_INPLACE npy_uint npy_lshiftu(npy_uint a, npy_uint b);
139
NPY_INPLACE npy_ulong npy_rshiftul(npy_ulong a, npy_ulong b);
140
NPY_INPLACE npy_ulong npy_lshiftul(npy_ulong a, npy_ulong b);
141
NPY_INPLACE npy_ulonglong npy_rshiftull(npy_ulonglong a, npy_ulonglong b);
142
NPY_INPLACE npy_ulonglong npy_lshiftull(npy_ulonglong a, npy_ulonglong b);
143

144
NPY_INPLACE npy_byte npy_rshifthh(npy_byte a, npy_byte b);
145
NPY_INPLACE npy_byte npy_lshifthh(npy_byte a, npy_byte b);
146
NPY_INPLACE npy_short npy_rshifth(npy_short a, npy_short b);
147
NPY_INPLACE npy_short npy_lshifth(npy_short a, npy_short b);
148
NPY_INPLACE npy_int npy_rshift(npy_int a, npy_int b);
149
NPY_INPLACE npy_int npy_lshift(npy_int a, npy_int b);
150
NPY_INPLACE npy_long npy_rshiftl(npy_long a, npy_long b);
151
NPY_INPLACE npy_long npy_lshiftl(npy_long a, npy_long b);
152
NPY_INPLACE npy_longlong npy_rshiftll(npy_longlong a, npy_longlong b);
153
NPY_INPLACE npy_longlong npy_lshiftll(npy_longlong a, npy_longlong b);
154

155
/*
156
 * avx function has a common API for both sin & cos. This enum is used to
157
 * distinguish between the two
158
 */
159
typedef enum {
160
    npy_compute_sin,
161
    npy_compute_cos
162
} NPY_TRIG_OP;
163

164
/*
165
 * C99 double math funcs
166
 */
167
NPY_INPLACE double npy_sin(double x);
168
NPY_INPLACE double npy_cos(double x);
169
NPY_INPLACE double npy_tan(double x);
170
NPY_INPLACE double npy_sinh(double x);
171
NPY_INPLACE double npy_cosh(double x);
172
NPY_INPLACE double npy_tanh(double x);
173

174
NPY_INPLACE double npy_asin(double x);
175
NPY_INPLACE double npy_acos(double x);
176
NPY_INPLACE double npy_atan(double x);
177

178
NPY_INPLACE double npy_log(double x);
179
NPY_INPLACE double npy_log10(double x);
180
NPY_INPLACE double npy_exp(double x);
181
NPY_INPLACE double npy_sqrt(double x);
182
NPY_INPLACE double npy_cbrt(double x);
183

184
NPY_INPLACE double npy_fabs(double x);
185
NPY_INPLACE double npy_ceil(double x);
186
NPY_INPLACE double npy_fmod(double x, double y);
187
NPY_INPLACE double npy_floor(double x);
188

189
NPY_INPLACE double npy_expm1(double x);
190
NPY_INPLACE double npy_log1p(double x);
191
NPY_INPLACE double npy_hypot(double x, double y);
192
NPY_INPLACE double npy_acosh(double x);
193
NPY_INPLACE double npy_asinh(double xx);
194
NPY_INPLACE double npy_atanh(double x);
195
NPY_INPLACE double npy_rint(double x);
196
NPY_INPLACE double npy_trunc(double x);
197
NPY_INPLACE double npy_exp2(double x);
198
NPY_INPLACE double npy_log2(double x);
199

200
NPY_INPLACE double npy_atan2(double x, double y);
201
NPY_INPLACE double npy_pow(double x, double y);
202
NPY_INPLACE double npy_modf(double x, double* y);
203
NPY_INPLACE double npy_frexp(double x, int* y);
204
NPY_INPLACE double npy_ldexp(double n, int y);
205

206
NPY_INPLACE double npy_copysign(double x, double y);
207
double npy_nextafter(double x, double y);
208
double npy_spacing(double x);
209

210
/*
211
 * IEEE 754 fpu handling. Those are guaranteed to be macros
212
 */
213

214
/* use builtins to avoid function calls in tight loops
215
 * only available if npy_config.h is available (= numpys own build) */
216
#if HAVE___BUILTIN_ISNAN
217
    #define npy_isnan(x) __builtin_isnan(x)
218
#else
219
    #ifndef NPY_HAVE_DECL_ISNAN
220
        #define npy_isnan(x) ((x) != (x))
221
    #else
222
        #if defined(_MSC_VER) && (_MSC_VER < 1900)
223
            #define npy_isnan(x) _isnan((x))
224
        #else
225
            #define npy_isnan(x) isnan(x)
226
        #endif
227
    #endif
228
#endif
229

230

231
/* only available if npy_config.h is available (= numpys own build) */
232
#if HAVE___BUILTIN_ISFINITE
233
    #define npy_isfinite(x) __builtin_isfinite(x)
234
#else
235
    #ifndef NPY_HAVE_DECL_ISFINITE
236
        #ifdef _MSC_VER
237
            #define npy_isfinite(x) _finite((x))
238
        #else
239
            #define npy_isfinite(x) !npy_isnan((x) + (-x))
240
        #endif
241
    #else
242
        #define npy_isfinite(x) isfinite((x))
243
    #endif
244
#endif
245

246
/* only available if npy_config.h is available (= numpys own build) */
247
#if HAVE___BUILTIN_ISINF
248
    #define npy_isinf(x) __builtin_isinf(x)
249
#else
250
    #ifndef NPY_HAVE_DECL_ISINF
251
        #define npy_isinf(x) (!npy_isfinite(x) && !npy_isnan(x))
252
    #else
253
        #if defined(_MSC_VER) && (_MSC_VER < 1900)
254
            #define npy_isinf(x) (!_finite((x)) && !_isnan((x)))
255
        #else
256
            #define npy_isinf(x) isinf((x))
257
        #endif
258
    #endif
259
#endif
260

261
#ifndef NPY_HAVE_DECL_SIGNBIT
262
    int _npy_signbit_f(float x);
263
    int _npy_signbit_d(double x);
264
    int _npy_signbit_ld(long double x);
265
    #define npy_signbit(x) \
266
        (sizeof (x) == sizeof (long double) ? _npy_signbit_ld (x) \
267
         : sizeof (x) == sizeof (double) ? _npy_signbit_d (x) \
268
         : _npy_signbit_f (x))
269
#else
270
    #define npy_signbit(x) signbit((x))
271
#endif
272

273
/*
274
 * float C99 math functions
275
 */
276
NPY_INPLACE float npy_sinf(float x);
277
NPY_INPLACE float npy_cosf(float x);
278
NPY_INPLACE float npy_tanf(float x);
279
NPY_INPLACE float npy_sinhf(float x);
280
NPY_INPLACE float npy_coshf(float x);
281
NPY_INPLACE float npy_tanhf(float x);
282
NPY_INPLACE float npy_fabsf(float x);
283
NPY_INPLACE float npy_floorf(float x);
284
NPY_INPLACE float npy_ceilf(float x);
285
NPY_INPLACE float npy_rintf(float x);
286
NPY_INPLACE float npy_truncf(float x);
287
NPY_INPLACE float npy_sqrtf(float x);
288
NPY_INPLACE float npy_cbrtf(float x);
289
NPY_INPLACE float npy_log10f(float x);
290
NPY_INPLACE float npy_logf(float x);
291
NPY_INPLACE float npy_expf(float x);
292
NPY_INPLACE float npy_expm1f(float x);
293
NPY_INPLACE float npy_asinf(float x);
294
NPY_INPLACE float npy_acosf(float x);
295
NPY_INPLACE float npy_atanf(float x);
296
NPY_INPLACE float npy_asinhf(float x);
297
NPY_INPLACE float npy_acoshf(float x);
298
NPY_INPLACE float npy_atanhf(float x);
299
NPY_INPLACE float npy_log1pf(float x);
300
NPY_INPLACE float npy_exp2f(float x);
301
NPY_INPLACE float npy_log2f(float x);
302

303
NPY_INPLACE float npy_atan2f(float x, float y);
304
NPY_INPLACE float npy_hypotf(float x, float y);
305
NPY_INPLACE float npy_powf(float x, float y);
306
NPY_INPLACE float npy_fmodf(float x, float y);
307

308
NPY_INPLACE float npy_modff(float x, float* y);
309
NPY_INPLACE float npy_frexpf(float x, int* y);
310
NPY_INPLACE float npy_ldexpf(float x, int y);
311

312
NPY_INPLACE float npy_copysignf(float x, float y);
313
float npy_nextafterf(float x, float y);
314
float npy_spacingf(float x);
315

316
/*
317
 * long double C99 math functions
318
 */
319
NPY_INPLACE npy_longdouble npy_sinl(npy_longdouble x);
320
NPY_INPLACE npy_longdouble npy_cosl(npy_longdouble x);
321
NPY_INPLACE npy_longdouble npy_tanl(npy_longdouble x);
322
NPY_INPLACE npy_longdouble npy_sinhl(npy_longdouble x);
323
NPY_INPLACE npy_longdouble npy_coshl(npy_longdouble x);
324
NPY_INPLACE npy_longdouble npy_tanhl(npy_longdouble x);
325
NPY_INPLACE npy_longdouble npy_fabsl(npy_longdouble x);
326
NPY_INPLACE npy_longdouble npy_floorl(npy_longdouble x);
327
NPY_INPLACE npy_longdouble npy_ceill(npy_longdouble x);
328
NPY_INPLACE npy_longdouble npy_rintl(npy_longdouble x);
329
NPY_INPLACE npy_longdouble npy_truncl(npy_longdouble x);
330
NPY_INPLACE npy_longdouble npy_sqrtl(npy_longdouble x);
331
NPY_INPLACE npy_longdouble npy_cbrtl(npy_longdouble x);
332
NPY_INPLACE npy_longdouble npy_log10l(npy_longdouble x);
333
NPY_INPLACE npy_longdouble npy_logl(npy_longdouble x);
334
NPY_INPLACE npy_longdouble npy_expl(npy_longdouble x);
335
NPY_INPLACE npy_longdouble npy_expm1l(npy_longdouble x);
336
NPY_INPLACE npy_longdouble npy_asinl(npy_longdouble x);
337
NPY_INPLACE npy_longdouble npy_acosl(npy_longdouble x);
338
NPY_INPLACE npy_longdouble npy_atanl(npy_longdouble x);
339
NPY_INPLACE npy_longdouble npy_asinhl(npy_longdouble x);
340
NPY_INPLACE npy_longdouble npy_acoshl(npy_longdouble x);
341
NPY_INPLACE npy_longdouble npy_atanhl(npy_longdouble x);
342
NPY_INPLACE npy_longdouble npy_log1pl(npy_longdouble x);
343
NPY_INPLACE npy_longdouble npy_exp2l(npy_longdouble x);
344
NPY_INPLACE npy_longdouble npy_log2l(npy_longdouble x);
345

346
NPY_INPLACE npy_longdouble npy_atan2l(npy_longdouble x, npy_longdouble y);
347
NPY_INPLACE npy_longdouble npy_hypotl(npy_longdouble x, npy_longdouble y);
348
NPY_INPLACE npy_longdouble npy_powl(npy_longdouble x, npy_longdouble y);
349
NPY_INPLACE npy_longdouble npy_fmodl(npy_longdouble x, npy_longdouble y);
350

351
NPY_INPLACE npy_longdouble npy_modfl(npy_longdouble x, npy_longdouble* y);
352
NPY_INPLACE npy_longdouble npy_frexpl(npy_longdouble x, int* y);
353
NPY_INPLACE npy_longdouble npy_ldexpl(npy_longdouble x, int y);
354

355
NPY_INPLACE npy_longdouble npy_copysignl(npy_longdouble x, npy_longdouble y);
356
npy_longdouble npy_nextafterl(npy_longdouble x, npy_longdouble y);
357
npy_longdouble npy_spacingl(npy_longdouble x);
358

359
/*
360
 * Non standard functions
361
 */
362
NPY_INPLACE double npy_deg2rad(double x);
363
NPY_INPLACE double npy_rad2deg(double x);
364
NPY_INPLACE double npy_logaddexp(double x, double y);
365
NPY_INPLACE double npy_logaddexp2(double x, double y);
366
NPY_INPLACE double npy_divmod(double x, double y, double *modulus);
367
NPY_INPLACE double npy_heaviside(double x, double h0);
368

369
NPY_INPLACE float npy_deg2radf(float x);
370
NPY_INPLACE float npy_rad2degf(float x);
371
NPY_INPLACE float npy_logaddexpf(float x, float y);
372
NPY_INPLACE float npy_logaddexp2f(float x, float y);
373
NPY_INPLACE float npy_divmodf(float x, float y, float *modulus);
374
NPY_INPLACE float npy_heavisidef(float x, float h0);
375

376
NPY_INPLACE npy_longdouble npy_deg2radl(npy_longdouble x);
377
NPY_INPLACE npy_longdouble npy_rad2degl(npy_longdouble x);
378
NPY_INPLACE npy_longdouble npy_logaddexpl(npy_longdouble x, npy_longdouble y);
379
NPY_INPLACE npy_longdouble npy_logaddexp2l(npy_longdouble x, npy_longdouble y);
380
NPY_INPLACE npy_longdouble npy_divmodl(npy_longdouble x, npy_longdouble y,
381
                           npy_longdouble *modulus);
382
NPY_INPLACE npy_longdouble npy_heavisidel(npy_longdouble x, npy_longdouble h0);
383

384
#define npy_degrees npy_rad2deg
385
#define npy_degreesf npy_rad2degf
386
#define npy_degreesl npy_rad2degl
387

388
#define npy_radians npy_deg2rad
389
#define npy_radiansf npy_deg2radf
390
#define npy_radiansl npy_deg2radl
391

392
/*
393
 * Complex declarations
394
 */
395

396
/*
397
 * C99 specifies that complex numbers have the same representation as
398
 * an array of two elements, where the first element is the real part
399
 * and the second element is the imaginary part.
400
 */
401
#define __NPY_CPACK_IMP(x, y, type, ctype)   \
402
    union {                                  \
403
        ctype z;                             \
404
        type a[2];                           \
405
    } z1;;                                   \
406
                                             \
407
    z1.a[0] = (x);                           \
408
    z1.a[1] = (y);                           \
409
                                             \
410
    return z1.z;
411

412
static NPY_INLINE npy_cdouble npy_cpack(double x, double y)
413
{
414 1
    __NPY_CPACK_IMP(x, y, double, npy_cdouble);
415
}
416

417
static NPY_INLINE npy_cfloat npy_cpackf(float x, float y)
418
{
419 1
    __NPY_CPACK_IMP(x, y, float, npy_cfloat);
420
}
421

422
static NPY_INLINE npy_clongdouble npy_cpackl(npy_longdouble x, npy_longdouble y)
423
{
424 1
    __NPY_CPACK_IMP(x, y, npy_longdouble, npy_clongdouble);
425
}
426
#undef __NPY_CPACK_IMP
427

428
/*
429
 * Same remark as above, but in the other direction: extract first/second
430
 * member of complex number, assuming a C99-compatible representation
431
 *
432
 * Those are defineds as static inline, and such as a reasonable compiler would
433
 * most likely compile this to one or two instructions (on CISC at least)
434
 */
435
#define __NPY_CEXTRACT_IMP(z, index, type, ctype)   \
436
    union {                                         \
437
        ctype z;                                    \
438
        type a[2];                                  \
439
    } __z_repr;                                     \
440
    __z_repr.z = z;                                 \
441
                                                    \
442
    return __z_repr.a[index];
443

444
static NPY_INLINE double npy_creal(npy_cdouble z)
445
{
446 1
    __NPY_CEXTRACT_IMP(z, 0, double, npy_cdouble);
447
}
448

449
static NPY_INLINE double npy_cimag(npy_cdouble z)
450
{
451 1
    __NPY_CEXTRACT_IMP(z, 1, double, npy_cdouble);
452
}
453

454
static NPY_INLINE float npy_crealf(npy_cfloat z)
455
{
456 1
    __NPY_CEXTRACT_IMP(z, 0, float, npy_cfloat);
457
}
458

459
static NPY_INLINE float npy_cimagf(npy_cfloat z)
460
{
461 1
    __NPY_CEXTRACT_IMP(z, 1, float, npy_cfloat);
462
}
463

464
static NPY_INLINE npy_longdouble npy_creall(npy_clongdouble z)
465
{
466 1
    __NPY_CEXTRACT_IMP(z, 0, npy_longdouble, npy_clongdouble);
467
}
468

469
static NPY_INLINE npy_longdouble npy_cimagl(npy_clongdouble z)
470
{
471 1
    __NPY_CEXTRACT_IMP(z, 1, npy_longdouble, npy_clongdouble);
472
}
473
#undef __NPY_CEXTRACT_IMP
474

475
/*
476
 * Double precision complex functions
477
 */
478
double npy_cabs(npy_cdouble z);
479
double npy_carg(npy_cdouble z);
480

481
npy_cdouble npy_cexp(npy_cdouble z);
482
npy_cdouble npy_clog(npy_cdouble z);
483
npy_cdouble npy_cpow(npy_cdouble x, npy_cdouble y);
484

485
npy_cdouble npy_csqrt(npy_cdouble z);
486

487
npy_cdouble npy_ccos(npy_cdouble z);
488
npy_cdouble npy_csin(npy_cdouble z);
489
npy_cdouble npy_ctan(npy_cdouble z);
490

491
npy_cdouble npy_ccosh(npy_cdouble z);
492
npy_cdouble npy_csinh(npy_cdouble z);
493
npy_cdouble npy_ctanh(npy_cdouble z);
494

495
npy_cdouble npy_cacos(npy_cdouble z);
496
npy_cdouble npy_casin(npy_cdouble z);
497
npy_cdouble npy_catan(npy_cdouble z);
498

499
npy_cdouble npy_cacosh(npy_cdouble z);
500
npy_cdouble npy_casinh(npy_cdouble z);
501
npy_cdouble npy_catanh(npy_cdouble z);
502

503
/*
504
 * Single precision complex functions
505
 */
506
float npy_cabsf(npy_cfloat z);
507
float npy_cargf(npy_cfloat z);
508

509
npy_cfloat npy_cexpf(npy_cfloat z);
510
npy_cfloat npy_clogf(npy_cfloat z);
511
npy_cfloat npy_cpowf(npy_cfloat x, npy_cfloat y);
512

513
npy_cfloat npy_csqrtf(npy_cfloat z);
514

515
npy_cfloat npy_ccosf(npy_cfloat z);
516
npy_cfloat npy_csinf(npy_cfloat z);
517
npy_cfloat npy_ctanf(npy_cfloat z);
518

519
npy_cfloat npy_ccoshf(npy_cfloat z);
520
npy_cfloat npy_csinhf(npy_cfloat z);
521
npy_cfloat npy_ctanhf(npy_cfloat z);
522

523
npy_cfloat npy_cacosf(npy_cfloat z);
524
npy_cfloat npy_casinf(npy_cfloat z);
525
npy_cfloat npy_catanf(npy_cfloat z);
526

527
npy_cfloat npy_cacoshf(npy_cfloat z);
528
npy_cfloat npy_casinhf(npy_cfloat z);
529
npy_cfloat npy_catanhf(npy_cfloat z);
530

531

532
/*
533
 * Extended precision complex functions
534
 */
535
npy_longdouble npy_cabsl(npy_clongdouble z);
536
npy_longdouble npy_cargl(npy_clongdouble z);
537

538
npy_clongdouble npy_cexpl(npy_clongdouble z);
539
npy_clongdouble npy_clogl(npy_clongdouble z);
540
npy_clongdouble npy_cpowl(npy_clongdouble x, npy_clongdouble y);
541

542
npy_clongdouble npy_csqrtl(npy_clongdouble z);
543

544
npy_clongdouble npy_ccosl(npy_clongdouble z);
545
npy_clongdouble npy_csinl(npy_clongdouble z);
546
npy_clongdouble npy_ctanl(npy_clongdouble z);
547

548
npy_clongdouble npy_ccoshl(npy_clongdouble z);
549
npy_clongdouble npy_csinhl(npy_clongdouble z);
550
npy_clongdouble npy_ctanhl(npy_clongdouble z);
551

552
npy_clongdouble npy_cacosl(npy_clongdouble z);
553
npy_clongdouble npy_casinl(npy_clongdouble z);
554
npy_clongdouble npy_catanl(npy_clongdouble z);
555

556
npy_clongdouble npy_cacoshl(npy_clongdouble z);
557
npy_clongdouble npy_casinhl(npy_clongdouble z);
558
npy_clongdouble npy_catanhl(npy_clongdouble z);
559

560

561
/*
562
 * Functions that set the floating point error
563
 * status word.
564
 */
565

566
/*
567
 * platform-dependent code translates floating point
568
 * status to an integer sum of these values
569
 */
570
#define NPY_FPE_DIVIDEBYZERO  1
571
#define NPY_FPE_OVERFLOW      2
572
#define NPY_FPE_UNDERFLOW     4
573
#define NPY_FPE_INVALID       8
574

575
int npy_clear_floatstatus_barrier(char*);
576
int npy_get_floatstatus_barrier(char*);
577
/*
578
 * use caution with these - clang and gcc8.1 are known to reorder calls
579
 * to this form of the function which can defeat the check. The _barrier
580
 * form of the call is preferable, where the argument is
581
 * (char*)&local_variable
582
 */
583
int npy_clear_floatstatus(void);
584
int npy_get_floatstatus(void);
585

586
void npy_set_floatstatus_divbyzero(void);
587
void npy_set_floatstatus_overflow(void);
588
void npy_set_floatstatus_underflow(void);
589
void npy_set_floatstatus_invalid(void);
590

591
#ifdef __cplusplus
592
}
593
#endif
594

595
#if NPY_INLINE_MATH
596
#include "npy_math_internal.h"
597
#endif
598

599
#endif

Read our documentation on viewing source code .

Loading