Skip to content

Rework BDCT into first-class BODFT primitive with iterative scheduling#42

Merged
falseywinchnet merged 1 commit into
mainfrom
bodft-kernel
Jun 23, 2026
Merged

Rework BDCT into first-class BODFT primitive with iterative scheduling#42
falseywinchnet merged 1 commit into
mainfrom
bodft-kernel

Conversation

@falseywinchnet

Copy link
Copy Markdown
Owner

Reframes the half-bin transform as BODFT (Bruun odd-frequency DFT), a first-class half-bin spectral primitive, and removes all DCT-I..IV framing and code. BODFT computes

H[k] = sum_n x[n] exp(-2*pi*i*(k+1/2)*n/N)

for real input -- the spectrum sampled halfway between the ordinary FFT bins -- emitting the packed lower half H[0..N/2-1].

Changes:

  • Rename kernel/API bdct -> bodft (namespace bodft, bodft::plan/plan_f32, C ABI bodft_plan/bodft_forward/bodft_inverse[_f32], C++ bfft::bodft).
  • Strip the DCT-IV path entirely (dctiv_plan, DCT-IV API, dctiv benchmark).
  • Replace the recursion with iterative scheduling: a build-time radix-4 digit-reversal permutation drives one leaf pass, then log4(N) ping-pong combine passes run leaves-up (forward) / top-down (inverse). This also improves locality (forward ~20% faster than the recursion at large N).
  • Forward and inverse are first class in both float and double. Forward uses the explicit 128-bit SoA SIMD combine (V2 double, V4F float, FMA, portable SSE+NEON); inverse is the exact algebraic inverse (scalar).
  • Precomputed t, t^2, t^3 twiddle tables (three muls per combine, no derivation chain).

Validation: examples/bodft_benchmark.cpp checks both precisions across N=2..8192 -- forward vs direct DFT, exact impulse phase, exact inverse roundtrip (~1e-16 double, ~1e-7 float). Warning-clean under -Wall -Wextra -Wpedantic; existing make test suite still passes.

Reframes the half-bin transform as BODFT (Bruun odd-frequency DFT), a
first-class half-bin spectral primitive, and removes all DCT-I..IV framing
and code. BODFT computes

    H[k] = sum_n x[n] exp(-2*pi*i*(k+1/2)*n/N)

for real input -- the spectrum sampled halfway between the ordinary FFT
bins -- emitting the packed lower half H[0..N/2-1].

Changes:
- Rename kernel/API bdct -> bodft (namespace bodft, bodft::plan/plan_f32,
  C ABI bodft_plan/bodft_forward/bodft_inverse[_f32], C++ bfft::bodft).
- Strip the DCT-IV path entirely (dctiv_plan, DCT-IV API, dctiv benchmark).
- Replace the recursion with iterative scheduling: a build-time radix-4
  digit-reversal permutation drives one leaf pass, then log4(N) ping-pong
  combine passes run leaves-up (forward) / top-down (inverse). This also
  improves locality (forward ~20% faster than the recursion at large N).
- Forward and inverse are first class in both float and double. Forward
  uses the explicit 128-bit SoA SIMD combine (V2 double, V4F float, FMA,
  portable SSE+NEON); inverse is the exact algebraic inverse (scalar).
- Precomputed t, t^2, t^3 twiddle tables (three muls per combine, no
  derivation chain).

Validation: examples/bodft_benchmark.cpp checks both precisions across
N=2..8192 -- forward vs direct DFT, exact impulse phase, exact inverse
roundtrip (~1e-16 double, ~1e-7 float). Warning-clean under
-Wall -Wextra -Wpedantic; existing make test suite still passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@falseywinchnet falseywinchnet merged commit d9507ef into main Jun 23, 2026
4 checks passed
@falseywinchnet falseywinchnet deleted the bodft-kernel branch June 23, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant