# DIT and DIF Algorithms of FFT DBCET, Azara

CHAPTER 1 RADIX 2 DECIMATION IN FREQUENCY (DIF) ALGORITHM

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. 1.2 FAST FOURIER TRANSFORMS ARE FAST DFT ALGORITHMS. It may be noted that the number of complex multiply and add operations required by the simple forms (both the DFT and IDFT) is of order N2. This is because there are N data points to calculate, each of which requires N complex arithmetic operations. Therefore they have algorithmic complexity O (N2 ). Thus the DFT will not be very useful for the majority of practical DSP applications if the complexity is not reduced. This is enabled by a number of different 'Fast Fourier Transform' (FFT) algorithms. 1.2.1 RADIX 2 ALGORITHMS The popular 'Radix 2' algorithms are useful if N is a regular power of 2 (N=2p ). These algorithms have complexity of only O(NlogN). If we assume that algorithmic complexity provides a direct measure of execution time (and that the relevant logarithm base is 2) then the ratio of execution times for the (DFT) vs. (Radix 2 FFT) can be expressed:

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

Both of these rely on the recursive decomposition of an N point transform into 2 (N/2) point transforms. These are sometimes slightly faster. but the above expression is useful to get 'ball park' estimates. 1.N/2-1) and 'bottom' (n=N/2«. the decomposition can be applied repeatedly until the trivial '1 point' transform is reached). There is also an efficient algorithm for evaluating the DFT of sequences whose length is a prime number. it just so happens that is particularly simple if N is divisible by 2 (and if N is a regular power of 2.DIT and DIF Algorithms of FFT DBCET...N/2-1): . This decomposition process can be applied to any composite (non prime) N.. we can see how this result enables us to express an N point FFT in terms of 2 (N/2) point FFT's.3 THE RADIX 2 DECIMATION IN FREQUENCY (DIF) ALGORITHM. the above sum can be split into 'top' (n=0«.. Azara achieved in practice depends on other factors associated with algorithm implementation and coding efficiency.N-1) halves and re-arranged as follows: If we now consider the form of this result for even and odd valued k separately. The so called Radix 4 algorithms are similar in concept to the Radix 2 algorithms. k=2k' (k'=0.. In short. there is always an FFT algorithm (and usually several) which can be applied to any sequence length. namely a) 'Decimation In Time' (DIT) Algorithm b) 'Decimation In Frequency' (DIF) Algorithm. An FFT is defined as: If N is even. Even k. There are two different Radix 2 algorithms.

Azara or equivalently. The factors TN are conventionally referred to as 'twiddle factors'.4 A RECURSIVE DIF FFT ROUTINE. If N is a regular power of 2.DIT and DIF Algorithms of FFT DBCET.Fo. 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): FUNCTION DIF(N. LOCAL N'. Given the above results.k'.f). Odd k.fe. The process of dividing the frequency components into even and odd parts is what gives this algorithm its name 'Decimation In Frequency'.n. 1. {trivial if N==1} ELSE BEGIN {perform 2 sub-transforms} .F.fo..N/2-1): or equivalently. k=2k'+1 (k'=0.. we can apply this method recursively until we get to the trivial 1 point transform.Fe. IF N==1 THEN RETURN(f).

Looking at the DIF routine above.DIT and DIF Algorithms of FFT DBCET. RETURN(F). it is easy to see that C(p) must satisfy the following recurrence relation: This has solution: or. 1. Fe:=DIF(N'. {size of sub-transforms} FOR n:=0 TO (N'-1) DO {perform N' DIF 'butterflies'} BEGIN fe[n]:= f[n]+f[n+N'].fe). {odd k} END. {even k} F[2*k'+1]:= Fo[k']. {even k} Fo:=DIF(N'. Azara N':=N/2. and is the basic primitive operation of the FFT. The process of calculating the fe and fo components is conventionally referred to as a (DIF) 'butterfly'. END. in terms of N (=2p): Dropping the constant scaling factors (including the log base) we get an algorithmic complexity of O(N. The algorithmic complexity of an FFT is usually quantified in terms of the total number of butterfly operations performed.fo).n). {even subset} fo[n]:=(f[n]-f[n+N'])*T(N. Let this number be C(p) for a 2p point transform.5 DIF FFT ALGORITHMIC COMPLEXITY (WHY IT'S FAST). {odd k} FOR k':=0 TO (N'-1) DO BEGIN F[2*k' ]:= Fe[k']. This is simplest form of DIF implementation and directly reflects the mathematical derivation of the algorithm.logN) . {odd subset} END.

