Skip to content

Commit

Permalink
Add complex compat header
Browse files Browse the repository at this point in the history
  • Loading branch information
lysnikolaou committed Jul 27, 2023
1 parent 04f4ce1 commit 991c4b1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions numpy/core/include/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ installed_headers = [
'numpy/ndarrayobject.h',
'numpy/ndarraytypes.h',
'numpy/npy_1_7_deprecated_api.h',
'numpy/npy_2_complexcompat.h',
'numpy/npy_3kcompat.h',
'numpy/npy_common.h',
'numpy/npy_cpu.h',
Expand Down
27 changes: 27 additions & 0 deletions numpy/core/include/numpy/npy_2_complexcompat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* This header is designed to be copy-pasted into downstream packages, since it provides
a compatibility layer between the old C struct complex types and the new native C99
complex types. */
#ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_2_COMPLEXCOMPAT_H_
#define NUMPY_CORE_INCLUDE_NUMPY_NPY_2_COMPLEXCOMPAT_H_

#include <numpy/numpyconfig.h>

#if (defined(NPY_TARGET_VERSION) && NPY_TARGET_VERSION >= 0x00000012) || (NPY_FEATURE_VERSION >= 0x00000012) /* Numpy 2.0 */
#include <numpy/npy_math.h>

#define NPY_CSETREALF(c, r) npy_csetrealf(c, r)
#define NPY_CSETIMAGF(c, i) npy_csetimagf(c, i)
#define NPY_CSETREAL(c, r) npy_csetreal(c, r)
#define NPY_CSETIMAG(c, i) npy_csetimag(c, i)
#define NPY_CSETREALL(c, r) npy_csetreall(c, r)
#define NPY_CSETIMAGL(c, i) npy_csetimagl(c, i)
#else
#define NPY_CSETREALF(c, r) (c)->real = (r)
#define NPY_CSETIMAGF(c, i) (c)->imag = (i)
#define NPY_CSETREAL(c, r) (c)->real = (r)
#define NPY_CSETIMAG(c, i) (c)->imag = (i)
#define NPY_CSETREALL(c, r) (c)->real = (r)
#define NPY_CSETIMAGL(c, i) (c)->imag = (i)
#endif

#endif

0 comments on commit 991c4b1

Please sign in to comment.