the quick discrete fourier transform - Semantic Scholar

15 downloads 0 Views 114KB Size Report
Halliburton Energy Services. Houston, TX 77236-6306. ABSTRACT. This paper will look at an approach that uses symmet- ric properties of the basis function to ...
THE QUICK DISCRETE FOURIER TRANSFORM H. Guoy G. A. Sittonz C. S. Burrusy y Dept. of ECE, Rice University. Houston, TX 77251-1892 z Halliburton Energy Services. Houston, TX 77236-6306

ABSTRACT

This paper will look at an approach that uses symmetric properties of the basis function to remove redundancies in the calculation of discrete Fourier transform (DFT). We will develop an algorithm, called the quick Fourier transform (QFT), that will reduce the number of oating point operations necessary to compute the DFT by a factor of two or four over direct methods or Goertzel's method for prime lengths. Further apply the idea to the calculation of a DFT of length-2M , we construct a new O(N log N ) algorithm. The algorithm can be easily modi ed to compute the DFT with only a subset of input points, and it will signi cantly reduce the number of operations when the data are real. The simple structure of the algorithm and the fact that it is well suited for DFTs on real data should lead to ecient implementations and to a wide range of applications.

1. INTRODUCTION

In the eld of digital signal processing, the discrete Fourier transform (DFT) is an interesting, important, and useful tool. The DFT de ned by

X x(n)e? C (k) := N ?1

p

n=0

j2 nk N ;k

= 0; : : : ; N ? 1;

that the QFT algorithm can be easily modi ed to compute the DFT with only a subset of input points. Compared with existing methods [8], it will signi cantly reduce the number of operations when the data are real.

2. QFT OF PRIME LENGTH

