OLD | NEW |
(Empty) | |
| 1 # NumPy math library |
| 2 # |
| 3 # This exports the functionality of the NumPy core math library, aka npymath, |
| 4 # which provides implementations of C99 math functions and macros for system |
| 5 # with a C89 library (such as MSVC). npymath is available with NumPy >=1.3, |
| 6 # although some functions will require later versions. The spacing function is |
| 7 # not in C99, but comes from Fortran. |
| 8 # |
| 9 # On the Cython side, the npymath functions are available without the "npy_" |
| 10 # prefix that they have in C, to make this is a drop-in replacement for |
| 11 # libc.math. The same is true for the constants, where possible. |
| 12 # |
| 13 # See the NumPy documentation for linking instructions. |
| 14 # |
| 15 # Complex number support and NumPy 2.0 half-precision functions are currently |
| 16 # not exported. |
| 17 # |
| 18 # Author: Lars Buitinck |
| 19 |
| 20 cdef extern from "numpy/npy_math.h" nogil: |
| 21 # Floating-point classification |
| 22 long double NAN "NPY_NAN" |
| 23 long double INFINITY "NPY_INFINITY" |
| 24 long double PZERO "NPY_PZERO" # positive zero |
| 25 long double NZERO "NPY_NZERO" # negative zero |
| 26 |
| 27 # These four are actually macros and work on any floating-point type. |
| 28 bint isfinite "npy_isfinite"(long double) |
| 29 bint isinf "npy_isinf"(long double) |
| 30 bint isnan "npy_isnan"(long double) |
| 31 bint signbit "npy_signbit"(long double) |
| 32 |
| 33 # Math constants |
| 34 long double E "NPY_E" |
| 35 long double LOG2E "NPY_LOG2E" # ln(e) / ln(2) |
| 36 long double LOG10E "NPY_LOG10E" # ln(e) / ln(10) |
| 37 long double LOGE2 "NPY_LOGE2" # ln(2) |
| 38 long double LOGE10 "NPY_LOGE10" # ln(10) |
| 39 long double PI "NPY_PI" |
| 40 long double PI_2 "NPY_PI_2" # pi / 2 |
| 41 long double PI_4 "NPY_PI_4" # pi / 4 |
| 42 long double NPY_1_PI # 1 / pi; NPY_ because of ident syntax |
| 43 long double NPY_2_PI # 2 / pi |
| 44 long double EULER "NPY_EULER" # Euler constant (gamma, 0.57721) |
| 45 |
| 46 # Low-level floating point manipulation (NumPy >=1.4) |
| 47 float copysignf "npy_copysignf"(float, float) |
| 48 float nextafterf "npy_nextafterf"(float x, float y) |
| 49 float spacingf "npy_spacingf"(float x) |
| 50 double copysign "npy_copysign"(double, double) |
| 51 double nextafter "npy_nextafter"(double x, double y) |
| 52 double spacing "npy_spacing"(double x) |
| 53 long double copysignl "npy_copysignl"(long double, long double) |
| 54 long double nextafterl "npy_nextafterl"(long double x, long double y) |
| 55 long double spacingl "npy_spacingl"(long double x) |
| 56 |
| 57 # Float C99 functions |
| 58 float sinf "npy_sinf"(float x) |
| 59 float cosf "npy_cosf"(float x) |
| 60 float tanf "npy_tanf"(float x) |
| 61 float sinhf "npy_sinhf"(float x) |
| 62 float coshf "npy_coshf"(float x) |
| 63 float tanhf "npy_tanhf"(float x) |
| 64 float fabsf "npy_fabsf"(float x) |
| 65 float floorf "npy_floorf"(float x) |
| 66 float ceilf "npy_ceilf"(float x) |
| 67 float rintf "npy_rintf"(float x) |
| 68 float sqrtf "npy_sqrtf"(float x) |
| 69 float log10f "npy_log10f"(float x) |
| 70 float logf "npy_logf"(float x) |
| 71 float expf "npy_expf"(float x) |
| 72 float expm1f "npy_expm1f"(float x) |
| 73 float asinf "npy_asinf"(float x) |
| 74 float acosf "npy_acosf"(float x) |
| 75 float atanf "npy_atanf"(float x) |
| 76 float asinhf "npy_asinhf"(float x) |
| 77 float acoshf "npy_acoshf"(float x) |
| 78 float atanhf "npy_atanhf"(float x) |
| 79 float log1pf "npy_log1pf"(float x) |
| 80 float exp2f "npy_exp2f"(float x) |
| 81 float log2f "npy_log2f"(float x) |
| 82 float atan2f "npy_atan2f"(float x) |
| 83 float hypotf "npy_hypotf"(float x) |
| 84 float powf "npy_powf"(float x) |
| 85 float fmodf "npy_fmodf"(float x) |
| 86 float modff "npy_modff"(float x) |
| 87 |
| 88 # Long double C99 functions |
| 89 long double sinl "npy_sinl"(long double x) |
| 90 long double cosl "npy_cosl"(long double x) |
| 91 long double tanl "npy_tanl"(long double x) |
| 92 long double sinhl "npy_sinhl"(long double x) |
| 93 long double coshl "npy_coshl"(long double x) |
| 94 long double tanhl "npy_tanhl"(long double x) |
| 95 long double fabsl "npy_fabsl"(long double x) |
| 96 long double floorl "npy_floorl"(long double x) |
| 97 long double ceill "npy_ceill"(long double x) |
| 98 long double rintl "npy_rintl"(long double x) |
| 99 long double sqrtl "npy_sqrtl"(long double x) |
| 100 long double log10l "npy_log10l"(long double x) |
| 101 long double logl "npy_logl"(long double x) |
| 102 long double expl "npy_expl"(long double x) |
| 103 long double expm1l "npy_expm1l"(long double x) |
| 104 long double asinl "npy_asinl"(long double x) |
| 105 long double acosl "npy_acosl"(long double x) |
| 106 long double atanl "npy_atanl"(long double x) |
| 107 long double asinhl "npy_asinhl"(long double x) |
| 108 long double acoshl "npy_acoshl"(long double x) |
| 109 long double atanhl "npy_atanhl"(long double x) |
| 110 long double log1pl "npy_log1pl"(long double x) |
| 111 long double exp2l "npy_exp2l"(long double x) |
| 112 long double log2l "npy_log2l"(long double x) |
| 113 long double atan2l "npy_atan2l"(long double x) |
| 114 long double hypotl "npy_hypotl"(long double x) |
| 115 long double powl "npy_powl"(long double x) |
| 116 long double fmodl "npy_fmodl"(long double x) |
| 117 long double modfl "npy_modfl"(long double x) |
| 118 |
| 119 # NumPy extensions |
| 120 float deg2radf "npy_deg2radf"(float x) |
| 121 float rad2degf "npy_rad2degf"(float x) |
| 122 float logaddexpf "npy_logaddexpf"(float x) |
| 123 float logaddexp2f "npy_logaddexp2f"(float x) |
| 124 |
| 125 double deg2rad "npy_deg2rad"(double x) |
| 126 double rad2deg "npy_rad2deg"(double x) |
| 127 double logaddexp "npy_logaddexp"(double x) |
| 128 double logaddexp2 "npy_logaddexp2"(double x) |
| 129 |
| 130 long double deg2radl "npy_deg2radl"(long double x) |
| 131 long double rad2degl "npy_rad2degl"(long double x) |
| 132 long double logaddexpl "npy_logaddexpl"(long double x) |
| 133 long double logaddexp2l "npy_logaddexp2l"(long double x) |
OLD | NEW |