diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2022-09-27 19:03:59 +0200 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2022-09-28 14:57:11 +0200 |
commit | 05e213e85d165a74b11fe38a7fb95a48494f8c5f (patch) | |
tree | 91b9d3472114cbc8a892d1c6e529aad6922430f1 /numpy/core | |
parent | c6366c16844b162749dca5aab5f8541b319d99c9 (diff) | |
download | numpy-05e213e85d165a74b11fe38a7fb95a48494f8c5f.tar.gz |
BLD: Add mandatory complex math feature detection with signature
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/feature_detection_cmath.h | 41 | ||||
-rw-r--r-- | numpy/core/setup.py | 12 | ||||
-rw-r--r-- | numpy/core/setup_common.py | 4 |
3 files changed, 52 insertions, 5 deletions
diff --git a/numpy/core/feature_detection_cmath.h b/numpy/core/feature_detection_cmath.h new file mode 100644 index 000000000..ce9a3d4c9 --- /dev/null +++ b/numpy/core/feature_detection_cmath.h @@ -0,0 +1,41 @@ +#include <complex.h> + +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) +#define cfloat _Fcomplex +#define cdouble _Dcomplex +#define cldouble _Lcomplex +#else +#define cfloat complex float +#define cdouble complex double +#define cldouble complex long double +#endif + +cfloat csinf(cfloat); +cfloat ccosf(cfloat); +cfloat ctanf(cfloat); +cfloat csinhf(cfloat); +cfloat ccoshf(cfloat); +cfloat ctanhf(cfloat); +float crealf(cfloat); +float cimagf(cfloat); +cfloat conjf(cfloat); + +cdouble csin(cdouble); +cdouble ccos(cdouble); +cdouble ctan(cdouble); +cdouble csinh(cdouble); +cdouble ccosh(cdouble); +cdouble ctanh(cdouble); +double creal(cdouble); +double cimag(cdouble); +cdouble conj(cdouble); + +cldouble csinl(cldouble); +cldouble ccosl(cldouble); +cldouble ctanl(cldouble); +cldouble csinhl(cldouble); +cldouble ccoshl(cldouble); +cldouble ctanhl(cldouble); +long double creall(cldouble); +long double cimagl(cldouble); +cldouble conjl(cldouble); diff --git a/numpy/core/setup.py b/numpy/core/setup.py index fc09dba8b..49ec29489 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -134,7 +134,7 @@ def check_math_capabilities(config, ext, moredefs, mathlibs): def check_func( func_name, decl=False, - headers=["feature_detection_math.h"], + headers=["feature_detection_math.h", "feature_detection_cmath.h"], ): return config.check_func( func_name, @@ -145,8 +145,10 @@ def check_math_capabilities(config, ext, moredefs, mathlibs): headers=headers, ) - def check_funcs_once(funcs_name, headers=["feature_detection_math.h"], - add_to_moredefs=True): + def check_funcs_once( + funcs_name, + headers=["feature_detection_math.h", "feature_detection_cmath.h"], + add_to_moredefs=True): call = dict([(f, True) for f in funcs_name]) call_args = dict([(f, FUNC_CALL_ARGS[f]) for f in funcs_name]) st = config.check_funcs_once( @@ -161,7 +163,9 @@ def check_math_capabilities(config, ext, moredefs, mathlibs): moredefs.extend([(fname2def(f), 1) for f in funcs_name]) return st - def check_funcs(funcs_name, headers=["feature_detection_math.h"]): + def check_funcs( + funcs_name, + headers=["feature_detection_math.h", "feature_detection_cmath.h"]): # Use check_funcs_once first, and if it does not work, test func per # func. Return success only if all the functions are available if not check_funcs_once(funcs_name, headers=headers): diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py index 0c727a913..a8497fe75 100644 --- a/numpy/core/setup_common.py +++ b/numpy/core/setup_common.py @@ -102,12 +102,14 @@ def set_sig(sig): args = args.rpartition(")")[0] funcname = prefix.rpartition(" ")[-1] args = [arg.strip() for arg in args.split(",")] - FUNC_CALL_ARGS[funcname] = ", ".join("(%s) 0" % arg for arg in args) + # We use {0} because 0 alone cannot be cast to complex on MSVC in C: + FUNC_CALL_ARGS[funcname] = ", ".join("(%s){0}" % arg for arg in args) for file in [ "feature_detection_locale.h", "feature_detection_math.h", + "feature_detection_cmath.h", "feature_detection_misc.h", "feature_detection_stdio.h", ]: |