We use the fact that the cosine is an even function and the sine is an odd function. The kernel of the DFT or the basis functions of the expansion is given by 2  jnk 2  nk ) ? j sin( 2  nk ) (2) e? N = cos( N

which has an even real part and odd imaginary part. If the data x(n) are decomposed into their real and imaginary parts and those into their even and odd parts, we have x(n) = u(n)+ jv(n) = [ue (n)+ uo (n)]+ j [ve(n)+ vo (n)]

(3)

where the even part of the real part of x(n) is given by ue = (u(n) + u(?n))=2

(4)

and the odd part of the real part is uo = (u(n) ? u(?n))=2

(1)

where j = ?1, has enormous capacity for improvement of its arithmetic eciency. The classical Cooley-Tukey FFT and prime factor FFT [2] exploit the periodic properties of the cosine and sine functions to remove redundancies. In this paper, we will use the symmetric properties to derive an ecient algorithm. This approach has long been recognized [3, 4, 1, 6, 7], but has not been developed in a systematic way in the open literature. We will rst develop the quick Fourier transform (QFT) algorithm for prime lengths. Compared with the direct methods or the Goertzel's method, the QFT will reduce the number of oating point operations necessary to compute the DFT by a factor of two or four. Indeed, it seems the best general algorithm available for prime length. Apply the same idea to the DFT of length-2M , we will develop a new O(N log N ) algorithm. The algorithm has very interesting structure, and is well suited for DFTs on real data. The standard FFT algorithms inherently assume that the length of the input and output sequences are equal. In practice this is not always an accurate assumption. We will show

N

(5)

with corresponding de nitions of ve(n) and vo (n).Using (3) with a simpler notation, the DFT of (1.) becomes C (k) =

X (u + jv)(cos ?j sin)

N ?1 n=0

(6)

The sum over an integral number of periods of an odd function is zero and the sum of an even function over half of the period is one half the sum over the whole period. This causes (1.) and (6) to become C (k) =

X [ue cos +vo sin] + j[ve cos ?uosin]

N=2?1 n=0

(7)

for k = 0; 1; 2;  ; N ? 1. The evaluation of the DFT using equation (7) requires half as many real multiplications and half as many real additions as evaluating it using (1.) or (6). We have exploited the symmetries of the sine and cosine functions of the time index n. This is independent of whether the length is composite or not. Another view of

Table 1. Comparison of the number of operations for O(N 2 ) DFT algorithms.

Algorithm real mults. real adds. trig.eval. Direct DFT 4N 2 4N 2 2N 2 Goertzel N2 + N 2N 2 + N N QFT N2 N 2 + 4N 2N

N

this formulation is that we have used the property of associatively of multiplication and addition. In other words, rather than multiply two data points by the same value of a sine or cosine then add the results, one should add the data points rst then multiply the sum by the sine or cosine which requires one rather than two multiplications. Next we take advantage of the symmetries of the sine and cosine as functions of the frequency index k. Using these symmetries on (7) gives C (N ? k) =

X [ue cos ?vo sin] + j[ve cos +uosin]

N=2?1 n=0

(8)

for k = 0; 1; 2;  ; N ? 1. This again reduces the number of operations by a factor of two, this time because it calculates two output values at a time. The rst reduction by a factor of two is always available. The second is possible only if both DFT values are needed. The above development has not dealt with the details that arise with the di erence in an even and an odd length. That is straightforward. A careful analysis of the QFT shows that the total algorithm requires N 2 real multiplications and N 2 +4N real additions. These numbers along with those for the modi ed second order Goertzel algorithm and the direct calculation of the DFT are include in table 1. Of the various O(N 2 ) DFT algorithms, the QFT seems to be the most ecient for a general length N. 3. QFT OF LENGTH-2M For N = 2M , let us de ne the following transforms of the length-N vector x with elements x(0); x(1)  x(N ? 1) : Discrete Fourier transform : N ?1 j2 nk DF T (k; N; x) := x(n)e? N ; k = 0; : : : ; N ? 1; (9) n=0

X

p

where j = ?1.

Discrete cosine transform of the length-(N + 1) vector x:

DCT (k; N +1; x):=

XN x(n) cos(  nk ); k = 0; : : : ; N; (10)

n=0

N

Discrete sine transform of the length-(N ? 1) vector x:

X x(n) sin(  nk ); k = 1; : : : ; N ? 1; DST (k; N ? 1; x):= N ?1 n=1

N

de nitions by Wang [9], one will see that they are DCT-I and DST-I respectively. Notice the following symmetric relations of sine and cosine functions: (12) cos( 2  (N ? n) k ) = cos( 2  nk )

(11) Note that in the de nitions of DCT and DST, the normalizing factors are omitted for simplicity. Comparing to the

N

(13) sin( 2  (NN? n) k ) = ? sin( 2 Nnk ) By de ning a length-(N=2 + 1) vector xe, which is the even part of vector x, as xe (0) := x(0); xe (N=2) := x(N=2)

(14)

xe (k) := x(k) + x(N ? k); k = 1;  ; N=2 ? 1; (15) and de ning a length-(N=2 ? 1) vector xo , which is the odd part of vector x, as xo (k) := x(k) ? x(N ? k); k = 1;  ; N=2 ? 1;

(16)

we can decompose a length-N DFT into a length-(N=2 + 1) DCT and a length-(N=2 ? 1) DST as follows: DF T (0; N; x) = DCT (0; N=2 + 1; xe)

(17)

N

N

2 +1; xe) ? jDST (k; 2 ? 1; xo ); k = 1;  ; N=2 ? 1; (18) DF T (N=2; N; x) = DCT (N=2; N=2 + 1; xe ) (19)

