This is a heavily modified implementation of FFTPack [1,2], with the following advantages:
- strictly C23 compliant with
-Wall -Wextra -Wpedantic -Werror - more accurate twiddle factor computation
- very fast plan generation
- worst case complexity for transform sizes with large prime factors is
N*log(N), because Bluestein's algorithm [3] is used for these cases.
3-clause BSD (see LICENSE)
- Debug build/test:
zig build test(C23 flags, warnings-as-errors). - Sanitized regression run:
just test(defaults tocc; override withCC=...; runstesting/tests.c). - Optimized build:
zig build release(ReleaseFast profile). - Artifacts install under
zig-out/.just testenables ASan, UBSan, and LSan on toolchains that support them.
Twiddle factor computation:
- making use of symmetries to reduce number of sin/cos evaluations
- all angles are reduced to the range
[0; pi/4]for higher accuracy - an adapted implementation of
sincospi()is used, which actually computessin(x)and(cos(x)-1). - if
nsin/cos pairs are required, the adjustedsincospi()is only called2*sqrt(n)times; the remaining values are obtained by evaluating the angle addition theorems in a numerically accurate way.
Parallel invocation:
- Plans only contain read-only data; all temporary arrays are allocated and deallocated during an individual FFT execution. This means that a single plan can be used in several threads at the same time.
Efficient codelets are available for the factors:
- 2, 3, 4, 5, 7, 11 for complex-valued FFTs
- 2, 3, 4, 5 for real-valued FFTs
Larger prime factors are handled by somewhat less efficient, generic routines.
For lengths with very large prime factors, Bluestein's algorithm is used, and
instead of an FFT of length n, a convolution of length n2 >= 2*n-1
is performed, where n2 is chosen to be highly composite.
[1] Swarztrauber, P. 1982, Vectorizing the Fast Fourier Transforms (New York: Academic Press), 51