DIT and DIF Algorithms
DIT and DIF Algorithms
DBCET, Azara
CHAPTER 1
1.1 INTRODUCTION
A DFT decomposes a sequence of values into components of different frequencies. This
operation is useful in many fields but computing it directly from the definition is often too slow to be
practical. A Fast Fourier Transform (FFT) is a way to compute the same result more quickly:
computing a DFT of N points using the definition, takes O(N2) arithmetical operations, while an FFT
can compute the same result in only O(N log N) operations. The difference in speed can be substantial,
especially for long data sets where N may be in the thousands or millions—in practice, the
computation time can be reduced by several orders of magnitude in such cases, and the improvement
is roughly proportional to N/log(N). This huge improvement makes many DFT-based algorithms
practical; FFTs are of great importance to a wide variety of applications, from digital signal
processing and solving partial differential equations to algorithms for quick multiplication of large
integers.
For a 1024 point transform (p=10, N=1024), this gives approximately 100 fold speed
improvement. This is why FFT's are important. Of course the actual speed improvement that is
DIT and DIF Algorithms of FFT
DBCET, Azara
achieved in practice depends on other factors associated with algorithm implementation and coding
efficiency, but the above expression is useful to get 'ball park' estimates.
If N is even, the above sum can be split into 'top' (n=0…...N/2-1) and
If we now consider the form of this result for even and odd valued k separately, we can see
how this result enables us to express an N point FFT in terms of 2 (N/2) point FFT's.
Even k, k=2k' (k'=0..N/2-1):
DIT and DIF Algorithms of FFT
DBCET, Azara
or equivalently,
Odd k, k=2k'+1 (k'=0..N/2-1):
or equivalently..
The process of dividing the frequency components into even and odd parts is what gives this algorithm
its name 'Decimation In Frequency'. If N is a regular power of 2, we can apply this method recursively
until we get to the trivial 1 point transform. The factors TN are conventionally referred to as 'twiddle
factors'.
FUNCTION DIF(N,f);
LOCAL N',n,fe,fo,Fe,Fo,k',F;
IF N==1
THEN RETURN(f); {trivial if N==1}
ELSE BEGIN {perform 2 sub-transforms}
DIT and DIF Algorithms of FFT
DBCET, Azara
N':=N/2; {size of sub-transforms}
FOR n:=0 TO (N'-1) DO {perform N' DIF 'butterflies'}
BEGIN
fe[n]:= f[n]+f[n+N']; {even subset}
fo[n]:=(f[n]-f[n+N'])*T(N,n); {odd subset}
END;
Fe:=DIF(N',fe); {even k}
Fo:=DIF(N',fo); {odd k}
FOR k':=0 TO (N'-1) DO
BEGIN
F[2*k' ]:= Fe[k']; {even k}
F[2*k'+1]:= Fo[k']; {odd k}
END;
RETURN(F);
END;
This is simplest form of DIF implementation and directly reflects the mathematical derivation
of the algorithm. The process of calculating the fe and fo components is conventionally referred to as a
(DIF) 'butterfly', and is the basic primitive operation of the FFT.
Dropping the constant scaling factors (including the log base) we get an algorithmic complexity of
O(N.logN)
DIT and DIF Algorithms of FFT
DBCET, Azara
1.6 A RECURSIVE 'IN PLACE' DIF FFT ROUTINE.
A better and more efficient (recursive) in-place DIF routine is as given below:
{
Perform in place DIF of N points starting at position BaseE
DIF(0,N,f) performs DIF FFT on entire array f, N= size of f
}
PROCEDURE DIF(BaseE,N, VAR f); {f is an external array}
LOCAL N',BaseO,n,e,o;
IF N==1
THEN {do nothing}
ELSE BEGIN
N':=N>>1; {shift right to get size of sub-transforms}
BaseO:=BaseE+N'; {split block into 2 halves}
FOR n:=0 TO (N'-1) DO
BEGIN
e:= f[BaseE+n]+f[BaseO+n];
o:=(f[BaseE+n]-f[BaseO+n])*T(N,n);
f[BaseE+n]:=e;
f[BaseO+n]:=o;
END;
DIF(BaseE,N',f); {even sub-transform}
DIF(BaseO,N',f); {odd sub-transform}
END;
This version of the DIF routine is a little simpler and more efficient than the first, but has the
disadvantage that the output is in 'jumbly' (bit reversed) order. This may or may not be a serious
problem, depending on what the output is to be used for and whether or not the
processor/programming language supports bit reversed addressing (most DSP's do). If bit reversed
addressing is not available then you may need to produce a bit reversed index look up table to access
the output.
DIT and DIF Algorithms of FFT
DBCET, Azara
It is worth noting that this is the simplest formulation of the 'in-place' DIF algorithm. It takes
normal order input and generates bit reversed order output. However, this is not fundamental to the
algorithm, it is merely a consequence of the simplest implementation. It is possible to write a reverse
order DIF algorithm FFT which takes bit reversed order input and generates normal order output. This
requires the DIF FFT routine to be amended in two ways:
Passing an additional parameter which specifies the spacing between elements in each sub-
array to be transformed. In the simple code above, this is always 1. In the reverse order FFT, this will
start at 1 and double for each sub transform. This parameter is also useful feature for multi-
dimensional transforms.
Since the input to each sub-transform is now in bit reversed order, the twiddle factors must also
used in bit reversed order. This isn't difficult if the twiddle factors are taken from a table in bit
reversed order, or if bit reversed addressing is available.
The next trick is to notice that often the twiddle factor will be either +1 or -j (it will never be -1
or +j). In such cases there is no need to do a full blown complex multiply (remember this requires 4
real multiplies and 2 real adds). Simple addition and subtraction will suffice. We shall call butterflies
that use one or other of these twiddle factors 'trivial butterflies'. Specifically:
Let us consider the last DIF FFT pass (N=2). In this case, T2(0)=1 is the only twiddle factor
used. So, the entire last pass consists of trivial butterflies. Similarly, the first butterfly of any sub-block
will use TN(0)=1. In general, in pass P (P=0..p-1), there are BP (=2P) sub-blocks and therefore
2Pbutterflies which use a twiddle factor of +1.
DIT and DIF Algorithms of FFT
DBCET, Azara
In the penultimate (N=4) pass the butterflies will use either T4(0)=1 or T4(1)=-j. So this pass
also uses only trivial butterflies. As in the above case, in each of the previous (N>4, P<p-2) passes,
there are BP (=2P) sub-blocks and therefore 2P butterflies which use a twiddle factor of -j (at n=N/4) .
We can now calculate exactly how many of these trivial butterflies Triv(p) there are in a typical
DIF FFT for sizes >4 (p>2). This is the sum of the number of butterflies in the last 2 passes (the easy
bit) and the number of trivial butterflies in all the other passes (the hard bit, but the result in Annex B
is useful here):
So, for a 2p point DIF FFT, the proportion of trivial butterflies is about 3/p. If this shortcut is
exploited, then large FFT's benefit less than small FFT's. For example, in a 512 point (p=9) DIF FFT
about 1/3 of the butterflies will be trivial.
The below given diagram shows the signal flow diagram for an 8-point radix-2 DIF FFT.
DIT and DIF Algorithms of FFT
DBCET, Azara
The N-point DIF FFT has log2(N) stages, numbered P = 1, 2, ..., log2(N).
Each stage comprises N/2 butterflies. Not counting the –1 twiddle factors, the Pth stage
has N/2P unique twiddle factors, numbered k = 0, 1, 2, ..., N/2P–1 as indicated by the bold numbers
above the upward-pointing arrows at the bottom of Figure.
Given those characteristics, the kth unique twiddle factor phase angle for the Pth stage is computed
using:
For example, for the second stage (P = 2) of an N = 8-point DIF FFT, the unique Q factors are:
In terms of the original 1D arrays, these two equations correspond to even and odd k respectively:
If N is even, the above sum can be split into 'even' (n=2n') and 'odd' (n=2n'+1) halves,
where n'=0..N/2-1, and re-arranged as follows:
This process of splitting the 'time domain' sequence into even an odd samples is what gives the
algorithm its name, 'Decimation In Time'. As with the DIF algorithm, we have succeeded in expressing
an N point transform as 2 (N/2) point sub-transforms. The principal difference here is that the order we
do things has changed. In the DIF algorithm the time domain data was 'twiddled' before the two sub-
transforms were performed. Here the two sub-transforms are performed first. The final result is
obtained by 'twiddling' the resulting frequency domain data. There is a slight problem here, because
the two sub-transforms only give values for k=0..N/2-1. We also need values for k=N/2..N-1. But from
the periodicity of the DFT we know:
Also,
So, for k=0..N/2-1:
and
DIT and DIF Algorithms of FFT
DBCET, Azara
where
This will produce a simple recursive DIT FFT routine for any N which
is a regular power of 2 (N=2p).
Given the above results, we can now have a 'first stab' at a recursive routine to
implement this algorithm (in a hypothetical Pascal like programming language which
supports complex numbers and allows arrays as function arguments and results):
Dropping the constant scaling factors (including the log base) we get an algorithmic complexity of
O(N.logN)
Passing an additional parameter which specifies the spacing between elements in each sub-
array to be transformed. In the simple code above, this is always 1. In the reverse order FFT, this will
start at 1 and double for each sub transform. This parameter is also useful feature for multi-
dimensional transforms.
Since the output from each sub-transform is now in bit reversed order, the twiddle factors must
also used in bit reversed order. This isn't difficult if the twiddle factors are taken from a table in bit
reversed order, or if bit reversed addressing is available.
As with the DIF algorithm, there is scope for optimising 'trivial' twiddle factors. (See the DIF
algorithm for more detail). The only differrence with the DIT algorithm is that it makes exclusive use
of trivial butterflies in the first two passes.
The below given diagram shows the signal flow diagram for an 8-point radix-2 DIT FFT.
Not counting the –1 twiddle factors, the Pth stage has N/2 twiddle factors, numbered k = 0, 1,
2, ..., N/2–1 as indicated by the upward arrows at the bottom of Figure 3.
Given those characteristics, the kth DIT twiddle Q factor for the Pth stage is computed using:
where 0 ≤ k ≤ N/2–1. The ⌊q⌋ operation means the integer part of q. The [z]bit-rev function represents the
three-step operation of:
DIT and DIF Algorithms of FFT
DBCET, Azara
[1] convert decimal integer z to a binary number represented by log2(N)–1 binary bits,
[2] perform bit reversal on the binary number as discussed in Section 4.5, and
[3] convert the bit reversed number back to a decimal integer.
As an example of using Eq.(2), for the second stage (P = 2) of an N = 8-point DIT FFT, the k =
3 twiddle Q factor is:
The above [1]bit-rev operation is: take the decimal number 1 and represent it with log 2(N)–1 = 2
bits, i.e., as 012. Next, reverse those bits to a binary 10 2 and convert that binary number to our desired
decimal result of 2.
In terms of the original 1D arrays, these two equations correspond to 'top' and 'bottom' k respectively:
DIT and DIF Algorithms of FFT
DBCET, Azara
DIT and DIF Algorithms of FFT
DBCET, Azara
CONCLUSION.
3.1 DIF OR DIT?
In terms of computational work load, there would appear to be very little to choose between
the DIF and DIT algorithms. Both perform exactly the same number of butterflies. Each butterfly
requires exactly one complex multiply and two complex adds. Both algorithms use exactly the same
number if trivial (and 'semi-trivial') butterflies.
The most significant difference between simple DIF and DIT algorithms is that DIF starts with
normal order input and generates bit reversed order output. In contrast, DIT starts with bit reversed
order input and generates normal order output. So if both forward and inverse transforms are required
and bit reversed addressing isn't available, then the choice would seem clear. Use DIF for the forward
transform and DIT for the inverse transform. (For the inverse transform you will need to conjugate the
twiddle factors.) Unfortunately, the issue isn't quite so simple. If your performing FFT's on pure real
data it may be simpler to use a modified DIT for the forward transform and a modified DIF for the
inverse transform.
It is worth noting that if the FFT (DIF or DIT) uses 'hard wired' -j trivial butterflies, then one
will need separate routines forward and inverse transforms in any case. You can easily conjugate a
twiddle factor table, but the 'hard wired' -j butterflies can't use conjugated twiddle factors without re-
writing the code.
If the processor supports bit reversed addressing (see below), then the physical ordering of the
input or output data is not an important efficiency consideration. One should try coding both the DIF
and DIT butterflies and see which is the most efficient. (In a DSP that supports single cycle adds,
multiplies and multiply/accumulates, both should take about 8 clock cycles).
What all this shows is that both the Radix 2 DIF and DIT algorithms can be regarded simply as
slightly different implementations of the same more general algorithm. The only difference is that if
you decompose a 2p point transform into 2 rows and 2 p-1 columns you get the DIF algorithm.
Decomposing into 2p-1 rows and 2 columns yields the DIT algorithm.
The corresponding butterflies are really just an optimization which combines multiplication by
the generalized twiddle factors and a 2 point FFT into the same operation. In the DIF algorithm
butterfly, the twiddle factors (one of which is 1) are applied after the 2 point (column) FFT. In the DIT
algorithm butterfly, the twiddle factors (one of which is again 1) are applied before the 2 point (row)
FFT.
DIT and DIF Algorithms of FFT
DBCET, Azara
TABLE OF CONTENTS
CHAPTER 1
1.1 Introduction………………………………………………………………………………………01
CHAPTER 2
CONCLUSION
3.1 DIF Or
DIT?.....................................................................................................................................................17
BIBLIOGRAPHY
1. Babu, P. Ramesh, Digital Signal Processing’, Scitech Publications (India) Pvt. Ltd., Hyderabad:
February, 2010.
2. Clausen, Michael and Meinard Muller, A Fast Program Generator of Fast Fourier Transforms,
Bonn Germany.
3. http://www.en.wikipedia.org/wiki/Fast_Fourier_transform
4. http://www.engineeringproductivitytools.com/stuff/T0001/PT08.HTM
5. http://www.springerlink.com/content/t3840k17g800m648/
DIT and DIF Algorithms of FFT
DBCET, Azara
6. http://www.cs.cf.ac.uk/Dave/Vision_lecture/node20.html