DF T (k; N; x) = DCT (k;

DFT(N?k;N;x)= DCT (k; N2 +1;xe) + jDST (k; N2 ? 1;xo ); k = 1;  ; N=2 ? 1:

(20)

The ow diagram, for N = 16, is shown in Figure 1. Notice the star-like structure in the diagram. Then we should further decompose DCT on length-(N +1) vertor x. Obviously, the following symmetric relations hold: cos(  (N ? n) k ) = cos(  nk ); k = 0; 2;  ; N; (21) N

N

and

cos(  (NN? n) k ) = ? cos( Nnk ); k = 1; 3;  ; N ? 1 (22)

Using the following trigonometric identity: 2 cos(  n (2 k + 1) ) cos(  n ) = cos( 2  nk ) N

N

N

(k + 1) ) (23) + cos( 2  n N and de ne two length-(N=2 + 1) vectors xe; xo : (x(k) ? x(N ? k)) xe (k) := x(k) + x(N ? k); xo (k) := 2 cos( Nk )

x

X

0

0

1

1

2

DCT

X

0

0

1

1

2

2

3

3

-

3

x

DCT

3

4

4

-

N=8 5

N=8

4

L=9

6

6

7

5

6

6

7

7

7

8

8

9

-

4

L=9

5

5

-

2

8 1/2

8

9

1/(2C(1,16))

9

j

-

9

10

10

1/(2C(1,8))

10

-

11

-

12

-

13

-

DST

j

11

-

12

-

10

DCT

11

1/(2C(3,16))

j

11

N=8

j

12

14

-

L=7

j

13

15

-

12

N=8

1/(2C(1,4))

13

-

13

1/(2C(5,16))

14

L=9

1/(2C(3,8))

15 1/(2C(7,16))

14

j

-

14

16

16

0

15

j

-

DFT

15

DCT

N=16

Figure 1. DFT, N = 16 k = 0;  ; N=2 ? 1

xe(N=2) := x(N=2);

(24)

xo (N=2) := 0

(25)

So the even transformed DCT points are: DCT (2k; N +1; x)= DCT (k;

Figure 2. DCT, N = 16 x

2 +1; xe); k = 0; 1;  ; N=2;

1 1/(2C(1,8))

2 1/(2C(3,16))

N

6

+DCT (k + 1; N2 +1; xo );

k = 0; 1;   ; N=2 ? 1:

(26) So we have recursively decomposed a length-(N + 1) DCT into two length-(N=2 + 1) DCTs. The ow diagram, for N = 16, is shown in Figure 2. Also notice the star-like structure in the diagram. Note, in Figure 2 and 3, C (a; b) := cos( ba ). We can similarly decompose a length-(N ? 1) DST into two length-(N=2 ? 1) DSTs. The ow diagram, for N = 16, is shown in Figure 3. Since the complex operations only occur at the last stage, the QFT algorithm is well suited for DFTs on real data, but if the input is complex , one simply takes the real and imaginary parts separately (thus doubling the computational load) and evaluates the output with 2N ? 4 auxiliary adds (k = 0 and N2 require no additions). Below, we state the

3

1/(2C(5,16))

and the odd transformed DCT points are: 2 +1; xo )

2

DST

1/(2C(1,4))

4 5

