ENH: use real FFTs for real-valued CWT convolution - #864
Open
ChS-YHWH wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
method="fft"and both the input data and the integrated wavelet kernel are real-valued, usenumpy.fft.rfftandnumpy.fft.irfftinstead of the full complexfftandifft.Complex-valued inputs or wavelets retain the existing complex FFT path. The public
cwtsignature, the defaultmethod="conv", coefficient shapes and dtypes, scale order, and input immutability are unchanged.Rationale
For real-valued data and kernels, the discrete Fourier transform is conjugate-symmetric. Computing only the non-redundant half-spectrum reduces FFT work and temporary frequency-domain storage without changing the convolution being evaluated.
Validation
1050 passed, 2 skipped.float32,float64,complex64, andcomplex128inputs;float64:1.33e-14float32:4.95e-6The small differences on real-valued inputs are expected floating-point roundoff from using a mathematically equivalent FFT representation and remain within the numerical precision of the corresponding dtype.
Performance
Local median timings were collected with the baseline and candidate interleaved in one process, CPU affinity fixed to one core, and numerical library threads limited to one.
These timings are local feasibility measurements, not a cross-machine performance guarantee.
Development note
This change was developed with AI assistance and was manually reviewed by the submitter. The tests and benchmark measurements reported above were run locally during preparation.