Prime-factor FFT algorithm

(Redirected from Prime-factor FFT algorithm.)

The prime-factor algorithm (PFA), also called the Good–Thomas algorithm (1958/1963), is a fast Fourier transform (FFT) algorithm that re-expresses the discrete Fourier transform (DFT) of a size N = N1N2 as a two-dimensional N1×N2 DFT, but only for the case where N1 and N2 are relatively prime. These smaller transforms of size N1 and N2 can then be evaluated by applying PFA recursively or by using some other FFT algorithm.

PFA should not be confused with the mixed-radix generalization of the popular Cooley–Tukey algorithm, which also subdivides a DFT of size N = N1N2 into smaller transforms of size N1 and N2. The latter algorithm can use any factors (not necessarily relatively prime), but it has the disadvantage that it also requires extra multiplications by roots of unity called twiddle factors, in addition to the smaller transforms. On the other hand, PFA has the disadvantages that it only works for relatively prime factors (e.g. it is useless for power-of-two sizes) and that it requires more complicated re-indexing of the data based on the additive group isomorphisms. Note, however, that PFA can be combined with mixed-radix Cooley–Tukey, with the former factorizing N into relatively prime components and the latter handling repeated factors.

PFA is also closely related to the nested Winograd FFT algorithm, where the latter performs the decomposed N1 by N2 transform via more sophisticated two-dimensional convolution techniques. Some older papers therefore also call Winograd's algorithm a PFA FFT.

