In real-life applications such as signal processing, speed matters a lot, this article examines an efficient FFT implementation. This article focuses on the iterative version of the FFT algorithm that runs in O(nlogn) time but can have a lower constant hidden than the recursive version plus it saves the recursion stack space. Pre-requisite: recursive algorithm of FFT. Recall the recursive-FFT pseudo code from previous post, in the for loop evaluation of , is calculated twice. We can change the loop to compute it only once, storing it in a temporary variable t. So, it becomes, for k 0 to n/2 – 1 do t
The operation in this loop, multiplying the twiddle factor w = by , storing the product into t, and adding and subtracting t from , is known as a butterfly operation. Pictorially, this is what a butterfly operation looks like:
Let us take for n=8 and proceed with the formation of the iterative FFT algorithm. Looking at the recursion tree above, we find that if we arrange the elements of the initial coefficient vector into the order in which they appear in the leaves, we could trace the execution of the Recursive-FFT procedure, but bottom-up instead of top-down. First, we take the elements in pairs, compute the DFT of each pair using one butterfly operation, and replace the pair with its DFT. The vector then holds n/2 2-element DFTs. Next, we take these n/2 DFTs in pairs and compute the DFT of the four-vector elements they come from by executing two butterfly operations, replacing two 2-element DFTs with one 4-element DFT. The vector then holds n/4 4-element DFTs. We continue in this manner until the vector holds two (n/2) element DFTs, which we combine using n/2 butterfly operations into the final n-element DFT.
To turn this bottom-up approach into code, we use an array A[0…n] that initially holds the elements of the input vector a in the order in which they appear in the leaves of the tree. Because we have to combine DFT so n each level of the tree, we introduce a variable s to count the levels, ranging from 1 (at the bottom, when we are combining pairs to form 2-element DFTs) to lgn (at the top, when we are combining two n/2 element DFTs to produce the final result). The algorithm therefore is:
1. for s=1 to lgn
2. do for k=0 to n-1 by 3. do combine the two -element DFTs in A[k...k+-1] and A[k+...k+-1] into one 2s-element DFT in A[k...k+-1]
Now for generating the code, we arrange the coefficient vector elements in the order of leaves. Example- The order in leaves 0, 4, 2, 6, 1, 5, 3, 7 is a bit reversal of the indices. Start with 000, 001, 010, 011, 100, 101, 110, 111 and reverse the bits of each binary number to obtain 000, 100, 010, 110, 001, 101, 011, 111.Pseudocode for iterative FFT :
n = length [a]
for k = 0 to n-1
do A[rev(k)] = a[k]
n = length(a)
for s = 1 to log n
do m= = for j = 0 to m/2-1 do for k = j to n-1 by m do t = A[k+m/2] u = A[k] A[k] = u+t A[k+m/2] = u-t return A
It will be more clear from the below parallel FFT circuit :
Please Login to comment...