DIT and DIF Algorithms of FFT DBCET. {shift right to get size of sub-transforms} BaseO:=BaseE+N'. {odd sub-transform} END.N'. {f is an external array} LOCAL N'. If bit reversed addressing is not available then you may need to produce a bit reversed index look up table to access the output. . VAR f).N'.f). f[BaseO+n]:=o. Azara 1. IF N==1 THEN {do nothing} ELSE BEGIN N':=N>>1. DIF(BaseE. This version of the DIF routine is a little simpler and more efficient than the first. 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. 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).BaseO.n. N= size of f } PROCEDURE DIF(BaseE.f). f[BaseE+n]:=e.N.6 A RECURSIVE 'IN PLACE' DIF FFT ROUTINE.e.f) performs DIF FFT on entire array f.o.N. but has the disadvantage that the output is in 'jumbly' (bit reversed) order. {even sub-transform} DIF(BaseO.n). END. {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.

there are BP (=2P) sub-blocks and therefore 2Pbutterflies which use a twiddle factor of +1. Azara It is worth noting that this is the simplest formulation of the 'in-place' DIF algorithm.. The twiddle factor used has index n*twiddle_step_size. In such cases there is no need to do a full blown complex multiply (remember this requires 4 real multiplies and 2 real adds). It is possible to write a reverse order DIF algorithm FFT which takes bit reversed order input and generates normal order output. Simple addition and subtraction will suffice. In general. 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. So. or if bit reversed addressing is available. this is not fundamental to the algorithm. It takes normal order input and generates bit reversed order output. in pass P (P=0. This parameter is also useful feature for multidimensional transforms. calculating these will require time consuming COS's and SIN's. Since the input to each sub-transform is now in bit reversed order. Specifically: Let us consider the last DIF FFT pass (N=2).7 TWIDDLE FACTOR TRICKS.) 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 the simple code above. the twiddle factors must also used in bit reversed order. The twiddle factor is given by: In practice. this will start at 1 and double for each sub transform.DIT and DIF Algorithms of FFT DBCET. this is always 1. This isn't difficult if the twiddle factors are taken from a table in bit reversed order. Instead we use the same table each pass and introduce an additional 'twiddle_step_size' parameter which starts at 1 and doubles after each pass. So what is needed is to look up table (an array of size N/2) which is calculated just once. We shall call butterflies that use one or other of these twiddle factors 'trivial butterflies'. The important thing to realise is that one doesn¶t need a separate table for each DIF pass (N halves each pass).p-1). it is merely a consequence of the simplest implementation. (The array bounds will never be exceeded. 1. In this case. because N halves on each pass and the maximum value of n is N/2-1. T2(0)=1 is the only twiddle factor used. the entire last pass consists of trivial butterflies. the first butterfly of any sub-block will use TN(0)=1. . Similarly. In the reverse order FFT. However.

DIT and DIF Algorithms of FFT DBCET. P<p-2) passes. then large FFT's benefit less than small FFT's. in each of the previous (N>4. but the result in Annex B is useful here): The total number of butterflies was calculated earlier: So. there are BP (=2P) sub-blocks and therefore 2P butterflies which use a twiddle factor of -j (at n=N/4) .8 COMPUTING DIF TWIDDLE FACTORS The below given diagram shows the signal flow diagram for an 8-point radix-2 DIF FFT. 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. 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). If this shortcut is exploited. So this pass also uses only trivial butterflies. for a 2p point DIF FFT. As in the above case. in a 512 point (p=9) DIF FFT about 1/3 of the butterflies will be trivial. For example. Azara In the penultimate (N=4) pass the butterflies will use either T4(0)=1 or T4(1)=-j. the proportion of trivial butterflies is about 3/p. 1. .

