Biomedical Signal processing Chapter 9 Computation of the Discrete Fourier Transform Zhongguo Liu Biomedical Engineering School of Control Science and Engineering, Shandong University 2017/7/28 1 Zhongguo Liu_Biomedical Engineering_Shandong Univ. Chapter 9 Computation of the Discrete Fourier Transform 9.0 Introduction 9.1 Direct Computation Of The Discrete Fourier Transform 9.2 decimation-in-time FFT Algorithms 9.3 decimation-in-frequency FFT Algorithms 9.4 practical considerations 9.5 ...... 2 9.0 Introduction Implement a convolution of two sequences by the following procedure: 1. Compute the N-point DFT X 1k and X 2 k of the two sequence x1n and x2 n 2. Compute X 3 k X 1k X 2 k for 0 k N 1 3. Compute x3 n x1 n N x2 n as the inverse DFT of X 3 k Why not convolve the two sequences directly? DFT has efficient FFT(Fast Fourier Transform) algorithms that can be orders of magnitude more efficient than others. 3 9.1 Direct Computation of the Discrete Fourier Transform The DFT pair was given as N 1 X k n 0 1 j 2 / N kn x[n]e , x[n] N N 1 X k e k 0 DFTcomputational complexity: Each DFT coefficient requires N complex multiplications; N-1 complex additions All N DFT coefficients require N2 complex multiplications; N(N-1) complex additions 4 j 2 / N kn 0k , n N 1 4 9.1 Direct Computation of the Discrete Fourier Transform Most fast methods are based on Periodicity properties Periodicity in n and k; j 2 / N k N n j 2 / N kn j 2 / N k n N e e e kn N W k ( N n) N W ( N k )n N W , e j 2 / N WN Complex conjugate symmetry WNk ( N n ) WN kn (WNkn )*, e j 2 / N k N n e (WNk ( N n ) )* (WN kn )* WNkn j 2 / N kN j 2 / N k n e e j 2 / N kn 5 5 9.1.1 Direct Evalutation of the Defination of DFT N 1 X k x[n]e j 2 / N kn n 0 N 1 N 1 x n WNkn n 0 j Re x[n] ImW Imx[n] Re W kn kn X k Re x[n] Re WN Im x[n] Im WN n 0 kn N kn N k 0,1, 2, , N 1 Complexity in terms of real operations 4N2 real multiplications N(4N-2) real additions : N (2(N-1) +2N ) 6 6 9.1.1 Direct Evalutation of the Defination of DFT k ( N n) kn kn Conjugate symmetry: WN WN (WN ) * N 1 Re X k Re x[n] Re WNkn Im x[n] Im WNkn n 0 N 1 2 group terms in the summation for n and (N-n): N 1 kn kn Re x [ n ] Re W + Re x [ n ] Re W N N n 0 n N 2 n=N n,n =N n N 2 N 1 2 1 k [ N n ] Re x [ N n ] R e W N n 0 kn k [ N n ] Re x[n] Re WN Re x[ N n] Re WN N n 0 kn 1 2 Re W N kn Re x[n] Re x[ N n] Re WN 乘法次数减少一半 n 0 7 9.1.1 Direct Evalutation of the Defination of DFT Conjugate symmetry: WNk ( N n ) WN kn (WNkn ) * N 1 Re X k Re x[n] Re WNkn Im x[n] Im WNkn n 0 N 1 2 group terms in the summation for n and (N-n): kn k [ N n ] Re x[n] Re WN Re x[ N n] Re WN n 0 N 1 kn 2 Re W N kn Re x[n] Re x[ N n] Re WN n 0 N 1 2 similarly, kn k [ N n ] Im x [ n ] Im W Im x [ N n ] I m W N N kn n 0 N 1 Im WN 乘法次数减少一半 2 Im x[n] Im x[ N n] Im WNkn n 0 8 9.1.2 The Goertzel Algorithm Makes use of the periodicity W kN e j 2 / N Nk e j 2 k 1 N Multiply DFT equation with this factor X k e j 2 / N kN Define yk n N 1 x[r ]e r 0 j 2 / N rk x[r ]e N 1 x[r ]e r 0 j 2 / N k n r r j 2 / N k N r h[n r ] u n r x[n]* h[n] n N,0 r N -1 0 r N -1 using x[n]=0 for n<0 and n>N-1, X k yk n n N yk[n] can be viewed as output of a filter to input x[n] Filter impulse response : h[n] e j 2 / N kn u n X[k] is the output of the filter at time n=N. DFT of x[n] Goertzel Filter 9 9 9.1.2 The Goertzel Algorithm kn j 2 / N kn Goertzel Filter: h[n] e u[n] WN u[n] 1 Hk z 1 WN k z 1 k 0,1,..., N -1 for causal LTI system x[n] is a complex x[n]=0, n<0 yk [n] yk [n 1]WN k x[n], n 0,1,..., N , yk [1] 0 X k yk n n N , k 0,1,..., N -1 N 1 X k x[n]WNkn n 0 Computational complexity for one X[k]. 4N real multiplications; 4N real additions; Slightly less efficient than the direct method(4N, 4N-2); But it avoids computation and storage of WNkn (N2 个) k WN (N 个) 10 Second Order Goertzel Filter Goertzel Filter 1 Hk z k 1 1 WN z y[n] 为便于分析 y[n] yk [ n ] 1 1 e j 2 k 1 N z x[n]=0, n<0 Multiply both numerator and denominator for causal LTI system j 2 k 1 k 1 N 1 WN z 1 e z Hk z 2 2 2 k 1 2 j k j k 1 1 1 2 cos z z N N 1 e z 1 e z N y[1] y[2] 0 2 k y[n] y[n 2] 2 cos y[n 1] x[n], n 0,1,..., N N k 实现极点因 yk [n] y[n] WN y[n 1] 实现零点因 式 k yk [ N ] y[ N ] WN y[ N 1] 式 X k , k 0,1,..., N -1 每个K只需计算 1次 11 Second Order Goertzel Filter 除n=0时y[0]=x[0], y[n]对每 个n有两个实数乘4个实数加 实现极点因式: 2 k y[n] y[n 2] 2 cos y[n 1] x[n], n 0,1,..., N N 实现零点因式: yk [ N ] y[ N ] WNk y[ N 1] X k , k 0,1,..., N -1 same Complexity for one X[k] ( x[n], y[n] is complex). Poles: 2N real multiplications 2 ( N k ) and 4N real additions y[n] y[n 2] 2 cos y[n 1] x[n], n 0,1,..., N Zeros: computed onlyNonce: 4 real ×and 4 real + . total: 2(N+2) real ×and 4(N+1) real + . 乘 N /2 Complexity for all N X[k] N Each pole is used for X[k], X[N-k] , k 0,1,..., 2 -1 Approximately N2 real multiplications and 2N2 real additions. More efficient than the direct method. 12 12 Second Order Goertzel Filter 2 k y[n] y[n 2] 2 cos y[n 1] x[n], n 0,1,..., N N yk [ N ] y[ N ] WNk y[ N 1] X k , k 0,1, ..., N If we only need to evaluate M X[k] , the total computation is proportional to NM, Goertzel method is attractive when M is small. The computation for FFT algorithm is Nlog2N. if M < log2N, either Goertzel Algorithm or direct method is more efficient than FFT. 13 13 9.2 Decimation-in-Time FFT Algorithms Makes use of periodicity and symmetry of WNkn Consider special case of N=2ν : integer ν power of 2 Separate x[n] into two sequences of length N/2 Even-numbered sequence ; Odd-numbered sequences . N 1 X k x[n]e j 2 / N kn , n 0 x[n]e n even 14 j 2 / N kn e j 2 / N x[n]e WN j 2 / N kn n odd 14 9.2 decimation-in-time FFT Algorithms X k x[n]e j 2 / N kn n even x[n]e j 2 / N kn n odd Substitute variables n=2r for n even and n=2r+1 for odd X k N /2 1 x[2r ]W 2 rk N r 0 N /2 1 r 0 rk N /2 x[2r ]W g[r] W k N G k WNk H k , x[2r 1]W 2 N W N/2-point DFT N /21 x[2r 1]W h[r] 2 r 1 k N r 0 N /2 1 r 0 N /2 1 rk N /2 j 2 2 e N X 1k x1[m]W m0 j 2 e N /2 mk N /2 WN /2 G[k] and H[k] are the N/2-point DFTs of each subsequence: N g[n]=x[2n] and h[n] =x[2n+1] , n 0,1,..., -1. 2 15 15 9.2 decimation-in-time FFT Algorithms X k N /2 1 N /2 1 x[2r ]W W x[2r 1]W N k ,..., N -1 N 2 G G kkW H kW k , , kH 0,1,..., 1 k 0,1,..., N -1 rk N /2 r 0 k NN 2 k N k N N N X k G k WN 2 2 k N 2 r 0 2 N 2 N H k G k WN 2 2 r ( k N / 2) j r ( k N /2 ) W e N /2 N /2 rk N /2 k j 2 rk e N /2 N 2 H k WNrk/2 N G k G k , 2 N H k H k 2 G[k] and H[k] are the N/2-point DFTs of each subsequence: N g[n]=x[2n] and h[n] =x[2n+1] , n 0,1,..., -1. 16 2 16 X k N /2 1 r 0 N /2 1 k using DIT x[2r ]WNrk/28-point WNk DFT x[2r 1] WNrk/2 G k W N H k r 0 N k N X k G k WN 2 H k 2 N G k + G k 2 N H k + H k 2 W 0 N W 1 N WN2 WN3 WN4 W W 17 Figure 9.4 5 N 6 N 0 1 2 3 N k 0,..., -1 2 4 5 6 7 WN7 k N ,..., N -1 2 computational complexity X k G k WNk H k Two N/2-point DFTs N N 1 exactly: 2 2 2 2(N/2)2 complex multiplications 2(N/2)2 complex additions Combining the DFT outputs N complex multiplications N complex additions Total complexity N2/2+N complex multiplications 2 N N N complex additions. exactly: 2 1 N 2 2 2 More efficient than direct DFT when N>2 N2/2+N 18 18 9.2 decimation-in-time FFT Algorithms Repeat same process , Divide N/2-point DFTs into Two N/4-point DFTs Combine outputs N=8 0 N /2 1 N /2 W W 2 N /2 W W W W 0 N 2 N 4 N WN3/2 WN6 19 19 9.2 decimation-in-time FFT Algorithms After two steps of decimation in time W20 WN0 Repeat until we’re left with two-point DFT’s 20 W21 WNN /2 20 9.2 decimation-in-time FFT Algorithms flow graph for 8-point decimation in time binary code: n2 n1n0 N=8=23 3 stages: N=2m m=log2N m级: 每级乘法 和加法个数为 N Complexity: Nlog2N complex multiplications and additions 21 21 Butterfly Computation Flow graph of basic butterfly computation W r N WNr r N /2 WN r N N /2 N =W W WNN /2 1 We can implement each butterfly with one multiplication Final complexity for decimation-in-time FFT (N/2)log2N complex multiplications and Nlog2N additions 22 22 9.2 decimation-in-time FFT Algorithms DIT flow graph for 8-point decimation in time N=8=23 generalized to N=2m m=log2N m级: 每级乘法 和加法个数为 N WN0 WN2 WN4 WN2 WN2WNN /2 WN6 WN6 WN2WNN /2 Complexity: Nlog2N complex multiplications and Nlog2N additions 23 23 9.2.1 Generalization and Programming the FFT Final flow graph for 8-point decimation in time N=8=23 0 generalized to N=2m m=log2N m级: 每级乘法 N/2个,加法N个 WN W W 0 N 2 N WN2 WN4-1 WN6 WN2 -1 the figure serves as proof, WN2 and for FFT WN6 -1 programming. Complexity: (Nlog2N)/2 complex multiplications and Nlog2N additions 24 24 9.2.2 In-Place Computation同址运算 DIT flow graphs require two sets of registers: Input, output In-Place Computation needs one or memory units set of registers. X 0 0 x 0 X 0 1 x 4 X 0 2 x 2 X 0 3 x 6 X 0 4 x 1 X 0 5 x 5 X 0 6 x 3 X 0 7 x 7 25 x 0 x 4 x 2 x 6 x 1 x 5 x 3 x 7 X 1 0 X 1 1 X 1 2 X 1 3 X 1 4 X 0 X 1 X 2 X 3 X 4 X 1 5 X 5 X 1 6 X 6 X1 7 X 7 25 9.2.2 In-Place Computation同址运算 Note the arrangement of the input indices Bit reversed indexing(码位倒置) X 0 000 X 0 0 x 000 x 0 X 0 001 X 0 1 x 100 x 4 X 0 010 X 0 2 x 010 x 2 X 0 011 X 0 3 x 110 x 6 X 0 100 X 0 4 x 001 x 1 X 0 101 X 0 5 x 101 x 5 X 0 110 X 0 6 x 011 x 3 X 0 111 X 0 7 x 111 x 7 X 0 X 1 X 2 X 3 X 4 X 5 X 6 X 7 26 26 normal order x n2n1n0 binary coding for position: 对应x[n] 从上向下出现的顺 的序号 n2 n1n0 n2 n1序 n0 x 000 000 x 001 001 x 010 010 x 011 011 x 100 100 x 101 101 x 110 110 x 111 111 x 0 出 现 x 4 的 x 2 顺 序 x 6 不 是 x 1 输 x 5 入 序 x 3 号 x 7 Figure 9.13 27 cause of bit-reversed order 序号的 3次奇 偶分解 x n2n1n0 binary coding for position: 对应x[n] 从上向下出现的顺 的序号 n2 n1n0 n0 n1序 n2 是把二进制序号翻转了 x 000 000 x 0 x 100 001 x 4 x 010 010 x 2 x 110 011 x 001 100 x 101 101 x 011 110 x 111 111 x 6 x 1 x 5 x 3 x 7 Figure 9.13 28 9.2.3 Alternative forms Note the arrangement of the input indices Bit reversed indexing(码位倒置) X 0 000 X 0 0 x 000 x 0 X 0 X 0 001 X 0 1 x 100 x 4 X 1 X 0 010 X 0 2 x 010 x 2 X 0 011 X 0 3 x 110 x 6 X 2 X 0 100 X 0 4 x 001 x 1 X 0 101 X 0 5 x 101 X 0 110 X 0 6 x 011 X 0 111 29 X 0 7 x 111 x 5 x 3 x 7 X 3 X 4 X 5 X 6 X 7 29 9.2.3 Alternative forms Figure 9.14 input in normal order and output in bit-reversed order strongpoint:in-place computations shortcoming:non-sequential access of elements of intermediate arrays. 30 Figure 9.15 strongpoint: Input, output same normal order shortcoming:not in-place computation; non-sequential access of elements of intermediate arrays. 31 Figure 9.16 Same structure, Input bit-reversed order , output normal order shortcoming:not in-place computation strongpoint: sequential access of data 32 9.3 Decimation-In-Frequency FFT Algorithm N 1 X k x[n]WNnk The DFT equation n 0 Split the DFT equation into even and odd frequency indexes N 1 X 2r x[n]WNn 2 r n 0 N /2 1 n 0 N / 2 1 n N /2 n n N / 2 n WN nr x[n] x[n N / 2]WN / 2 n 0 N / 2 1 n2r N N /2 1 g[n]WNnr/2 x[n ' N / 2]W x[n]WNn 2 r x[n]W n 0 33 W x[n]WNn 2 r N 1 n 0 nr N /2 N /2 1 nn' 0 n 'NN//2222rr N WNn 2 r =WNnr/2 N /22 r Nr N =W =1 N/2-point DFT 33 9.3 Decimation-In-Frequency FFT Algorithm N 1 X k x[n]WNnk The DFT equation N 1 X 2r 1 x[n]W n (2 r 1) N n 0 N /2 1 n 0 N /2 1 n 0 N /2 1 n 0 x[n]W N /2 1 n (2 r 1) N n 0 x[n]WNn ( 2 r 1) NN/2 /211 xx[[nn' N / 2]W n N n 0 W 34 rn N /2 n N rn N /2 n ' NN/2/2(2(2rr1)1) n (2 r 1) N W n N N/2-point DFT N /2 1 n 0 N (2 r 1) 2 N W W W W , W 2 rn N n N /2 n n N / 2 n nn'00 n (2 r 1) x [ n ] x [ n N / 2] W N n 2 r 1 N x[n]WNn ( 2 r 1) N x[n] x[n N / 2]W W N 1 h[n]WNnWNrn/2 N 2 N WNNrW 1 34 DIF decomposition: N-point DFT to N/2-point DFT X 2r X 2r 1 X 2r N /2 1 x[n] x[n N / 2] n N 0 /2 1 X 2r 1 35 n 0 WNnr/2 N /2 1 g[n]WNrn/2 n 0 N /2 1 rn N /2 n x [ n ] x [ n N / 2] W NW n 0 h[n]WNnWNrn/2 35 DIF decomposition: N-point DFT to N/2-point DFT 8=23 N=2m g[0] p[0] g[1] p[1] X [4] g[2] WN0 q[0] X [2] g[3] m=log2N X [0] WN2 q[1] 2点 DFT X [6] X 2r X 2* 2s N /4 1 n 0 X 2*(2s 1) 36 sn g [ n ] g [ n N / 4] W N /4 N /4 1 g[n] g[n N / 4]W n 0 2n N sn N /4 W N /4 1 n 0 p[n]WNsn/4 N /4 1 n 0 q[n]WN2 nWNsn/4 36 2-point DFT in the last stage of decimation-in-frequency decomposition X v [ p] X v1[ p] X v1[q] X v [q] X v1[ p] X v1[q] W80 , 37 when N 8 37 Final flow graph of decimation-in-frequency decomposition of 8-point DFT N=8=23 generalized to N=2m m=log2N m级: 每级 乘法N/2个, 加法N个 N/2=4-point DFT N/4=2-point DFT Complexity: (Nlog 2N)/2 complex multiplications and Nlog2N additions 42 42 9.3 .1 In-Place Computation同址运算 DIF FFT 结构相同, 乘数排列 区别大 DIT FFT 43 43 9.3 .1 In-Place Computation同址运算 DIF FFT transpose DIT FFT 44 44 9.3 .2 Alternative forms transpose decimation-in-frequecy Butterfly Computation transpose decimation-in-time Butterfly Computation 45 45 The DIF FFT is the transpose of the DIT FFT DIF FFT transpose DIT FFT 46 46 9.3 .2 Alternative forms DIF FFT transpose DIT FFT 49 Chapter 9 HW 9.1, 9.6, 9.7, 50 返 回2017/7/28 上一页 Zhongguo Liu_Biomedical Engineering_Shandong Univ. 下一页
© Copyright 2026 Paperzz