Purpose: Compute a DFT of prime length in by re-indexing with a primitive root, turning the transform into a cyclic convolution of length .
The Idea
The multiplicative group is cyclic of order . Let be a primitive root. Then every nonzero index can be written as , and the map is a bijection .
Re-index the DFT (for ) by , :
The exponent depends only on , so the right-hand side is a cyclic convolution of length between the sequences and .
Since is composite (for ), that convolution can be computed with a standard FFT β or, if is awkward, by zero-padding to a power of two with Bluestein-style handling.
Algorithm
- Find a primitive root modulo .
- Set separately.
- Permute the input by .
- Cyclically convolve with the precomputed sequence .
- Add to every output and un-permute.
Complexity
- Time:
- Space:
- Precomputation: one primitive root (fast, needs the factorisation of ) plus the twiddle sequence
Rader vs Bluestein for prime lengths
| Rader | Bluestein | |
|---|---|---|
| Requires | a primitive root mod | nothing |
| Convolution length | (exact, cyclic) | (padded, linear) |
| Numerical accuracy | better | chirp factors grow, slightly worse |
| Generality | prime lengths only | any length |
| Used by | FFTW for small primes | FFTW for large/awkward primes |
Both appear in production FFT libraries: FFTW picks Rader for moderate primes and Bluestein when factors badly.
Where this matters in competitive programming
Rarely, directly. But the underlying move β re-indexing a sum by a primitive root to turn multiplication into addition β is a genuinely reusable idea:
- it is how discrete logarithms convert multiplicative problems into additive ones;
- it is the basis of Pohlig-Hellman;
- it turns βconvolution over under multiplicationβ into ordinary cyclic convolution, which is occasionally exactly what a counting problem needs.
Variants / Use Cases
- FFT and NTT β the topic page
- Primitive Root β the number theory this depends on
- Good-Thomas β the coprime-factor decomposition, often combined with Rader in mixed-radix FFTs
- Cooley-Tukey β the power-of-two workhorse