Repository navigation
Commit c55a14e
authored
ENH: enable complex dtype support unconditionally (#790)
* WIP: ENH: enable complex dtype support unconditionally
This also gets rid of usage of the deprecated IF macro in Cython code,
which resolves a bunch of build warnings.
* BLD/ENH: support complex dtypes on MSVC, mirroring NumPy's approach
MSVC has no C99 `_Complex`; it provides the struct-based
`_Fcomplex`/`_Dcomplex` types, which have no arithmetic operators. Handle
this the way NumPy does (see npy_common.h/npy_math.h and the complex
check in numpy/_core/meson.build):
- common.h: typedef switch (`_Fcomplex`/`_Dcomplex` on MSVC, C99 complex
elsewhere) plus inline accessors that read via `creal` and write via
pointer punning, valid for every representation. A
PYWT_TEST_STRUCT_COMPLEX define forces NumPy's struct branch so the
MSVC code path can be compiled and tested with any compiler.
- convolution.template.c (the only complex arithmetic in the C core):
replace operators with type-generic helpers - ZERO/ADD/SUB/MUL and
ADD_PRODUCT(s, f, x) for `s += f * x`. The multiplier is always real,
so real and imaginary parts stay independent and codegen on
C99-complex compilers is unchanged.
- Cython boundary: declare float_complex/double_complex as opaque extern
typedefs in c_wt.pxd and cast explicitly at call sites, instead of
forcing -DCYTHON_CCOMPLEX=1; Cython >=3.2.5 picks the right complex
representation per compiler.
- meson: replace the have_c99_complex probe with NumPy's complex.h/type
checks, and drop the _c99_config machinery plus the remaining
real/imag-splitting fallbacks in _swt.py/_multidim.py.
The full test suite passes both normally and with the struct
representation forced (emulating MSVC semantics on Linux).
* CI: test the MSVC-style struct complex path on linux-aarch64
Build with -DPYWT_TEST_STRUCT_COMPLEX so the operator-free complex code
path that MSVC relies on is compiled and tested on every PR, not only in
the Windows wheel builds.
* DOC: clarify the PYWT_TEST_STRUCT_COMPLEX comment in common.h
* BLD: document why the Cython copy-tree must stay in meson.build
The generated config.pxi is gone, but the copies still provide the
rebuild dependency on .pxd files: Cython's -M depfiles (which Meson's
native Cython support relies on) do not record module-namespace cimports
such as 'from . cimport c_wt', so dropping the copy-tree would cause
stale builds after .pxd edits.22 files changed
Lines changed: 708 additions & 636 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
| |||
100 | 106 | | |
101 | 107 | | |
102 | 108 | | |
| 109 | + | |
| 110 | + | |
103 | 111 | | |
104 | 112 | | |
105 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | 163 | | |
171 | 164 | | |
172 | 165 | | |
| |||
241 | 234 | | |
242 | 235 | | |
243 | 236 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | 237 | | |
256 | 238 | | |
257 | 239 | | |
| |||
328 | 310 | | |
329 | 311 | | |
330 | 312 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | 313 | | |
335 | 314 | | |
336 | 315 | | |
| |||
387 | 366 | | |
388 | 367 | | |
389 | 368 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | 369 | | |
394 | 370 | | |
395 | 371 | | |
| |||
0 commit comments