(Although the PFA is distinct from the Cooley–Tukey algorithm, Good's 1958 work on the PFA was cited as inspiration by Cooley and Tukey in their 1965 paper, and there was initially some confusion about whether the two algorithms were different. In fact, it was the only prior FFT work cited by them, as they were not then aware of the earlier research by Gauss and others.)

Algorithm

Let ${\displaystyle a(x)}$ a polynomial and ${\displaystyle \omega _{n}}$ a principal ${\displaystyle n}$th root of unity. We define the DFT of ${\displaystyle a(x)}$ as the ${\displaystyle n}$-tuple ${\displaystyle ({\hat {a}}_{j})=(a(\omega _{n}^{j}))}$. In other words,

${\displaystyle {\hat {a}}_{j}=\sum _{i=0}^{n-1}a_{i}\omega _{n}^{ij}\quad {\text{ for all }}j=0,1,\dots ,n-1.}$
For simplicity, we denote the transformation as ${\displaystyle {\text{DFT}}_{\omega _{n}}}$.

The PFA relies on a coprime factorization of ${\textstyle n=\prod _{d=0}^{D-1}n_{d}}$ and turns ${\displaystyle {\text{DFT}}_{\omega _{n}}}$ into ${\textstyle \bigotimes _{d}{\text{DFT}}_{\omega _{n_{d}}}}$ for some choices of ${\displaystyle \omega _{n_{d}}}$'s where ${\textstyle \bigotimes }$ is the tensor product.

Mapping Based on CRT

For a coprime factorization ${\textstyle n=\prod _{d=0}^{D-1}n_{d}}$, we have the Chinese remainder map ${\displaystyle m\mapsto (m{\bmod {n}}_{d})}$ from ${\displaystyle \mathbb {Z} _{n}}$ to ${\textstyle \prod _{d=0}^{D-1}\mathbb {Z} _{n_{d}}}$ with ${\textstyle (m_{d})\mapsto \sum _{d=0}^{D-1}e_{d}m_{d}}$ as its inverse where ${\displaystyle e_{d}}$'s are the central orthogonal idempotent elements with ${\textstyle \sum _{d=0}^{D-1}e_{d}=1{\pmod {n}}}$. Choosing ${\displaystyle \omega _{n_{d}}=\omega _{n}^{e_{d}}}$ (therefore, ${\textstyle \prod _{d=0}^{D-1}\omega _{n_{d}}=\omega _{n}^{\sum _{d=0}^{D-1}e_{d}}=\omega _{n}}$), we rewrite ${\displaystyle {\text{DFT}}_{\omega _{n}}}$ as follows:

${\displaystyle {\hat {a}}_{j}=\sum _{i=0}^{n-1}a_{i}\omega _{n}^{ij}=\sum _{i=0}^{n-1}a_{i}\left(\prod _{d=0}^{D-1}\omega _{n_{d}}\right)^{ij}=\sum _{i=0}^{n-1}a_{i}\prod _{d=0}^{D-1}\omega _{n_{d}}^{(i{\bmod {n}}_{d})(j{\bmod {n}}_{d})}=\sum _{i_{0}=0}^{n_{0}-1}\cdots \sum _{i_{D-1}=0}^{n_{D-1}-1}a_{\sum _{d=0}^{D-1}e_{d}i_{d}}\prod _{d=0}^{D-1}\omega _{n_{d}}^{i_{d}(j{\bmod {n}}_{d})}.}$
Finally, define ${\displaystyle a_{i_{0},\dots ,i_{D-1}}=a_{\sum _{d=0}^{D-1}i_{d}e_{d}}}$ and ${\displaystyle {\hat {a}}_{j_{0},\dots ,j_{D-1}}={\hat {a}}_{\sum _{d=0}^{D-1}j_{d}e_{d}}}$, we have
${\displaystyle {\hat {a}}_{j_{0},\dots ,j_{D-1}}=\sum _{i_{0}=0}^{n_{0}-1}\cdots \sum _{i_{D-1}=0}^{n_{D-1}-1}a_{i_{0},\dots ,i_{D-1}}\prod _{d=0}^{D-1}\omega _{n_{d}}^{i_{d}j_{d}}.}$
Therefore, we have the multi-dimensional DFT, ${\displaystyle \otimes _{d=0}^{D-1}{\text{DFT}}_{\omega _{n_{d}}}}$.

As Algebra Isomorphisms

PFA can be stated in a high-level way in terms of algebra isomorphisms. We first recall that for a commutative ring ${\displaystyle R}$ and a group isomorphism from ${\displaystyle G}$ to ${\textstyle \prod _{d}G_{d}}$, we have the following algebra isomorphism

${\displaystyle R[G]\cong \bigotimes _{d}R[G_{d}]}$
where ${\displaystyle \bigotimes }$ refers to the tensor product of algebras.

To see how PFA works, we choose ${\displaystyle G=(\mathbb {Z} _{n},+,0)}$ and ${\displaystyle G_{d}=(\mathbb {Z} _{n_{d}},+,0)}$ be additive groups. We also identify ${\displaystyle R[G]}$ as ${\textstyle {\frac {R[x]}{\langle x^{n}-1\rangle }}}$ and ${\displaystyle R[G_{d}]}$ as ${\textstyle {\frac {R[x_{d}]}{\langle x_{d}^{n_{d}}-1\rangle }}}$. Choosing ${\displaystyle \eta =a\mapsto (a{\bmod {n}}_{d})}$ as the group isomorphism ${\textstyle G\cong \prod _{d}G_{d}}$, we have the algebra isomorphism ${\textstyle \eta ^{*}:R[G]\cong \bigotimes _{d}R[G_{d}]}$, or alternatively,

${\displaystyle \eta ^{*}:{\frac {R[x]}{\langle x^{n}-1\rangle }}\cong \bigotimes _{d}{\frac {R[x_{d}]}{\langle x_{d}^{n_{d}}-1\rangle }}.}$
Now observe that ${\displaystyle {\text{DFT}}_{\omega _{n}}}$ is actually an algebra isomorphism from ${\textstyle {\frac {R[x]}{\langle x^{n}-1\rangle }}}$ to ${\textstyle \prod _{i}{\frac {R[x]}{\langle x-\omega _{n}^{i}\rangle }}}$ and each ${\displaystyle {\text{DFT}}_{\omega _{n_{d}}}}$ is an algebra isomorphism from ${\textstyle {\frac {R[x]}{\langle {x_{d}}^{n_{d}}-1\rangle }}}$ to ${\textstyle \prod _{i_{d}}{\frac {R[x_{d}]}{\langle x_{d}-\omega _{n_{d}}^{i_{d}}\rangle }}}$, we have an algebra isomorphism ${\displaystyle \eta '}$ from ${\textstyle \bigotimes _{d}\prod _{i_{d}}{\frac {R[x_{d}]}{\langle x_{d}-\omega _{n_{d}}^{i_{d}}\rangle }}}$ to ${\textstyle \prod _{i}{\frac {R[x]}{\langle x-\omega _{n}^{i}\rangle }}}$. What PFA tells us is that ${\textstyle {\text{DFT}}_{\omega _{n}}=\eta '\circ \bigotimes _{d}{\text{DFT}}_{\omega _{n_{d}}}\circ \eta ^{*}}$ where ${\displaystyle \eta ^{*}}$ and ${\displaystyle \eta '}$ are re-indexing without actual arithmetic in ${\displaystyle R}$.

Counting the Number of Multi-Dimensional Transformations

Notice that the condition for transforming ${\displaystyle {\text{DFT}}_{\omega _{n}}}$ into ${\textstyle \eta '\circ \bigotimes _{d}{\text{DFT}}_{\omega _{n_{d}}}\circ \eta ^{*}}$ relies on "an" additive group isomorphism ${\displaystyle \eta }$ from ${\displaystyle (\mathbb {Z} _{n},+,0)}$ to ${\textstyle \prod _{d}(\mathbb {Z} _{n_{d}},+,0)}$. Any additive group isomorphism will work. To count the number of ways transforming ${\displaystyle {\text{DFT}}_{\omega _{n}}}$ into ${\textstyle \eta '\circ \bigotimes _{d}{\text{DFT}}_{\omega _{n_{d}}}\circ \eta ^{*}}$, we only need to count the number of additive group isomorphisms from ${\displaystyle (\mathbb {Z} _{n},+,0)}$ to ${\textstyle \prod _{d}(\mathbb {Z} _{n_{d}},+,0)}$, or alternative, the number of additive group automorphisms on ${\displaystyle (\mathbb {Z} _{n},+,0)}$. Since ${\displaystyle (\mathbb {Z} _{n},+,0)}$ is cyclic, any automorphism can be written as ${\displaystyle 1\mapsto g}$ where ${\displaystyle g}$ is a generator of ${\displaystyle (\mathbb {Z} _{n},+,0)}$. By the definition of ${\displaystyle (\mathbb {Z} _{n},+,0)}$, ${\displaystyle g}$'s are exactly those coprime to ${\displaystyle n}$. Therefore, there are exactly ${\displaystyle \varphi (n)}$ many such maps where ${\displaystyle \varphi }$ is the Euler's totient function. The smallest example is ${\displaystyle n=6}$ where ${\displaystyle \varphi (n)=2}$, demonstrating the two maps in the literature: the "CRT mapping" and the "Ruritanian mapping".[1]