DCT (2k + 1; N + 1; x) = DCT (k;

X

1/(2C(1,16))

1

3

N

N=16 L=17

N=8

-

5

L=7

1/(2C(3,8))

4

6 -

1/(2C(7,16))

7

7

8

-‘

9

-

10

-

11

-

12

-

13

-

8 9

DST

10 11

N=8

12 413

L=7 14

-

14

15

-

15

DST

N=16 L=15

Figure 3. DST, N = 16

Table 2. Comparison of direct computation of a DFT on real data with a FFT of N=2 or the QFT algorithm ( the FFT of N=2 is computed with the Rader-Brenner algorithm).

FFT Pruning on 512 Real Data

4

x 10

Prune-Skinner

size FFT of N/2 + ops. QFT algorithm N real mults. real adds. real mults. real adds. 16 26 122 11 66 64 162 710 105 482 256 898 3870 673 2818 1024 4610 19582 3713 14580 number of operations required for QFT on real and complex data, where OM [:] and OA [:] stand for the number of real multiplies and adds respectively. 11 (27) 2 log2 (N ) ? 8 N + 1 7 (28) OA [R ? DF T (N )] = N log 2 (N ) ? 3 N + 2 4 11 OM [C ? DF T (N )] = N log2 (N ) ? N + 2 (29) 4 7 OA [C ? DF T (N )] = N log 2 (N ) ? 4 N (30) 2 Table 2 compares this result with the QFT and shows the substantial savings that are obtained. The operation counts are taken from [5]. OM [R ? DF T (N )] =

N

4. QFT ON A SUBSET OF INPUT DATA

Given that there are L nonzero input points, one can see that there are at most L nonzero points in each star-like structure of the QFT diagrams. For real data, the number of operations necessary to compute all the outputs are = N2 log 2 L + N8 + 2NL ? 2L (31) 3N log N + N log L ? 3N + 2N (32) OA = 2 4 2 L Figure 4 shows the total number of operations to compute a length-512 DFT, using Skinner's Pruning method, Transform Decomposition [8] and QFT. We can see that the QFT is signi cantly better than other methods. This is due to the fact that both Pruning and Transform Decomposition have to use complex twiddle factors. OM

5. SUMMARY

In summary, we have exploited the symmetric properties of the basis functions of DFT. The resulting QFT algorithm works for both prime length and length-2M . We also showed that the QFT algorithm is very ecient to compute the DFT with only a subset of real input points. The simple structure of the algorithm and the fact that it is well suited for DFTs on real data should lead to ecient implementations and to a wide range of applications.

Acknowledgements

This work was supported in part by AFOSR under grant number 90-0334 which was funded by DARPA and in part by BNR.

Number of operations

2

TD 2BF

1.5

1

Prune-QFT 0.5 0

100

200 300 400 Number of input points

500

600

Figure 4. Comparison of several methods for computing a DFT eciently with only a subset of input points for a length 512 DFT.

REFERENCES

[1] C. S. Burrus. The quick discrete Fourier transform. December 1991. [2] C. S. Burrus and T. W. Parks. DFT/FFT and Convolution Algorithms. John Wiley and Sons, New York, 1985. [3] M. T. Heideman, D. H. Johnson, and C. S. Burrus. Gauss and the history of the FFT. IEEE ASSP. Magazine, 1:14{ 21, October 1984. [4] J. F. Kohne. A quick Fourier transform algorithm. Naval Electronics Laboratory Center, Technical Report, June 1979. [5] H. J. Nussbaumer. Fast Fourier Transform and Convolution Algorithms. Springer Verlag, Berlin, 1982. [6] G. A. Sitton. The QFT algorithm. unpublished paper, 1985. [7] G. A. Sitton. The QDFT: an ecient method for short prime length dfts. unpublished paper, June 1991. [8] Henrik V. Sorensen and C. S. Burrus. Ecient computation of the DFT with only a subset of input or output points. IEEE Trans. ASSP., 41:1184{1200, March 1993. [9] Z. Wang. Fast algorithms for the discrete W transform and for the discrete Fourier transform. IEEE Trans. ASSP., 32:803{816, August. 1984.

THE QUICK DISCRETE FOURIER TRANSFORM H. Guoy, G. A. Sittonz and C. S. Burrusy y Dept. of ECE, Rice University. Houston, TX 77251-1892 z Halliburton Energy Services. Houston, TX 77236-6306 This paper will look at an approach that uses symmetric properties of the basis function to remove redundancies in the calculation of discrete Fourier transform (DFT). We will develop an algorithm, called the quick Fourier transform (QFT), that will reduce the number of oating point operations necessary to compute the DFT by a factor of two or four over direct methods or Goertzel's method for prime lengths. Further apply the idea to the calculation of a DFT of length-2M , we construct a new O(N log N ) algorithm. The algorithm can be easily modi ed to compute the DFT with only a subset of input points, and it will signi cantly reduce the number of operations when the data are real. The simple structure of the algorithm and the fact that it is well suited for DFTs on real data should lead to ecient implementations and to a wide range of applications.