diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2023-05-13 11:02:49 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-13 11:02:49 -0600 |
commit | 5187067d7ad176ee3614beab2b99a524dd719aa8 (patch) | |
tree | 907997d0c294f550193322aaa73237c1a7bcfaa6 /numpy/core/include/numpy/npy_math.h | |
parent | b786189222ac5bf2f4efbb04399261f7f760bc18 (diff) | |
parent | 81caed6e3c34c4bf4b22b4f6167e816ba2a3f73c (diff) | |
download | numpy-5187067d7ad176ee3614beab2b99a524dd719aa8.tar.gz |
Merge branch 'main' into deprecate-find-common-type
Diffstat (limited to 'numpy/core/include/numpy/npy_math.h')
-rw-r--r-- | numpy/core/include/numpy/npy_math.h | 70 |
1 files changed, 22 insertions, 48 deletions
diff --git a/numpy/core/include/numpy/npy_math.h b/numpy/core/include/numpy/npy_math.h index 27e1ddad0..2fcd41eb0 100644 --- a/numpy/core/include/numpy/npy_math.h +++ b/numpy/core/include/numpy/npy_math.h @@ -8,7 +8,7 @@ /* By adding static inline specifiers to npy_math function definitions when appropriate, compiler is given the opportunity to optimize */ #if NPY_INLINE_MATH -#define NPY_INPLACE NPY_INLINE static +#define NPY_INPLACE static inline #else #define NPY_INPLACE #endif @@ -24,25 +24,25 @@ extern "C" { * * XXX: I should test whether INFINITY and NAN are available on the platform */ -NPY_INLINE static float __npy_inff(void) +static inline float __npy_inff(void) { const union { npy_uint32 __i; float __f;} __bint = {0x7f800000UL}; return __bint.__f; } -NPY_INLINE static float __npy_nanf(void) +static inline float __npy_nanf(void) { const union { npy_uint32 __i; float __f;} __bint = {0x7fc00000UL}; return __bint.__f; } -NPY_INLINE static float __npy_pzerof(void) +static inline float __npy_pzerof(void) { const union { npy_uint32 __i; float __f;} __bint = {0x00000000UL}; return __bint.__f; } -NPY_INLINE static float __npy_nzerof(void) +static inline float __npy_nzerof(void) { const union { npy_uint32 __i; float __f;} __bint = {0x80000000UL}; return __bint.__f; @@ -198,12 +198,12 @@ NPY_INPLACE double npy_atan2(double x, double y); #define npy_sqrt sqrt #define npy_pow pow #define npy_modf modf +#define npy_nextafter nextafter -double npy_nextafter(double x, double y); double npy_spacing(double x); /* - * IEEE 754 fpu handling. Those are guaranteed to be macros + * IEEE 754 fpu handling */ /* use builtins to avoid function calls in tight loops @@ -211,11 +211,7 @@ double npy_spacing(double x); #ifdef HAVE___BUILTIN_ISNAN #define npy_isnan(x) __builtin_isnan(x) #else - #ifndef NPY_HAVE_DECL_ISNAN - #define npy_isnan(x) ((x) != (x)) - #else - #define npy_isnan(x) isnan(x) - #endif + #define npy_isnan(x) isnan(x) #endif @@ -223,39 +219,17 @@ double npy_spacing(double x); #ifdef HAVE___BUILTIN_ISFINITE #define npy_isfinite(x) __builtin_isfinite(x) #else - #ifndef NPY_HAVE_DECL_ISFINITE - #ifdef _MSC_VER - #define npy_isfinite(x) _finite((x)) - #else - #define npy_isfinite(x) !npy_isnan((x) + (-x)) - #endif - #else - #define npy_isfinite(x) isfinite((x)) - #endif + #define npy_isfinite(x) isfinite((x)) #endif /* only available if npy_config.h is available (= numpys own build) */ #ifdef HAVE___BUILTIN_ISINF #define npy_isinf(x) __builtin_isinf(x) #else - #ifndef NPY_HAVE_DECL_ISINF - #define npy_isinf(x) (!npy_isfinite(x) && !npy_isnan(x)) - #else - #define npy_isinf(x) isinf((x)) - #endif + #define npy_isinf(x) isinf((x)) #endif -#ifndef NPY_HAVE_DECL_SIGNBIT - int _npy_signbit_f(float x); - int _npy_signbit_d(double x); - int _npy_signbit_ld(long double x); - #define npy_signbit(x) \ - (sizeof (x) == sizeof (long double) ? _npy_signbit_ld (x) \ - : sizeof (x) == sizeof (double) ? _npy_signbit_d (x) \ - : _npy_signbit_f (x)) -#else - #define npy_signbit(x) signbit((x)) -#endif +#define npy_signbit(x) signbit((x)) /* * float C99 math funcs that need fixups or are blocklist-able @@ -298,8 +272,8 @@ NPY_INPLACE float npy_modff(float x, float* y); #define npy_frexpf frexpf #define npy_ldexpf ldexpf #define npy_copysignf copysignf +#define npy_nextafterf nextafterf -float npy_nextafterf(float x, float y); float npy_spacingf(float x); /* @@ -342,8 +316,8 @@ NPY_INPLACE npy_longdouble npy_modfl(npy_longdouble x, npy_longdouble* y); #define npy_frexpl frexpl #define npy_ldexpl ldexpl #define npy_copysignl copysignl +#define npy_nextafterl nextafterl -npy_longdouble npy_nextafterl(npy_longdouble x, npy_longdouble y); npy_longdouble npy_spacingl(npy_longdouble x); /* @@ -399,17 +373,17 @@ NPY_INPLACE npy_longdouble npy_heavisidel(npy_longdouble x, npy_longdouble h0); \ return z1.z; -static NPY_INLINE npy_cdouble npy_cpack(double x, double y) +static inline npy_cdouble npy_cpack(double x, double y) { __NPY_CPACK_IMP(x, y, double, npy_cdouble); } -static NPY_INLINE npy_cfloat npy_cpackf(float x, float y) +static inline npy_cfloat npy_cpackf(float x, float y) { __NPY_CPACK_IMP(x, y, float, npy_cfloat); } -static NPY_INLINE npy_clongdouble npy_cpackl(npy_longdouble x, npy_longdouble y) +static inline npy_clongdouble npy_cpackl(npy_longdouble x, npy_longdouble y) { __NPY_CPACK_IMP(x, y, npy_longdouble, npy_clongdouble); } @@ -431,32 +405,32 @@ static NPY_INLINE npy_clongdouble npy_cpackl(npy_longdouble x, npy_longdouble y) \ return __z_repr.a[index]; -static NPY_INLINE double npy_creal(npy_cdouble z) +static inline double npy_creal(npy_cdouble z) { __NPY_CEXTRACT_IMP(z, 0, double, npy_cdouble); } -static NPY_INLINE double npy_cimag(npy_cdouble z) +static inline double npy_cimag(npy_cdouble z) { __NPY_CEXTRACT_IMP(z, 1, double, npy_cdouble); } -static NPY_INLINE float npy_crealf(npy_cfloat z) +static inline float npy_crealf(npy_cfloat z) { __NPY_CEXTRACT_IMP(z, 0, float, npy_cfloat); } -static NPY_INLINE float npy_cimagf(npy_cfloat z) +static inline float npy_cimagf(npy_cfloat z) { __NPY_CEXTRACT_IMP(z, 1, float, npy_cfloat); } -static NPY_INLINE npy_longdouble npy_creall(npy_clongdouble z) +static inline npy_longdouble npy_creall(npy_clongdouble z) { __NPY_CEXTRACT_IMP(z, 0, npy_longdouble, npy_clongdouble); } -static NPY_INLINE npy_longdouble npy_cimagl(npy_clongdouble z) +static inline npy_longdouble npy_cimagl(npy_clongdouble z) { __NPY_CEXTRACT_IMP(z, 1, npy_longdouble, npy_clongdouble); } |