Algorithm Search⌘K

Proofs: Mixed-radix FFT

These are the human proofs of Mixed-radix FFT, at full length.

MIXED-RADIX-FFT computes the DFT of length r_1 ⋯ r_t with n Σ (r_i − 1) additions and at most as many multiplications full

This proof shows: correctness, complexity.

Statement. Let RR be a commutative ring, t≥0t \ge 0, r1,…,rt≥2r_1, \ldots, r_t \ge 2 integers, n=r1⋯rtn = r_1 \cdots r_t, and ω∈R\omega \in R with ωn=1\omega^n = 1. For every x∈Rnx \in R^n, MIXED-RADIX-FFT(x,ω,(r1,…,rt))(x, \omega, (r_1, \ldots, r_t)) returns XX with Xk=∑j=0n−1xjωjkX_k = \sum_{j=0}^{n-1} x_j \omega^{jk} for 0≤k<n0 \le k < n. It does exactly A(n)=n∑i=1t(ri−1)A(n) = n \sum_{i=1}^{t} (r_i - 1) additions and at most M(n)=n∑i=1t(ri−1)M(n) = n \sum_{i=1}^{t} (r_i - 1) multiplications in RR, with equality for MM when every rir_i is prime, besides building the table of powers of ω\omega. If moreover ω\omega is a principal nn-th root of unity and nn is a unit, running it with ω−1\omega^{-1} and dividing by nn inverts it.

Lemma 1 (the splitting). Let n=rmn = r m, ωn=1\omega^n = 1, and for 0≤l<r0 \le l < r let Yk(l)=∑q=0m−1xrq+l (ωr)qkY^{(l)}_k = \sum_{q=0}^{m-1} x_{rq+l}\, (\omega^r)^{qk} for 0≤k<m0 \le k < m. Then for 0≤k<m0 \le k < m and 0≤s<r0 \le s < r,

Xk+ms=∑l=0r−1(ωlkYk(l))(ωm)ls.X_{k+ms} = \sum_{l=0}^{r-1} \left(\omega^{lk} Y^{(l)}_k\right) (\omega^m)^{ls}.

Proof. Every j∈[0,n)j \in [0, n) is uniquely j=rq+lj = rq + l with 0≤q<m0 \le q < m and 0≤l<r0 \le l < r (division by rr). So

Xk+ms=∑l=0r−1∑q=0m−1xrq+l ω(rq+l)(k+ms).X_{k+ms} = \sum_{l=0}^{r-1} \sum_{q=0}^{m-1} x_{rq+l}\, \omega^{(rq+l)(k+ms)}.

Expand the exponent: (rq+l)(k+ms)=rqk+rqms+lk+lms(rq + l)(k + ms) = rqk + rqms + lk + lms. Here ωrqms=(ωn)qs=1\omega^{rqms} = (\omega^n)^{qs} = 1, ωrqk=(ωr)qk\omega^{rqk} = (\omega^r)^{qk} and ωlms=(ωm)ls\omega^{lms} = (\omega^m)^{ls}. Factoring out the terms that do not depend on qq gives ∑lωlk(ωm)ls∑qxrq+l(ωr)qk\sum_l \omega^{lk} (\omega^m)^{ls} \sum_q x_{rq+l} (\omega^r)^{qk}, which is the claim. □\square

Correctness. By induction on tt. If t=0t = 0 then n=1n = 1, line L2 returns xx, and X0=x0ω0=x0X_0 = x_0 \omega^0 = x_0. Let t≥1t \ge 1, r=r1r = r_1, m=n/r=r2⋯rtm = n/r = r_2 \cdots r_t. Since (ωr)m=ωn=1(\omega^r)^m = \omega^n = 1, the induction hypothesis for the t−1t - 1 radices (r2,…,rt)(r_2, \ldots, r_t) shows that line L5 sets Y(l)Y^{(l)} to the DFT of length mm with root ωr\omega^r of the subsequence (xrq+l)q(x_{rq+l})_q, which is the Y(l)Y^{(l)} of Lemma 1. For fixed kk, line L7 sets tl=ωlkYk(l)t_l = \omega^{lk} Y^{(l)}_k, and line L9 sets Xk+ms=t0+∑l≥1ωmlstl=∑l(ωm)lstlX_{k+ms} = t_0 + \sum_{l \ge 1} \omega^{mls} t_l = \sum_{l} (\omega^m)^{ls} t_l, because (ωm)0⋅s=1(\omega^m)^{0 \cdot s} = 1. By Lemma 1 this is the correct value. The map (k,s)↦k+ms(k, s) \mapsto k + ms from [0,m)×[0,r)[0, m) \times [0, r) to [0,n)[0, n) is a bijection (division by mm), so every output is written exactly once, by the loops at lines L6 and L8. So the returned vector is XX.