2.. . Nx=N/2. where 0  k  N/2P±1. 2. the unique Q factors are: k = 0.9 DIF DECOMPOSITION. Let Ny=2.. 1. Q = 02P/2 = 04/2 = 0 k = 1.. 1. Not counting the ±1 twiddle factors.DIT and DIF Algorithms of FFT DBCET... Azara The N-point DIF FFT has log 2(N) stages. For example. so f is decomposed as h: and F is decomposed as H: If we disregard scaling. . Each stage comprises N/2 butterflies. for the second stage (P = 2) of an N = 8-point DIF FFT.. Given those characteristics. the decomposed column transform is: which simplifies to: . log2 (N). the Pth stage has N/2P unique twiddle factors. numbered P = 1. N/2P±1 as indicated by the bold numbers above the upward-pointing arrows at the bottom of Figure. the kth unique twiddle factor phase angle for the Pth stage is computed using: The Kth DIF twiddle factor angle = k2P/2 . numbered k = 0. Q = 12P/2 = 14/2 = 2.

the decomposed twiddle/row transform is: which simplifies to: (The twiddle factor is 1 in the above case. .) In terms of the original 1D arrays. Azara Similarly.DIT and DIF Algorithms of FFT DBCET. these two equations correspond to even and odd k respectively: This is the decomposition used in the DIF algorithm.

