fft computation

Upload: tharindudesi1840

Post on 05-Apr-2018

246 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 FFT Computation

    1/10

    120 Chapter 3 I Discrete transforms

    where

    This subj ect is treated mor,e fully in Chapter 5.(7) DFfS may also be used in the ~ a m p of circular convolutions, and, by

    using augmenting zeros, in linear convolutions. These may be either time orfrequency domain convolutions. The time convolution theorem states that

    (3.34)where denotes circular convolution, and x1p(n), x2P(n) and x 3p(n ) are fin iteperiodic sequences of equal length.

    In an analogous manner to Equation 3.31, x3P(n) may also be writtenN - i

    x3P(n) = L x1P(m)x2p(n m) (3.35)m=O

    Fur:thermore,(3.36)

    where X3(k) =F0 [x3(n)].The fol lowing equation is the statement of the frequency convolution theorem:(3.37)

    whereN- i

    X 1(k) X2(k) = L X 1(m)X2(k - m) (3.3X)m=OEquation 3.34 gives rise to the statement that convolut ion in the time domain isequivalent to multiplication in the frequency domai n, whi le Equation 3.37 hasled to the observation that convolution in the frequency domain is equivalent tomult iplication in the time doma in. T hese statements may provide a means orremembering the re lationships. Convolution will also be treated in more detail inChap ter 5.

    3.4 Computational complexity of the OFTA large number of mu ltiplications and additions are req uired for the calculation of theDFf. Fo r an 8-point DF f the expansion for X(k) becomes (from Equation 3 .20)

  • 8/2/2019 FFT Computation

    2/10

    3.5 The decimation-in-time fast Fourier transform algorithm 1217X(k) == L x(n) e-Jk2" "18, k == 0, . . . , 7 (3.39)

    11= 0and letting k2n /8 == K this expands to

    X(k) == x(O) e-JKO + x( I) e -JKI + x(2) e-iK2 + x(3) e-,KJ + x(4) e-' K+ x(S) e - iKS + x(6) e-iK+ x(7) e-'K7, k = 0 , . . :, 7 (3.40)

    Equation 3.40 con tains eight terms on the right-hand side .Each term consists of amultiplication of an exponential term which is always complex by another term whichis real or co mplex (for example, rea l for a vo ltage time series). Each of the productterms is added together. There are therefore eight complex,multiplications and sevencomplex additions to be calculated. For an N-point OFT, the re will beN and N - Iof them respec tive ly . There are also eight harmonic co mponents to be evaluated(k = 0, . . . , 7). This number becomes N for anN-point OFT. Therefore the calculationof the eight-point OFT requires 82 == 64 comp lex mu ltip lications and 8 x 7 == 56complex additions. For anN-point OFT these become N 2 and N(N- I) respectively. IfN = 1Q24, then approximately one million co mplex multipli cations and one millioncomplex additions are required. Clearly some means of reduc ing these numbers idesirable.

    The amount of computation involved may be reduced if we note tha t there is aconsiderable amount of built-in redundancy in equations such as Equation 3 .4 . Forexample if k = 1 and n == 2, e-ik2"" 18 =e-i"12, and if k =2 and n = I , e-'"2"" / 8 =e-i"12 also.

    I -

    The decimation-in-time fast Fourier transformalgorithmIn this section it wi ll be shown how the computational redundancy inherent in theOFT is used to reduce the number of different calculations necessary, therebyspeeding up the computat ion. For a 1024-point OFT the number of calculationsrequired can be reduced by a factor of 204.8. The algo rithms which can achieve thisare given the title ' fast Fourier transform ' , or FFT in short. When applied in the timedomain the algorithm is referred to as a decimation-in-time (DI T) FFT. The fi rs t DITalgorithm was d ue to Coo ley and T ukey (l965), after whom it is o ften named.Dec imation th"en re fers to the significant reduction in the number of calculationsperformed on time domain data. It is no teworthy that the co mputational savings willbe seen to increase as N 2 - (N 2) log2 N.

    Fi rst the notation will be simpiified and some mathematica l re lationships will bees tablished. Thus Equation 3.20 will be re-written as

    N - 1X,(k) = I.. XII e - j21fnk/N, k = 0, . . . , N - I (3.41)n=O

  • 8/2/2019 FFT Computation

    3/10

    122 Chapter 3 I Discrete transforms

    Also, the factor e-j2rr/Nwill be wntten as WN, thus

    so that Equation 3.41 becomesN - 1

    X 1(k) = L k =0, . . . , N - 1n=O

    It is worthwhile at this point to note some relationships involving WN. First,W 2 _ (e-j2rr/N)2_ e-j2rr2/N_ e-j2r/(Nj2) _ WN - - - - N/2

    Second,= : / 2 = e-j(2rr/NXN 2) = e-Jtr= -

    Summarizing the useful results concerning WN or convenience, we have

    = w N/2= -

    (3.42)

    (3.43)

    (3 .44)

    (3.45)

    (3.46a)(3.46b)(3.46c)

    IIn exploiting the -computational redundancy expressed by Equations 3.46 the datasequence is divided into two equal sequences, one of even-numbered data, and one ofodd-numbered data. For the sequences to be of equal length, they must all contain aneven number of data. I f he original sequence consists of an odd number of data, thenan augmenting zero should be added to render the number of data even. This allowsthe DFf , X1(k), to be written in terms of two DFfs, X 11 (k) and X12(k), which are theDFTs of the even-valued data and of the odd-valued data respectively (see Table 3.1 ).Thus theN-point DF T is converted into two DFTs each of N/ 2 points. This process isthen repeated until X 1(k ) is decomposed into N / 2 DFfs, each of two points, both ofwhich are initial data. Thu s, in practice, the initial data is re-ordered and theN 2 twopoint DFTs are calculated by taking the data in pairs. These DFT outputs are suitablycombined in fours to provide N/4 four-point DFfs which are computed andappropriately combined to produce N/ 8eight-point DFfs which are computed, and soon until the final N-point DFT, X1(k), is obtained . At each stage common factors whichare powers of WN are incorporated to reduce the number of complex calculations. Thisprocedure is justified as follows.

    The suffixes, n, in Equation 3.43 extend from n = 0 ton= N - I , corresponding tothe data values x 0, x 1, x2, x 3, . .. , x N- I The even-numbered sequence is x 0, x 2, x 4, . .. ,x N_2, and the odd-numbered sequence is x 1, x 3, . .. , x N- I Both sequences containN/2 points. The terms in the even sequence may be designated x2 with n = 0 ton = N/ 2 - l while those in the odd sequence become x2,. +I Then Equation 3.43may be re-written

  • 8/2/2019 FFT Computation

    4/10

    Table 3.1 Structure of an 8-poin t FFT.Line Linenumber contentI Data sequence A0 Au X0 X 1X2 XJ X X5 X6 X12 8-po int DFT of Au X1(k) = X11(k) + W ~ X d k )

    -3 Re-ordered A0 : AI x0 x2 x.x6 A! X1x,x5 x1two sequences,A1and A2

    4 4-point DFTs x1 1Ck) = X21(k) + X 2 2 C k ) X12Ck) = X2J(k) + . ( k ) of A1and A25 Re-orde red AJ x0 x4 A. x2x6 As XI Xs A6 x 3 x1sequences A1and A2:four sequences

    A1, A., A ~ , A66 2-point DFTs of X!l(k) = Xo + X X!ik) =X! + . x 6 X2.1(k) =XI + X2.(k) = x1 +AJ, A4 , A5,

    - - '- - - - -

    k ranges

    0, .. . ,N -1(0, . .. '7 )

    ..0, . . . , N/ 2 - 1(0, . . . '3 )

    O, . . . , N/4-1(0, I) .

    N ranges0, . . . '70, . . . . 7

    0 . . . ' 3

    0, . . . ' 3

    0, I

    0, I

    ....U1- i::T.,Q.(! )n3"2:.c;1.z.3".,-'-n0

  • 8/2/2019 FFT Computation

    5/10

    124 Chapter 3 I Discrete transformsN/2-1

    2u Nn=O'-v--------'even sequence

    N/2-1+ W(2n+llkL..J 2 t ~ + Nodd sequence

    N2-1 N/2-1= L x 2n + wzL x 2n+lw:\ k =0, . . . ' N - In=O n-=-0

    Using Equation 3.46b gives ~ k = so Equation 3.47 becomesN2-1 II =N2-1

    X(k) = L x 2n + wz L x21+l ~ ~ 2 k =0, . . . , N - I11=0 n=O

    Equatio n 3.48 may be written

    (3.47 1

    (3.4X)

    (3.49)On comparison of Equation 3.49 with Equa tion 3.43, it is seen that X11(k) is indeed theDF f of the even sequence, while X12(k) is that of the odd sequence. Therefore, "'prev iously stated, the DFf , X1(k) , can be expressed in terms of two DFfs : X11 (.l. land X12(k) . The factor WZ2 occurs in both X11(k) and X12(k) and needs calculationonce o nly.

    Table 3.1 illustrates the process for an 8-point DFf. Line I gives the data while line2 g ives an expression for the D Ff of the data in term s of the D Ffs of the even and oddI -sequences, X11 (k) and X 1l k) respec tively . Line 3 shows the re-ordered da ta fro n1which X11(k) and X12(k) are derived . Line 4 gives the D Ffs of the data sequences olline 3 in terms of the DFTs of their even and odd sequences , X21 (k), X22(k), X23(k) andX24(k). Th ese sequences are shown in line 5, and are seen to be the ultimate 2-poinlsequences, whose D Ffs are X21(k), X22(k), X23(k) and X2i k) and are expressed in e of the da ta in line 6. Thu s the single 8-point D Ff has been decomposed in.to folll2-po int D Ffs, each one of which produces two values, for example X21(0) and X21 ( I lin the case of X21(k). This process involved two decompositions, and the we ight\wzwe re sq uared at each step. Considering line 6 it seen that

    X11 (k) =x0 + k =0, . .. , N/ 4 - I, that is k = 0, 1 (3.50)Thus

    whilex 21(1) = Xo + WN/4x4

    = 0 + W2x 4 = 0 + e-i2"12x4 = 0 + e-i"x4 = 0 - X4Similarly,

  • 8/2/2019 FFT Computation

    6/10

    3.5 The decimation-in-time fast Fourier transform algorithm 125

    X22 (0) = x2 + x6 ,X23(0) = x 1 + x5,X24(0) = X3 + X7,

    Xn (l) = x2 - x6X23(1) =X I - Xsx24( 1.) = x3 - .x7,

    from which we observe that the va lu c:rs with k = I differ only by a s ign from those withk =0. This point is emphasized if X 11(k) (k =0, I , 2, 3) is considered. Now,SO,

    Now

    and

    X,,(O) =X21(0) + ( 0 ) =X21(0) + X22(0 )X 11 (1) = X2,( l ) + W ( 1 ) = X21( I)+ e-i"12X22 ( l )

    = X2,(1 ) - jXzz(l)X"(2) = Xz,(2) + =X21 (2) + e-i

  • 8/2/2019 FFT Computation

    7/10

    126 Chapter 3 I Discrete transforms

    Drawing these results together givesX,,(O) =X2,(0) +X22(0) =X21 (0) + ~ 2 X11 (2) = X2, (0)- X22(0) = X2 , (0) - ~ 2 ( 0 ) X"(l) = X2, ( l ) - jXnO) = x 2,0 ) +__w ~ x 2 2 ( l ) x "(3) =x 2,(1) + jX220 ) =x2,(l) =- ~ x 2 2 (

    (3.58a)(3.58b)(3.58c)(3.58d)

    Inspection of these equations shows how the DFTs X11(k) are related to the DFTs oftheir even-numbered and odd-numbered data, and that X11 (0) and X11(2) are given byexpressions with common terms which differ only in one sign. The same is true ofX11 (1) and X11 (3). Equations such as these are known as recomposition equationsbecause starting from the data pairs and forming X21 (k), X22(k), X23(k) and X24(k)allows X11 (k) and X12 (k) to be found, and hence X1(k). The number of complexadditions and multiplications involved is reduced in this way because (i) the

    (a)

    X"(3) = X2,(1 ) - Wi X22(1 )(b)

    X21 (0) X,,(O) = X2,(0) + ( 0 )

    Xz,{l) XII ( I )= x2,(1) + WiX2z( l)X,(O) X11 (2) = X2,(0)- 2

    X: 20 ) X 11 (3) = X21(1) - Wi X22(1)(c)

    Figure 3.4 FFT butterflies.

  • 8/2/2019 FFT Computation

    8/10

    3.5.1

    3.5 The decimation-in-time fast Fourier transform algorithm 127

    recomposition equations are e x p r e ~ s e d in terms of powers of the recurring factor WN,(ii) use is also made of relationships of the type X2 1(2) =X21(0) and X2 ,(3) =X21 (1),and (iii) the presence of only sign differences in the pairs of expressions is exploited.This algorithm is known as the Cooley-Tukey algorithm.

    The butterflyEquations 3.58 may be represented diagrammatica lly by exploiting the symmetrycentred on the sign differences and taking the equations in pairs. Thus from Equations3.58a and 3.58b the outputs of the recompositions are X 11 (0 ) and X 11(2) formed fromthe inputs X21(0) and X22 (0). This is illustrated in Figure 3.4(a). The inputs are at theleft-band side of the cross, the outputs to the right. Figure 3.4(b) shows how the outputs X 11 ( I ) and X11(3) are obtained diagrammatically. By overlapping Figures 3.4(a)and 3.4(b), a co mposite diagram is obtained in which the output DFTs are arranged inorder of increasing k. This is shown in Figure 3.4(c). The structure of Figure 3.4(a) or3.4(b) is referred to as a 'butterfly ', being reminiscent of the symbolic representationof the insect. The entire 8-point FFT may be dep icted in this manner as in Figure 3.5.

    x2 ,COJ XII(O)Xo X1(0)

    x. X,( I )

    x2 X 1(2)

    x6 X1(3)

    x, X1(4)

    X5 X 1(5)

    XJ X 1(6)

    X1(7)x7 X24(1)+-4 off 2-point DFTs 2 of f 4-pointDFTs-+-1 off 8-pointOFf-+Stage I (S = I ) Stage 2 (S = 2) Stage 3 (S = 3)

    Figure 3.5 FFf butterflies for an 8-point OFT: BW 3, memory separation between pointscontributing to uppermost butterfly of stage 3; 882, memory separation betweenbottom points of butterflies in stage 2 with the same weighting factor.

  • 8/2/2019 FFT Computation

    9/10

    128 Chapter 3 I Discrete transforms

    Example 3.5 I t will now be instructive to obtain the OFT of the sequence {I , 0. 0, I}, p r e v i o uevaluated in Section 3.2, by means of the decimation-in-time FFT a lgorithm. 1.a four-point OFT with Xo = I' XI = 0, Xz = 0, x3 = I ' and Xl(k) = x l l (k ) + Ik = 0. I, 2. 3. The re-ordered sequence is x0 . x2, x 1, x3.We can now utilize the top le'ft-hand corner of Fig ure 3.5 to work out the OFIPoints x0, xJ, x2 , x6 are replaced by x0 , x2.x1, x3 , and the required OFT values are X 11 (111XII( I), x 11(2) and X11(3). Therefore,

    x 21(0) =Xo + x2 = Ix21(1) = Xo- Xz = IX 22(0) =XI +X ) = IX22( l )=x 1-x3 =- lX 11(0) = X 21 (0) + ( 0 ) = I + I = 2X l l( l ) =X 21 (1)+ I +e -JI'12( - I )= l + jXll(-2) = X z1CO)- 2 ( 0 ) = I - I = 0X 11 (3) =X21 ( 1)- 2 1-j

    These values are the same as those obtained in Section 3.2, but were more readihobtained us ing the FFT algorithm. This co ncl usion is general and the computation:dsav ings increase as the numbe\ of data increases.

    3.5.2 Algorithmic developmentInspection of Figure 3.5 shows that in order to execute the FFT the program mu 'tre-order the input data and perform the butterfly computations. These will nm1be considered in turn. (See also Strum and Kirk, 1988.)

    3.5.2.1 Re-ordering the input dataWhile it might at first appear that there is no obv ious way to program the re-orderinrof the input data, there is. The secret is to think in binary terms. Tab le 3.2 shows in thrfirst co lumn the required ordering of the data for input to the butterny network a'given by Figure 3.5. Each value is assumed to be stored in a binary memory a d d r e s ~ These addresses are given in the second co lumn. The third co lumn shows e ~ r memory addresses bit reversed. If these bit-reversed addresses are taken to co rrespondto the binary addresses of the original data sequence, commencing with x(O) at 000.then the corresponding data va lues are given in the fourth column , which is seen tocontain the original data sequence. Thus the addresses of the re-ordered da ta arrseen to be the bit-reversed addresses of the original data sequence. The program

  • 8/2/2019 FFT Computation

    10/10

    3.5 The decimation-in-time fast Fourier transform algorithm 129

    Table 3.2 Sequence re-ordering by bi t reversa l.Required sequence forbutterfly computation

    Xox.Xzx6XIx5XJx1

    Binary addresses ofrequired sequence data

    000 '10001011000 1101011Ill

    Bit-reversedaddresses

    00000 101001110010111 0111

    Correspondingsequence =origlnaf

    data sequence

    therefore required to convert the data po in t numbe rs (0 to N - 1) to binary, to bitreverse these binary numbers and to conve11 them back to the denary numbers whichare the addresses of the re-ordered data. Conversion to binary may be achieved byrepetitively di viding by two when the remainders g ive the reverse-orde red digits ofthe corresponding binary number which is therefore the required binary address of there-ordered sequence. These remai nders may be obta ined by using the MOD func tionob tainable in a high leve l language, for example MOD(K,2) gives the remai nder ondividing the denary value K by 2. 1The integer part of K /2 is found by pe rform ingintege r division. The remaining digits are found by repea ting this process until log2 Ndivisions have bee n made. This is becau se the data is to con sist of 2"' = N data po in tsso each address requires m digits and is divisible by two m times, where 111 = log2 N.The /th bit of the new address i the binary coeffic ient of 2"'+1 so the new address(NADDR) may be found us ing a DO loop for a particular va lue o f K (K=lAD DR) whichruns from 1=0 to l=m- 1 and which takes the re mainde rs (RMNDR) fro m the successive integers o btained after dividing K=IADDR by two. The pse udo-code required forthi s is

    DO FOR 1=0 TO m- 1RMNDR:=MOD(IADDR,2)NADDR:=NADDR+RMNDRx2ml-lIADDR :=IADDR/ 2END DOThis DO loo p has to be nes ted inside another DO loop, the func tion of which is toextrac t the original data from a co mplex anay DATA(K) , K=O to N-1 being the datumpoint number which is also the number of the complex element in the array andcorresponds to the initial address of the datum , and to insert the re-ordered da ta intothe array NEWDATA(NADDR). Th e da ta in NEWDATA is now in the co rrec t seq uencefor the butterfly computations. The co mplete pseudo-code is