1 / 15
Digital Signal Processing (4-1)
The Radix 2 Decimation-In-Time FFT
Algorithm
The Radix 2 Decimation-In-Time FFT Algorithm ....................................................................... 1
1. Examples .......................................................................................................................... 2
2. The Principle of the Radix 2 Decimation-In-Time FFT Algorithm ................................. 6
2.1. Principle ................................................................................................................ 6
2.2. Algorithm .............................................................................................................. 7
3. The Radix 2 Decimation-In-Time FFT Algorithm ........................................................... 9
3.1 The Bit-Reversed Algorithm .................................................................................. 9
3.2 The Main Block Diagram ....................................................................................... 9
3.3 The Algorithm for computation of ( ) k X
p
............................................................ 9
4. The Applications of FFT Algorithm............................................................................... 11
4.1. IFFT Algorithm ................................................................................................... 11
4.2. The 2-Dimentional FFT Algorithm ..................................................................... 11
4.3. The 2-Dimentional IFFT Algorithm .................................................................... 11
Appendix: Source Programs .............................................................................................. 13
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
2 / 15
1. Examples
We first illustrate FFT algorithms by examples. Lets consider an 8-point DFT. The
8-point DFT can be decomposed into two 4-point DFTs. In fact,
( ) ( ) | | ( ) ( ) ( )
( )
=
+
= =
+ + = = =
3
0 n
k 1 n 2
8
3
0 n
nk 2
8
7
0 n
nk
8 8
W 1 n 2 x W n 2 x W n x n x DFT k X
( ) ( ) ( ) ( )
= = = =
+ = + + =
3
0 n
nk
4
k
8
3
0 n
nk
4
3
0 n
nk
4
k
8
3
0 n
nk
4
W n h W W n g W 1 n 2 x W W n 2 x
( ) ( ) ( ) ( )
( ) ( )
( ) ( )
=
= +
= + =
7 , 6 , 5 , 4 k 4 k H W 4 k G
3 , 2 , 1 , 0 k k H W k G
k H W k G
4 k
8
k
8
4
k
8 4
where
( ) ( ) n 2 x n g = and ( ) ( ) | | ( )
=
= =
3
0 n
nk
4 4
W n g n g DFT k G
( ) ( ) 1 n 2 x n h + =
and ( ) ( ) | | ( )
=
= =
3
0 n
nk
4 4
W n h n h DFT k H
This can be illustrated by the following figure:
where the cross pattern means the butterfly computation:
X(0)
X(1)
X(2)
X(3)
X(4)
X(5)
X(6)
X(7)
G(0)
G(1)
G(2)
G(3)
H(0)
H(1)
H(2)
H(3)
0
8
W
1
8
W
2
8
W
3
8
W
A
B
A+B
A-B
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
3 / 15
Furthermore, a 4-point DFT can be also decomposed into two 2-point DFTs in the
same way. In fact,
( ) ( ) | | ( ) ( ) ( )
( )
=
+
= =
+ + = = =
1
0 n
k 1 n 2
4
1
0 n
nk 2
4
4
0 n
nk
4 4
W 1 n 2 g W n 2 g W n g n g DFT k G
( ) ( ) ( ) ( ) ( ) ( )
2 2
k
4 2 1
1
0 n
nk
2
k
4
1
0 n
nk
2
k G W k G W 1 n 2 g W W n 2 g + = + + =
= =
( ) ( )
( ) ( )
=
= +
=
3 , 2 k 2 k G W 2 k G
1 , 0 k k G W k G
2
2 k
4 1
2
k
4 1
where
( ) ( ) | | ( ) ( ) ( ) 2 g W 0 g W n 2 g n 2 g DFT k G
k
2
1
0 n
nk
2 2 1
+ = = =
=
( ) ( ) | | ( ) ( ) ( ) 3 g W 1 g W 1 n 2 g 1 n 2 g DFT k G
k
2
1
0 n
nk
2 2 2
+ = + = + =
=
Similarly
( ) ( ) | | ( ) ( ) ( )
( )
=
+
= =
+ + = = =
1
0 n
k 1 n 2
4
1
0 n
nk 2
4
4
0 n
nk
4 4
W 1 n 2 h W n 2 h W n h n h DFT k H
( ) ( ) ( ) ( ) ( ) ( )
2 2
k
4 2 1
1
0 n
nk
2
k
4
1
0 n
nk
2
k H W k H W 1 n 2 h W W n 2 h + = + + =
= =
( ) ( )
( ) ( )
=
= +
=
3 , 2 k 2 k H W 2 k H
1 , 0 k k H W k H
2
2 k
4 1
2
k
4 1
where
( ) ( ) | | ( ) ( ) ( ) 2 h W 0 h W n 2 h n 2 h DFT k H
k
2
1
0 n
nk
2 2 1
+ = = =
=
( ) ( ) | | ( ) ( ) ( ) 3 h W 1 h W 1 n 2 h 1 n 2 h DFT k H
k
2
1
0 n
nk
2 2 2
+ = + = + =
=
Thus, the above 8-point DFT can be illustrated by the following figure:
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
4 / 15
From the above example we may conclude that
(1) The sequence ( ) n x must be first rearranged in bit-reversed order.
(2) A N-point DFT, where
m
2 N = , is implemented through m stages of
computation, each has its own input and output. The output from a certain
stage is the input to the next stage. It is clear that the input to the first stage
is ( ) n x , but the order of its indices has been bit-reversed, and the output
from the last stage is nothing but the DFT of ( ) n x .
(3) In the p-th stage of computation , where m p 1 s s , the elements of the
input sequence are arranged into
p
2
N
groups, each consists of
p
2 elements
and
1 p
2
butterfly computations. It is clear that the index of the first element
of the L-th group in the p-th stage is ( )
p
2 1 L and the two elements
participating in the butterfly computation in the p-th stage are spaced in
index
1 p
2
.
(4) The R-th butterfly computation of the L-th group in the p-th stage can be
depicted by the following figure:
X(0)
X(1)
X(2)
X(3)
X(4)
X(5)
X(6)
X(7)
0
8
W
1
8
W
2
8
W
3
8
W
0
4
W
1
4
W
1
4
W
0
4
W
x(0)=g(0)
x(4)=g(2)
x(2)=g(1)
x(6)=g(3)
x(1)=h(0)
x(5)=h(2)
x(3)=h(1)
x(7)=h(3)
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
5 / 15
In the next section we will show that the above conclusion dose not rely on ones
insight only.
In general, let
( ) ( )
e
x n x 2n = ,
N
0 n
2
s < and
( ) ( )
e N e
2
X k DFT x n = (
,
N
0 k
2
s <
( ) ( )
o
x n x 2n 1 = + ,
N
0 n
2
s < and
( ) ( )
o N o
2
X k DFT x n = (
,
N
0 k
2
s <
then
( ) ( ) ( )
N 1
nk
N N
n 0
X k DFT x n x n W
=
= = (
( ) ( )
( )
N N
1 1
2 2
2n 1 k 2nk
N N
n 0 n 0
x 2n W x 2n 1 W
+
= =
= + +
( ) ( )
N N
1 1
2 2
nk k nk
N N N
n 0 n 0
2 2
x 2n W W x 2n 1 W
= =
= + +
( ) ( )
k
N e N N o
2 2
DFT x n W DFT x n = + ( (
( ) ( )
k
N N
e N o
2 2
X k W X k
( (
= +
( (
When
N
0 k
2
s < , we have
( )
| | | |
| | | |
k
e N o
k
e N o
X k
X k W X k
N
X k W X k X k
2
(
( +
(
=
( | |
(
+
|
(
\ .
1 R
p
2
W
( ) ( ) ( ) 1 R 2 1 L x
p
+
( ) ( ) ( )
1 p p
2 1 R 2 1 L x
+ +
( ) ( ) ( ) 1 R 2 1 L x
p
+
( ) ( ) ( )
1 p p
2 1 R 2 1 L x
+ +
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
6 / 15
2. The Principle of the Radix 2 Decimation-In-Time
FFT Algorithm
2.1. Principle
Let
m
2 N = , the indices n and k can be then represented as:
m 1
i
i
i 0
n n 2
=
=
,
m 1
j
j
j 0
k k 2
=
=
,
where
i j
0 n ,k 1 s s , i, j 0,1, ,m 1 = . Thus we have
m 1 m 1 m 1 m 1 m 1
i j i j i j
i j i j i j
i 0 j 0 i 0 j 0 j 0
m m m
n 2 k 2 n 2 k 2 n 2 k 2 m 1
nk
N
2 2 2
i 0
W W W W
= = = = =
| | | |
| |
| |
|
|
| |
\ .
\ . \ .
=
= = =
[
m 1 i m 1 m 1 i m 1
i j j i i j j i
i j j i j i j
j 0 j m i j 0 j m i
m m m
n 2 k 2 k 2 n 2 k 2 n k 2 m 1 m 1 m 1
2 2 2
i 0 i 0 i 0
W W W
+ +
= = = =
| |
|
+
|
\ .
= = =
| || |
| |
= =
| |
\ .\ .
[ [ [
m 1 i i 1 m 1 i
i j m p i j
i j i p m i i j
j 0 p 0 j 0
m m m
i 1
m p
n 2 k 2
i p m i
p 0
m
2
n 2 k 2 n 2 k 2 n 2 k 2 m 1 m 1 m 1
2 2 2
p j i m
i 0 i 0 i 0
W =1
W W = W
+
= = =
+
=
= +
= = =
| || |
| |
=
| |
\ .\ .
[ [ [
and
( ) ( )
m 1 i
j
i j
j 0
m m i
0 1 m 1
n k 2 m 1 N 1 1 1 1 m 1
nk i
i
2 2
n 0 n 0 n 0 n 0 i 0 i 0
X k x n W x n 2 W
=
= = = = = =
| |
| |
|
= =
|
|
\ .
\ .
[
m 1 m 2
j j
0 j 1 j
j 0 j 0
m 1 0
m m 1
0 1 m 1
n k 2 n k 2
1 1 1 m 1
n k i
i 2
2 2
n 0 n 0 n 0 i 0
x n 2 W W W
= =
= = = =
| |
| |
|
=
|
|
\ .
\ .
m 1 m 2
j j
0 j 1 j
j 0 j 0
m 1 0
m m 1
0 1 m 1
n k 2 n k 2
1 1 1 m 1
n k i
i 2
2 2
n 0 n 0 n 0 i 0
x n 2 W W W
= =
= = = =
| |
| |
|
=
|
|
\ .
\ .
m 1 m 2
j j
0 j 1 j
j 0 j 0
m 1 0
m m 1
0 1 m 1
n k 2 n k 2
1 1 1 m 1
n k i
i 2
2 2
n 0 n 0 n 0 i 0
W W x n 2 W
= =
= = = =
| |
=
|
\ .
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
7 / 15
Let
m 1 m 1
i i
0 m 1 i i
i 0 i 0
X n 2 x n 2
= =
| | | |
=
| |
\ . \ .
and
m 1 0
m 1
m 1 1 m 1
n k i i
1 m 1 i 0 0 m 1 i m 1 2
i 1 n 0 i 1
X n 2 k X n 2 n W
= = =
| | | |
+ = +
| |
\ . \ .
m 1
i
2 m 1 i 1 0
i 2
X n 2 k 2 k
=
| |
+ + =
|
\ .
2
j
m 2 j
j 0
2
m 2
n k 2
1 m 1
i
1 m 1 i m 2 0
2
n 0 i 2
X n 2 n 2 k W
=
= =
| |
= + +
|
\ .
p 2 m 1
i p 1 j
p m 1 i p 1 j
i p j 0
X n 2 k 2 k 2
= =
| |
+ + =
|
\ .
p 1
j
m p j
j 0
p
m p
n k 2 p 2 1 m 1
i p 1 j
p 1 m 1 i m p j
2
n 0 i p j 0
X n 2 n 2 k 2 W
= = =
| |
= + +
|
\ .
m 1
j
0 j
j 0
0
n k 2
m 2 1 m 2
m 1 j m 1 j
m m 1 j m 1 0 j N
j 0 n 0 j 0
X k 2 k 2 X n 2 k 2 W
=
= = =
| | | |
+ = +
| |
\ . \ .
( ) k X is then seen to be
( )
=
| |
=
|
\ .
m 1
j
m j
j 0
X k X k 2
2.2. Algorithm
p 2 m 1
i p 1 j
p m 1 i p 1 j
i p j 0
X n 2 k 2 k 2
= =
| |
+ + =
|
\ .
p 1
j
m p j
j 0
p
m p
n k 2 p 2 1 m 1
i p 1 j
p 1 m 1 i m p j
2
n 0 i p j 0
X n 2 n 2 k 2 W
= = =
| |
= + +
|
\ .
Let
p 2
j
j
j 0
R k 2
=
=
and
L 2 2 n 2 2 n
p
p 1 m
0 i
i
i 1 m
p
1 m
p i
i
i 1 m
= =
=
=
,
=
=
p 1 m
0 i
i
i 1 m
2 n L
then
( ) ( )
( )
p 1
m p p 1
p
m p
1
n k 2 R
p p 1 p p 1
p p 1 p 1 m p
2
n 0
X L2 k 2 R X L2 n 2 R W
+
=
+ + = + +
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
8 / 15
( ) ( )
p 1
p 1
p p
k 2
p R p p 1
p 1 p 1
2 2
X L2 R W W X L2 2 R
= + + + +
Furthermore, we finally have
( ) ( ) ( ) p
p p R p p 1
p p 1 p 1
2
X L2 R X L2 R W X L2 2 R
+ = + + + +
( ) ( ) ( ) p
p p 1 p R p p 1
p p 1 p 1
2
X L2 2 R X L2 R W X L2 2 R
+ + = + + +
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
9 / 15
3. The Radix 2 Decimation-In-Time FFT Algorithm
3.1 The Bit-Reversed Algorithm
=
=
= =
1 m
0 i
i
i 1 m
1 m
0 i
i
i
2 n n
~
2 n n
(1) input n and m;
(2) if 0 n = , return n;
(3) 1 k = , 0 n
~
= ,
1 m
2 N
= ;
(4)
(
=
N
n
t ;
(5) if 0 t = , goto (7);
(6)
1 k
2 t n
~
n
~
+ = , N n n = ;
(7) if 0 n = ,
2
N
N = , 1 k k + = , goto (4);
(8) return n
~
.
3.2 The Main Block Diagram
(1) input ( ) n x
(2) bit-reverse ( ) n x and then set ( ) ( ) n x n
~
X
0
=
(3) 1 p =
(4) compute ( ) k X
p
, 1 N , , 1 , 0 k =
(5) if m p = , 1 p p + = , goto (4)
(6) return with ( ) ( ) k X k X
m
= , 1 N , , 1 , 0 k =
3.3 The Algorithm for computation of ( ) k X
p
For( p 1 = ; p m s ; p p = ++)
For( L 0 = ;
p 1
L 2
< ; L L = ++)
For( R 0 = ;
m p
R 2
< ; R R = ++)
{
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
10 / 15
( ) ( ) ( ) p
p p p p 1 R
p p 1 p 1
2
X L 2 R X L 2 R X L 2 2 R W
+ = + + + +
( ) ( ) ( ) p
p p 1 p p p 1 R
p p 1 p 1
2
X L 2 2 R X L 2 R X L 2 2 R W
+ + = + + +
}
In-place computation: Let
( ) ( )
0
X k X k = , then
For( p 1 = ; p m s ; p p = ++)
For( L 0 = ;
p 1
L 2
< ; L L = ++)
For( R 0 = ;
m p
R 2
< ; R R = ++)
{
( )
p
temp1 X L 2 R = +
( )
p p 1
temp2 X L 2 2 R
= + +
( ) p
p R
2
X L 2 R temp1 W temp2 + = +
( ) p
p p 1 R
2
X L 2 2 R temp1 W temp2
+ + =
}
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
11 / 15
4. The Applications of FFT Algorithm
4.1. IFFT Algorithm
Since
( ) ( )
=
1 N
0 n
nk
N
W k X
N
1
n x
thus we have
( ) ( ) ( ) | | k X DFT
N
1
W k X
N
1
n x
1 N
0 n
nk
N
- -
-
=
-
= |
.
|
\
|
=
The above formula shows that the IDFT can be implemented by using FFT
Algorithm.
4.2. The 2-Dimentional FFT Algorithm
( ) ( )
=
=
1 N
0 n
1 M
0 m
ml
M
nk
N
W W m , n x l , k X
Let
( ) ( ) ( ) | | m , n x DFT W m , n x m , k X
1 N
0 n
nk
N 1
= =
=
where m is invariant in ( ) | | m , n x DFT , then
( ) ( ) ( ) | | m , k X DFT W m , k X l , k X
1
1 M
0 m
ml
M 1
= =
=
where k is invariant in ( ) | | m , k X DFT
1
. Thus the 2-dimentional DFT can be
implemented by using FFT algorithm.
4.3. The 2-Dimentional IFFT Algorithm
Since
( ) ( )
=
=
1 N
0 n
1 M
0 m
ml
M
nk
N
W W l , k X
NM
1
m , n x
thus we have
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
12 / 15
( ) ( )
-
=
-
|
.
|
\
|
=
1 N
0 n
1 M
0 m
ml
M
nk
N
W W l , k X
NM
1
m , n x
The above formula shows that the 2-dimentional IDFT can be implemented by
using the fast algorithm for the 2-dimentional DFT, which is in turn implemented
by using FFT algorithm.
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
13 / 15
Appendix: Source Programs
#include<iostream.h>
#include<complex.h>
#include<math.h>
#define DIM 100
main()
{ int n,m,N;
complex x[DIM];
void FFT(complex*,int),IFFT(complex*,int);
cout<<"m="; cin>>m;
N=pow(2,m);
for(n=0;n<=N-1;n++){cout<<"x["<<n<<"]="; cin>>x[n];}
FFT(x,m); IFFT(x,m);
for(n=0;n<=N-1;n++){cout<<"x["<<n<<"]="<<x[n]<<endl;};
cout<<"The End!";
}
// -------------------------- FFT Algorithm -------------------------
#define DIM 10 // DIM must not be less than N=2**m
void FFT(complex *x,int m)
{ int p,L,R,T,N=pow(2,m),Inverse_Order(int,int);
complex temp,weight,X[DIM-1];
X[0]=x[0]; X[N-1]=x[N-1];
for(p=1;p<=N-2;p++)X[p]=x[Inverse_Order(p,m)];
for(p=1;p<=m;p++)
{ T=pow(2,p);
for(L=0;L<=N/T-1;L++)
for(R=0;R<=T/2-1;R++)
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
14 / 15
{ temp=X[L*T+R];
weight=exp(complex(0,-(2*3.1416*R)/T));
X[L*T+R]=temp+weight*X[L*T+R+T/2];
X[L*T+R+T/2]=temp-weight*X[L*T+R+T/2];
}
}
for(p=0;p<=N-1;p++)x[p]=X[p];
}
int Inverse_Order(int n,int m)
{ int k,t,nt=0,N=pow(2,m-1);
if(n==0)return n;
for(k=1;n;k++,N=N/2)
{ t=n/N;
if(t==0)continue;
nt=nt+t*pow(2,k-1);
n=n-N;
}
return nt;
}
// -------------------------- IFFT Algorithm ------------------------
void IFFT(complex *X,int m)
{ int p,N=pow(2,m);
void FFT(complex*,int);
for(p=0;p<=N-1;p++)X[p]=conj(X[p]);
FFT(X,m);
for(p=0;p<=N-1;p++)X[p]=conj(X[p])/N;
}
// ---------------- 2-Dimentional FFT Algorithm ---------------------
#define SIZE 10 // SIZE should be defined in the main function
#define DIM 10 // DIM must not be less than N=2**n nor M=2**m
The Radix 2 Decimation-In-Time FFT Algorithm (11/8/12)
15 / 15
void FFT_2DIM(complex (*x)[SIZE-1],int n,int m)
{ int p,q,N=pow(2,n),M=pow(2,m);
complex t[DIM-1];
void FFT(complex*,int);
for(q=0;q<=M-1;q++)
{ for(p=0;p<=N-1;p++)t[p]=x[p][q];
FFT(t,n);
for(p=0;p<=N-1;p++)x[p][q]=t[p];
}
for(p=0;p<=N-1;p++)
{ for(q=0;q<=M-1;q++)t[q]=x[p][q];
FFT(t,m);
for(q=0;q<=M-1;q++)x[p][q]=t[q];
}
}
// ---------------- 2-Dimentional IFFT Algorithm ---------------------
#define SIZE 10 // SIZE should be defined in the main function
void IFFT_2DIM(complex (*X)[SIZE-1],int n,int m)
{ int p,q,N=pow(2,n),M=pow(2,m);
void FFT_2DIM(complex (*)[],int,int);
for(p=0;p<=N-1;p++)
for(q=0;q<=M-1;q++)
X[p][q]=conj(X[p][q]);
FFT_2DIM(X,n,m);
for(p=0;p<=N-1;p++)
for(q=0;q<=M-1;q++)
X[p][q]=conj(X[p][q])/(N*M);
}