Inverse. If ω\omega is a principal nn-th root of unity, so is ω−1\omega^{-1}, and ω−n=1\omega^{-n} = 1, so the program with ω−1\omega^{-1} returns Zj=∑kXkω−jk=∑ixi∑kω(i−j)k=nxjZ_j = \sum_k X_k \omega^{-jk} = \sum_i x_i \sum_k \omega^{(i-j)k} = n x_j, since the inner sum is nn for i=ji = j and 00 otherwise by principality. Dividing by the unit nn gives xx.

Operation count. Let AtA_t and MtM_t be the counts for tt radices, as functions of the radices. For t=0t = 0 both are 00. For t≥1t \ge 1, line L5 makes rr calls of length mm, costing rAt−1(r2,…,rt)r A_{t-1}(r_2, \ldots, r_t) additions. Lines L6 to L9 run for mm values of kk; for each, line L7 does r−1r - 1 multiplications (t0t_0 needs none), and line L9 does, for each of the rr values of ss, exactly r−1r - 1 additions and one multiplication for each l≥1l \ge 1 with ls≢0(modr)ls \not\equiv 0 \pmod r, as in the implementation, which uses the table entry ωm(ls mod r)\omega^{m (ls \bmod r)} and skips the factor 11. That is r(r−1)r(r-1) additions and at most (r−1)2(r-1)^2 multiplications per kk (the pairs l,s≥1l, s \ge 1), with equality when rr is prime, since then ls≢0ls \not\equiv 0 for 1≤l,s<r1 \le l, s < r. So the stage costs exactly m⋅r(r−1)=n(r−1)m \cdot r (r - 1) = n (r - 1) additions and at most m((r−1)+(r−1)2)=mr(r−1)=n(r−1)m((r - 1) + (r-1)^2) = m r (r - 1) = n(r - 1) multiplications. Hence

At=n(r1−1)+r1At−1(r2,…,rt)withAt−1(r2,…,rt)=m∑i≥2(ri−1)A_t = n (r_1 - 1) + r_1 A_{t-1}(r_2, \ldots, r_t) \quad\text{with}\quad A_{t-1}(r_2, \ldots, r_t) = m \sum_{i \ge 2} (r_i - 1)

by induction, so At=n(r1−1)+r1m∑i≥2(ri−1)=n∑i=1t(ri−1)A_t = n(r_1 - 1) + r_1 m \sum_{i \ge 2}(r_i - 1) = n \sum_{i=1}^{t} (r_i - 1). The same computation with inequalities gives Mt≤n∑i(ri−1)M_t \le n \sum_i (r_i - 1), with equality when every rir_i is prime.

Time and space. The index arithmetic per counted operation is O(1)O(1), and each call does O(r)O(r) work besides its stage, so the time is Θ(At+Mt+number of calls)\Theta(A_t + M_t + \text{number of calls}). The calls at level ii number n/ni≤nn / n_i \le n, with ni=ri⋯rtn_i = r_i \cdots r_t, and t≤lg⁡nt \le \lg n, so the time is Θ(n∑iri)\Theta(n \sum_i r_i), since n(ri−1)≥nri/2n (r_i - 1) \ge n r_i / 2. The recursion holds at most one partial result per level along the current path, of total size ∑ini≤2n\sum_i n_i \le 2n, plus the table of nn powers, so the extra space is Θ(n)\Theta(n). ■\blacksquare

Back to Mixed-radix FFT