N/2-1..DIT and DIF Algorithms of FFT DBCET.N-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. We also need values for k=N/2. But from the periodicity of the DFT we know: Also. because the two sub-transforms only give values for k=0.. In the DIF algorithm the time domain data was 'twiddled' before the two subtransforms were performed. 'Decimation In Time'.1 THE RADIX 2 DECIMATION IN FREQUENCY (DIF) ALGORITHM The Radix 2 Decimation In Time Algorithm (DIF) is very similar in concept to the Decimation in Frequency (DIF) Algorithm We define the FFT as: If N is even.N/2-1. There is a slight problem here. Azara CHAPTER 2 RADIX 2 DECIMATION IN TIME (DIT) ALGORITHM.. So. we have succeeded in expressing an N point transform as 2 (N/2) point sub-transforms. for k=0. where n'=0. The principal difference here is that the order we do things has changed..N/2-1: and . the above sum can be split into 'even' (n=2n') and 'odd' (n=2n'+1) halves. The final result is obtained by 'twiddling' the resulting frequency domain data. Here the two sub-transforms are performed first. As with the DIF algorithm. 2.

Fe. {odd n} FOR k:=0 TO (N'-1) DO {perform N' DIT 'butterflies'} BEGIN x=Fo[k]*T(N. END.DIT and DIF Algorithms of FFT DBCET.x.n'. . {odd n} END.fo). {twiddle the odd n results} subset} F[k ]:= Fe[k]+x. {even n} Fo:=DIT(N'. {bottom subset} END. Given the above results. Fe:=DIT(N'.f).F. LOCAL N'. {top F[k+N']:= Fe[k]-x.k).2 A RECURSIVE DIT FFT ROUTINE. 2.fo.fe. {trivial if N==1} BEGIN {perform 2 sub-transforms} N':=N/2.k. {even n} fo[n']:= f[2*n'+1].fe). RETURN(F). IF N==1 THEN ELSE RETURN(f). Azara where This will produce a simple recursive DIT FFT routine for any N which is a regular power of 2 (N=2p). 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): {f is an array of size N=2^p} FUNCTION DIT(N.Fo. {size of sub-transforms} FOR n':=0 TO (N'-1) DO BEGIN fe[n']:= f[2*n' ].

{odd n} . {shift right to get size of sub-transforms} BaseB:=BaseT+N'. We get a better and more efficient (recursive) in-place DIT routine as follows: {Perform in place DIT of N points starting at position BaseT.BaseB. {even n} DIT(BaseB.bot..top.logN) 2.3 DIT FFT ALGORITHMIC COMPLEXITY (WHY IT'S FAST).f). DIT(0.etc (recursively). N= size of f N. } PROCEDURE DIT(BaseT.k. As with the DIF algorithm. IF N==1 THEN {do nothing} ELSE BEGIN N':=N>>1. the number of butterfly operations C(p) for a 2p point DIT transform is given by: or. {split block into 2 halves} DIT(BaseT.f) performs DIT FFT on entire array f. {f is an external array} LOCAL N'. in terms of N (=2p ): Dropping the constant scaling factors (including the log base) we get an algorithmic complexity of O(N.N.N'.B.DIT and DIF Algorithms of FFT DBCET. Azara This is simplest form of DIT implementation and directly reflects the mathematical derivation of the algorithm.N.f). The input array f is in bit reversed order! So all the 'even' input samples are in the 'top' half.4 A RECURSIVE 'IN PLACE' DIT FFT ROUTINE. all the 'odd' input samples are in the 'bottom' half. VAR f).N'. 2.

{bottom subset} END. {twiddle the odd n results} subset} f[BaseT+k]:= top+bot. this is always 1. bot=f[BaseB+k]*T(N.5 TWIDDLE FACTOR TRICKS. this will start at 1 and double for each sub transform. As with the DIF algorithm. The twiddle factor is expressed as: In practice. Instead you use . this is not fundamental to the algorithm. Azara FOR k:=0 TO (N'-1) DO {perform N' DIT 'butterflies'} BEGIN top=f[BaseT+k]. So what you need is a look up table (an array of size N/2) which is calculated just once. This may or may not be a serious problem. {top f[BaseB+k]:= top-bot. In the simple code above. This parameter is also useful feature for multidimensional transforms. Since the output from each sub-transform is now in bit reversed order. it is merely a consequence of the simplest implementation.It is worth noting that this is the simplest formulation of the 'in-place' DIT algorithm. The important thing to realise is that you don't need a separate table for each DIT pass (N doubles each pass). 2. This requires the DIT 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 reverse order FFT. the twiddle factors must also used in bit reversed order.DIT and DIF Algorithms of FFT DBCET. depending on what the output is to be used for and whether or not your processor/programming language supports bit reversed addressing (most DSP's do). END. This isn't difficult if the twiddle factors are taken from a table in bit reversed order.k). but has the disadvantage that the input must be in 'jumbly' (bit reversed) order. or if bit reversed addressing is available. It takes bit reversed order input and generates normal order output. so you certainly don't want to do this for every butterfly (if you do your FFT will be anything but fast). it is possible to write a reverse order DIT algorithm FFT which takes normal order input and generates bit reversed order output. However. calculating these will require time consuming COS's and SIN's. If bit reversed addressing is not available then you may need to produce a bit reversed index look up table. This version of the DIT routine is a little simpler and more efficient than the first.

the kth DIT twiddle Q factor for the Pth stage is computed using: kth DIT twiddle factor Q = [ k2P/N ]bit-rev where 0  k  N/2±1. 1. numbered k = 0. . there is scope for optimising 'trivial' twiddle factors.DIT and DIF Algorithms of FFT DBCET. the Pth stage has N/2 twiddle factors.. 2. Each stage comprises N/2 butterflies. Azara the same table each pass and introduce an additional 'twiddle_step_size' parameter which starts at N/2 and halves after each pass.6 COMPUTING DIT TWIDDLE FACTORS The below given diagram shows the signal flow diagram for an 8-point radix-2 DIT FFT. .... Not counting the ±1 twiddle factors. log2 (N). numbered P = 1. Let us consider the above figure showing the butterfly signal flow of an 8-point DIT FFT.. The only differrence with the DIT algorithm is that it makes exclusive use of trivial butterflies in the first two passes. . Given those characteristics. N/2±1 as indicated by the upward arrows at the bottom of Figure 3. The q operation means the integer part of q. As with the DIF algorithm.. 2. The [z]bit-rev function represents the three-step operation of: [1] convert decimal integer z to a binary number represented by log2 (N)±1 binary bits. The N-point DIT FFT has log2(N) stages. 2. The twiddle factor used has index n*twiddle_step_size. Here's an algorithm for computing the individual twiddle factor angles of a radix-2 DIT FFT. (See the DIF algorithm for more detail).

Nx=2.. the k = 3 twiddle Q factor is: 3rd twiddle factor Q = [ 322/8 ]bit-rev = [ 1. as 012. The above [1]bit-rev operation is: take the decimal number 1 and represent it with log2 (N)±1 = 2 bits. i. Azara [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. for the second stage (P = 2) of an N = 8-point DIT FFT. As an example of using Eq. so f is decomposed as h: . reverse those bits to a binary 102 and convert that binary number to our desired decimal result of 2.DIT and DIF Algorithms of FFT DBCET.e.7 DIT DECOMPOSITION. Next. 2.(2). Let Ny=N/2.5 ]bit-rev = [1]bit-rev = 2.

DIT and DIF Algorithms of FFT DBCET. the decomposed twiddle/row transform is: which simplifies to: In terms of the original 1D arrays. the decomposed column transform is: which simplifies to: Similarly. these two equations correspond to 'top' and 'bottom' k respectively: . Azara and F is decomposed as H: If we disregard scaling.

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. the twiddle factors (one of which is again 1) are applied before the 2 point (row) FFT. Decomposing into 2p-1 rows and 2 columns yields the DIT algorithm. 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 the DIF algorithm butterfly. 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. Each butterfly requires exactly one complex multiply and two complex adds. the twiddle factors (one of which is 1) are applied after the 2 point (column) FFT. Use DIF for the forward transform and DIT for the inverse transform. You can easily conjugate a twiddle factor table. (In a DSP that supports single cycle adds. the issue isn't quite so simple. Both algorithms use exactly the same number if trivial (and 'semi-trivial') butterflies. 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. there would appear to be very little to choose between the DIF and DIT algorithms. 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.) Unfortunately. 3.1 DIF OR DIT? In terms of computational work load. If the processor supports bit reversed addressing (see below). One should try coding both the DIF and DIT butterflies and see which is the most efficient. Both perform exactly the same number of butterflies. So if both forward and inverse transforms are required and bit reversed addressing isn't available. both should take about 8 clock cycles). (For the inverse transform you will need to conjugate the twiddle factors. DIT starts with bit reversed order input and generates normal order output. multiplies and multiply/accumulates. then the choice would seem clear. Azara CONCLUSION. . The only difference is that if you decompose a 2p point transform into 2 rows and 2p-1 columns you get the DIF algorithm. In contrast. but the 'hard wired' -j butterflies can't use conjugated twiddle factors without rewriting the code.DIT and DIF Algorithms of FFT DBCET. In the DIT algorithm butterfly. then the physical ordering of the input or output data is not an important efficiency consideration.

..9 DIF Decomposition««««««««««««««««««««««««««««««08 CHAPTER 2 RADIX 2 DECIMATION IN TIME (DIT) ALGORITHM 2.......6 Computing DIT Twiddle Factors «««««««««««««««««««««««««14 2.12 2.....«««««02 1........«««««««««««.........7 Twiddle Factor Tricks«««««««««««««««..04 1..06 1...1 Radix 2 Algorithms«««««««««««««««««««..13 2.....5 Twiddle Factor Tricks«««««««««««««««««««««««««««««...01 1.......««««««««««««««07 1.....10 2....1 Introduction«««««««««««««««««««««««««««««««««01 1.......2 Fast Fourier Transforms Are Fast DFT Algorithms««««««««««««««««««. 17 .DIT and DIF Algorithms of FFT DBCET...1 DIF Or DIT?.....2...................3 DIT FFT Algorithmic Complexity (Why It's Fast)««««««««««.......05 1..5 DIF FFT Algorithmic Complexity (Why It's Fast )«««««««.7 DIT Decomposition««««««««««««««««««««««««««««««15 CONCLUSION 3....3 The Radix 2 Decimation In Frequency (DIF) Algorithm«««««««««««....8 Computing DIF Twiddle Factors «««««««««««...4 A Recursive DIF FFT Routine««««««««««««««««««««««««««03 1....6 A Recursive 'In Place' DIF FFT Routine««««««««««««««««««««««....1 The Radix 2 Decimation In Frequency (DIF) Algorithm««««««««««««««««..........««««««««««««««.. ....... Azara TABLE OF CONTENTS CHAPTER 1 RADIX 2 DECIMATION IN FREQUENCY (DIF) ALGORITHM 1.4 A Recursive 'In Place' DIT FFT Routine««««««««««««««««««««««..«««««««««01 1..........««««««««.....2 A Recursive DIT FFT Routine««««««««««««««««««««««««««11 2.........12 2...........

2010. Digital Signal Processing¶. Bonn Germany..cf.engineeringproductivitytools.wikipedia. Scitech Publications (India) Pvt. Ltd.HTM 5.cs. http://www.en. A Fast Program Generator of Fast Fourier Transforms.springerlink.DIT and DIF Algorithms of FFT DBCET.ac. http://www. Clausen.uk/Dave/Vision_lecture/node20.org/wiki/Fast_Fourier_transform 4. Babu. 3. 2. P. Azara BIBLIOGRAPHY 1. Michael and Meinard Muller.com/stuff/T0001/PT08. Ramesh. http://www. http://www. Hyderabad: February.html .com/content/t3840k17g800m648/ 6.