DIT and DIF Algorithms



Comments



Description

DIT and DIF Algorithms of FFT DBCET, AzaraCHAPTER 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 but the above expression is useful to get 'ball park' estimates. 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. The so called Radix 4 algorithms are similar in concept to the Radix 2 algorithms. 1. the above sum can be split into 'top' (n=0«. There are two different Radix 2 algorithms. k=2k' (k'=0.3 THE RADIX 2 DECIMATION IN FREQUENCY (DIF) ALGORITHM. namely a) 'Decimation In Time' (DIT) Algorithm b) 'Decimation In Frequency' (DIF) Algorithm.N/2-1): . An FFT is defined as: If N is even. the decomposition can be applied repeatedly until the trivial '1 point' transform is reached). 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) and 'bottom' (n=N/2«. These are sometimes slightly faster. This decomposition process can be applied to any composite (non prime) N..N-1) halves and re-arranged as follows: If we now consider the form of this result for even and odd valued k separately. In short.. Both of these rely on the recursive decomposition of an N point transform into 2 (N/2) point transforms. There is also an efficient algorithm for evaluating the DFT of sequences whose length is a prime number. Azara achieved in practice depends on other factors associated with algorithm implementation and coding efficiency... there is always an FFT algorithm (and usually several) which can be applied to any sequence length. F.n. 1.Fo.fe. If N is a regular power of 2. {trivial if N==1} ELSE BEGIN {perform 2 sub-transforms} .4 A RECURSIVE DIF FFT ROUTINE.k'. The process of dividing the frequency components into even and odd parts is what gives this algorithm its name 'Decimation In Frequency'..Fe. k=2k'+1 (k'=0. LOCAL N'.fo..DIT and DIF Algorithms of FFT DBCET. 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. Azara or equivalently.f). Given the above results.N/2-1): or equivalently. The factors TN are conventionally referred to as 'twiddle factors'. IF N==1 THEN RETURN(f). we can apply this method recursively until we get to the trivial 1 point transform. Odd k. RETURN(F). {even k} F[2*k'+1]:= Fo[k']. {even k} Fo:=DIF(N'.fe). This is simplest form of DIF implementation and directly reflects the mathematical derivation of the algorithm.DIT and DIF Algorithms of FFT DBCET. The algorithmic complexity of an FFT is usually quantified in terms of the total number of butterfly operations performed. {odd k} FOR k':=0 TO (N'-1) DO BEGIN F[2*k' ]:= Fe[k']. {odd subset} END. {odd k} END. Fe:=DIF(N'. Azara N':=N/2. Looking at the DIF routine above.logN) .fo). END. Let this number be C(p) for a 2p point transform. The process of calculating the fe and fo components is conventionally referred to as a (DIF) 'butterfly'.n).5 DIF FFT ALGORITHMIC COMPLEXITY (WHY IT'S FAST). in terms of N (=2p): Dropping the constant scaling factors (including the log base) we get an algorithmic complexity of O(N. {size of sub-transforms} FOR n:=0 TO (N'-1) DO {perform N' DIF 'butterflies'} BEGIN fe[n]:= f[n]+f[n+N']. 1. it is easy to see that C(p) must satisfy the following recurrence relation: This has solution: or. {even subset} fo[n]:=(f[n]-f[n+N'])*T(N. and is the basic primitive operation of the FFT. but has the disadvantage that the output is in 'jumbly' (bit reversed) order.n). END.N'.DIT and DIF Algorithms of FFT DBCET. 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= size of f } PROCEDURE DIF(BaseE.e. {shift right to get size of sub-transforms} BaseO:=BaseE+N'. o:=(f[BaseE+n]-f[BaseO+n])*T(N.f).6 A RECURSIVE 'IN PLACE' DIF FFT ROUTINE.n.N. This version of the DIF routine is a little simpler and more efficient than the first. 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). {split block into 2 halves} FOR n:=0 TO (N'-1) DO BEGIN e:= f[BaseE+n]+f[BaseO+n].o.f) performs DIF FFT on entire array f. {odd sub-transform} END.f). . DIF(BaseE. This may or may not be a serious problem. f[BaseE+n]:=e.N'.N.BaseO. Azara 1. {f is an external array} LOCAL N'. f[BaseO+n]:=o. IF N==1 THEN {do nothing} ELSE BEGIN N':=N>>1. 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). {even sub-transform} DIF(BaseO. it is merely a consequence of the simplest implementation. because N halves on each pass and the maximum value of n is N/2-1. This parameter is also useful feature for multidimensional transforms. the entire last pass consists of trivial butterflies.. this is always 1. In general. The twiddle factor used has index n*twiddle_step_size. calculating these will require time consuming COS's and SIN's. However. In this case. So what is needed is to look up table (an array of size N/2) which is calculated just once.DIT and DIF Algorithms of FFT DBCET. In the simple code above. In such cases there is no need to do a full blown complex multiply (remember this requires 4 real multiplies and 2 real adds). 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. 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.) The next trick is to notice that often the twiddle factor will be either +1 or -j (it will never be -1 or +j). . (The array bounds will never be exceeded. Similarly. Specifically: Let us consider the last DIF FFT pass (N=2).p-1).7 TWIDDLE FACTOR TRICKS. This isn't difficult if the twiddle factors are taken from a table in bit reversed order. It is possible to write a reverse order DIF algorithm FFT which takes bit reversed order input and generates normal order output. In the reverse order FFT. there are BP (=2P) sub-blocks and therefore 2Pbutterflies which use a twiddle factor of +1. The twiddle factor is given by: In practice. in pass P (P=0. So. or if bit reversed addressing is available. We shall call butterflies that use one or other of these twiddle factors 'trivial butterflies'. Simple addition and subtraction will suffice. this is not fundamental to the algorithm. It takes normal order input and generates bit reversed order output. this will start at 1 and double for each sub transform. Since the input to each sub-transform is now in bit reversed order. The important thing to realise is that one doesn¶t need a separate table for each DIF pass (N halves each pass). the first butterfly of any sub-block will use TN(0)=1. 1. T2(0)=1 is the only twiddle factor used. Azara It is worth noting that this is the simplest formulation of the 'in-place' DIF algorithm. the twiddle factors must also used in bit reversed order. If this shortcut is exploited. the proportion of trivial butterflies is about 3/p. then large FFT's benefit less than small FFT's.DIT and DIF Algorithms of FFT DBCET. 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. there are BP (=2P) sub-blocks and therefore 2P butterflies which use a twiddle factor of -j (at n=N/4) . P<p-2) passes. in each of the previous (N>4. For example. for a 2p point DIF FFT. in a 512 point (p=9) DIF FFT about 1/3 of the butterflies will be trivial. but the result in Annex B is useful here): The total number of butterflies was calculated earlier: So. As in the above case. So this pass also uses only trivial butterflies.8 COMPUTING DIF TWIDDLE FACTORS The below given diagram shows the signal flow diagram for an 8-point radix-2 DIF FFT. . Azara In the penultimate (N=4) pass the butterflies will use either T4(0)=1 or T4(1)=-j. 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). 1. 1. numbered k = 0. Nx=N/2. log2 (N). Given those characteristics. For example. the decomposed column transform is: which simplifies to: . the kth unique twiddle factor phase angle for the Pth stage is computed using: The Kth DIF twiddle factor angle = k‡2P/2 .. N/2P±1 as indicated by the bold numbers above the upward-pointing arrows at the bottom of Figure. the Pth stage has N/2P unique twiddle factors. 1. Q = 0‡2P/2 = 0‡4/2 = 0 k = 1.DIT and DIF Algorithms of FFT DBCET. 2. Azara The N-point DIF FFT has log 2(N) stages.. . for the second stage (P = 2) of an N = 8-point DIF FFT. Each stage comprises N/2 butterflies. the unique Q factors are: k = 0.9 DIF DECOMPOSITION. Not counting the ±1 twiddle factors.. Q = 1‡2P/2 = 1‡4/2 = 2. 2.. where 0 ” k ” N/2P±1.. numbered P = 1. so f is decomposed as h: and F is decomposed as H: If we disregard scaling. .. Let Ny=2. . these two equations correspond to even and odd k respectively: This is the decomposition used in the DIF algorithm.) In terms of the original 1D arrays. Azara Similarly. the decomposed twiddle/row transform is: which simplifies to: (The twiddle factor is 1 in the above case.DIT and DIF Algorithms of FFT DBCET. N-1. because the two sub-transforms only give values for k=0. The final result is obtained by 'twiddling' the resulting frequency domain data.. So. We also need values for k=N/2.. Here the two sub-transforms are performed first. where n'=0. There is a slight problem here..N/2-1.DIT and DIF Algorithms of FFT DBCET. the above sum can be split into 'even' (n=2n') and 'odd' (n=2n'+1) halves. for k=0. In the DIF algorithm the time domain data was 'twiddled' before the two subtransforms were performed. The principal difference here is that the order we do things has changed.N/2-1. Azara CHAPTER 2 RADIX 2 DECIMATION IN TIME (DIT) ALGORITHM. we have succeeded in expressing an N point transform as 2 (N/2) point sub-transforms. But from the periodicity of the DFT we know: Also.N/2-1: and . As with the DIF algorithm.. '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. 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. 2. x.fe. 2. .Fo. Fe:=DIT(N'. {odd n} FOR k:=0 TO (N'-1) DO {perform N' DIT 'butterflies'} BEGIN x=Fo[k]*T(N. {top F[k+N']:= Fe[k]-x. {twiddle the odd n results} subset} F[k ]:= Fe[k]+x.f).n'. Given the above results. RETURN(F). END.fo).k). IF N==1 THEN ELSE RETURN(f). {even n} Fo:=DIT(N'. {trivial if N==1} BEGIN {perform 2 sub-transforms} N':=N/2. LOCAL N'.F.Fe. 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.DIT and DIF Algorithms of FFT DBCET. {size of sub-transforms} FOR n':=0 TO (N'-1) DO BEGIN fe[n']:= f[2*n' ].fe). {bottom subset} END. Azara where This will produce a simple recursive DIT FFT routine for any N which is a regular power of 2 (N=2p).2 A RECURSIVE DIT FFT ROUTINE. {even n} fo[n']:= f[2*n'+1].k. {odd n} END. {split block into 2 halves} DIT(BaseT. {odd n} . Azara This is simplest form of DIT implementation and directly reflects the mathematical derivation of the algorithm.bot.N.N'. N= size of f N..top. 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. IF N==1 THEN {do nothing} ELSE BEGIN N':=N>>1.logN) 2.etc (recursively). {even n} DIT(BaseB.3 DIT FFT ALGORITHMIC COMPLEXITY (WHY IT'S FAST). 2. VAR f).DIT and DIF Algorithms of FFT DBCET. {shift right to get size of sub-transforms} BaseB:=BaseT+N'. } PROCEDURE DIT(BaseT.k. all the 'odd' input samples are in the 'bottom' half.f) performs DIT FFT on entire array f. As with the DIF algorithm.B.4 A RECURSIVE 'IN PLACE' DIT FFT ROUTINE. in terms of N (=2p ): Dropping the constant scaling factors (including the log base) we get an algorithmic complexity of O(N.BaseB. DIT(0.f).N'.N. {f is an external array} LOCAL N'. The input array f is in bit reversed order! So all the 'even' input samples are in the 'top' half.f). the number of butterfly operations C(p) for a 2p point DIT transform is given by: or. This may or may not be a serious problem.k). As with the DIF algorithm. This parameter is also useful feature for multidimensional transforms. However. So what you need is a look up table (an array of size N/2) which is calculated just once. the twiddle factors must also used in bit reversed order. 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). but has the disadvantage that the input must be in 'jumbly' (bit reversed) order. this is not fundamental to the algorithm. {top f[BaseB+k]:= top-bot. Azara FOR k:=0 TO (N'-1) DO {perform N' DIT 'butterflies'} BEGIN top=f[BaseT+k]. it is possible to write a reverse order DIT algorithm FFT which takes normal order input and generates bit reversed order output. END. The important thing to realise is that you don't need a separate table for each DIT pass (N doubles each pass). Instead you use . This version of the DIT routine is a little simpler and more efficient than the first. this will start at 1 and double for each sub transform. {twiddle the odd n results} subset} f[BaseT+k]:= top+bot.DIT and DIF Algorithms of FFT DBCET. bot=f[BaseB+k]*T(N. It takes bit reversed order input and generates normal order output. this is always 1. or if bit reversed addressing is available. In the reverse order FFT. 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.It is worth noting that this is the simplest formulation of the 'in-place' DIT algorithm. The twiddle factor is expressed as: In practice. it is merely a consequence of the simplest implementation. Since the output from each sub-transform is now in bit reversed order. 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.5 TWIDDLE FACTOR TRICKS. 2. {bottom subset} END. In the simple code above. so you certainly don't want to do this for every butterfly (if you do your FFT will be anything but fast). This isn't difficult if the twiddle factors are taken from a table in bit reversed order. The twiddle factor used has index n*twiddle_step_size.DIT and DIF Algorithms of FFT DBCET.. 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. . there is scope for optimising 'trivial' twiddle factors..6 COMPUTING DIT TWIDDLE FACTORS The below given diagram shows the signal flow diagram for an 8-point radix-2 DIT FFT. Azara the same table each pass and introduce an additional 'twiddle_step_size' parameter which starts at N/2 and halves after each pass. (See the DIF algorithm for more detail).. . Here's an algorithm for computing the individual twiddle factor angles of a radix-2 DIT FFT. . Each stage comprises N/2 butterflies.. 2. Given those characteristics. Not counting the ±1 twiddle factors. 2. 1. As with the DIF algorithm. The only differrence with the DIT algorithm is that it makes exclusive use of trivial butterflies in the first two passes. 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... N/2±1 as indicated by the upward arrows at the bottom of Figure 3. The q operation means the integer part of q. log2 (N). numbered k = 0. the Pth stage has N/2 twiddle factors. Let us consider the above figure showing the butterfly signal flow of an 8-point DIT FFT. numbered P = 1. 2. so f is decomposed as h: . and [3] convert the bit reversed number back to a decimal integer.(2). reverse those bits to a binary 102 and convert that binary number to our desired decimal result of 2. The above [1]bit-rev operation is: take the decimal number 1 and represent it with log2 (N)±1 = 2 bits.. i.e.5 ]bit-rev = [1]bit-rev = 2.DIT and DIF Algorithms of FFT DBCET. As an example of using Eq. Nx=2. Let Ny=N/2.5. Next. the k = 3 twiddle Q factor is: 3rd twiddle factor Q = [ 3‡22/8 ]bit-rev = [ 1. for the second stage (P = 2) of an N = 8-point DIT FFT. as 012.7 DIT DECOMPOSITION. Azara [2] perform bit reversal on the binary number as discussed in Section 4. 2. Azara and F is decomposed as H: If we disregard scaling.DIT and DIF Algorithms of FFT DBCET. these two equations correspond to 'top' and 'bottom' k respectively: . the decomposed column transform is: which simplifies to: Similarly. the decomposed twiddle/row transform is: which simplifies to: In terms of the original 1D arrays. One should try coding both the DIF and DIT butterflies and see which is the most efficient. DIT starts with bit reversed order input and generates normal order output. It is worth noting that if the FFT (DIF or DIT) uses 'hard wired' -j 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. the twiddle factors (one of which is 1) are applied after the 2 point (column) FFT. In contrast. Decomposing into 2p-1 rows and 2 columns yields the DIT algorithm.1 DIF OR DIT? In terms of computational work load. 3. but the 'hard wired' -j butterflies can't use conjugated twiddle factors without rewriting the code. then the choice would seem clear. So if both forward and inverse transforms are required and bit reversed addressing isn't available. Use DIF for the forward transform and DIT for the inverse transform. 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. Both perform exactly the same number of butterflies. You can easily conjugate a twiddle factor table. . there would appear to be very little to choose between the DIF and DIT algorithms. Each butterfly requires exactly one complex multiply and two complex adds. 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. Azara CONCLUSION. then one will need separate routines forward and inverse transforms in any case. multiplies and multiply/accumulates. In the DIF algorithm butterfly. 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. If the processor supports bit reversed addressing (see below).) Unfortunately. both should take about 8 clock cycles). (For the inverse transform you will need to conjugate the twiddle factors. the issue isn't quite so simple. In the DIT algorithm butterfly. the twiddle factors (one of which is again 1) are applied before the 2 point (row) FFT. 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 a DSP that supports single cycle adds. Both algorithms use exactly the same number if trivial (and 'semi-trivial') butterflies. then the physical ordering of the input or output data is not an important efficiency consideration.DIT and DIF Algorithms of FFT DBCET. ....1 The Radix 2 Decimation In Frequency (DIF) Algorithm««««««««««««««««..4 A Recursive 'In Place' DIT FFT Routine««««««««««««««««««««««.2....1 DIF Or DIT?.1 Radix 2 Algorithms«««««««««««««««««««..........«««««««««01 1..9 DIF Decomposition««««««««««««««««««««««««««««««08 CHAPTER 2 RADIX 2 DECIMATION IN TIME (DIT) ALGORITHM 2.DIT and DIF Algorithms of FFT DBCET......12 2..7 DIT Decomposition««««««««««««««««««««««««««««««15 CONCLUSION 3........05 1..04 1..««««««««...3 DIT FFT Algorithmic Complexity (Why It's Fast)««««««««««.«««««««««««..........2 Fast Fourier Transforms Are Fast DFT Algorithms««««««««««««««««««...6 A Recursive 'In Place' DIF FFT Routine««««««««««««««««««««««.........06 1...... .......««««««««««««««07 1...2 A Recursive DIT FFT Routine««««««««««««««««««««««««««11 2..««««««««««««««.8 Computing DIF Twiddle Factors «««««««««««..10 2........5 DIF FFT Algorithmic Complexity (Why It's Fast )«««««««.........3 The Radix 2 Decimation In Frequency (DIF) Algorithm«««««««««««.............01 1..... 17 ..............7 Twiddle Factor Tricks«««««««««««««««.4 A Recursive DIF FFT Routine««««««««««««««««««««««««««03 1.......«««««02 1.............. Azara TABLE OF CONTENTS CHAPTER 1 RADIX 2 DECIMATION IN FREQUENCY (DIF) ALGORITHM 1.....5 Twiddle Factor Tricks«««««««««««««««««««««««««««««........12 2....6 Computing DIT Twiddle Factors «««««««««««««««««««««««««14 2..13 2.1 Introduction«««««««««««««««««««««««««««««««««01 1.... http://www. Azara BIBLIOGRAPHY 1. Hyderabad: February.engineeringproductivitytools. http://www.cf. Bonn Germany.wikipedia. 2010.ac.en. Digital Signal Processing¶. Michael and Meinard Muller.uk/Dave/Vision_lecture/node20.springerlink. P.com/stuff/T0001/PT08.cs.DIT and DIF Algorithms of FFT DBCET. http://www. Ramesh. http://www.HTM 5. Clausen. A Fast Program Generator of Fast Fourier Transforms.html .. Scitech Publications (India) Pvt.com/content/t3840k17g800m648/ 6. 2. Babu. Ltd. 3.org/wiki/Fast_Fourier_transform 4.
Copyright © 2024 DOKUMEN.SITE Inc.