fast non-recursive computation of individual running harmonics

4
IEEE TRANSACTIONS ON CIRCUITS AND SYSTEMS—II: ANALOG AND DIGITAL SIGNAL PROCESSING, VOL. 47, NO. 8, AUGUST 2000 779 Fast Non-Recursive Computation of Individual Running Harmonics A. Gómez Expósito and J. A. Rosendo Macías Abstract—It has been recently shown that the fast Fourier transform of a sequence which slides over a time-limited rectangular window can be carried out in a nonrecursive manner by means of O computations. When only certain individual harmonics are needed, the application of this technique leads to O additions and O multiplications per harmonic. In this paper, an improvement is proposed by which any harmonic can be calculated at a cost of O additions but only two complex multiplications. The new technique stems from the application of the frequency-shifting property to existing methods. Index Terms—Discrete Fourier transform, harmonic computation, spec- tral analysis. I. INTRODUCTION Many applications rely on the discrete Fourier transform (DFT) of the samples included in a sliding rectangular window at instant [1], [2] (1) This type of DFT is known in the literature as the short-time DFT [2], [3] or, indistinctly, as the moving-window, sliding, or running DFT. When the full spectrum is required, the standard approach consists of using the well-known fast Fourier transform (FFT), whose complexity in the general case is . However, the FFT is not competitive when a single or a few individual harmonics are needed. In such cases, the DFT is obtained directly from its definition or by more elaborated algorithms, like that of Goertzel [4]. The total number of operations required by any of these methods to obtain a generic har- monic is of O . It is also widely known that the computational cost can be made independent of in the moving-window case provided recursive algorithms are acceptable [5], [6]. Recently, it has been shown that the short-time FFT can be obtained at the cost of O operations by taking advantage of the similar contents of consecutive windows [7], [8]. This technique allows a single harmonic to be nonrecursively and accurately computed by means of just O mult/adds. Table I summarizes the computational complexity of the different approaches proposed so far to obtain the running DFT. In this paper, the O short-time FFT is first reviewed by means of an example, paying special attention to the computation of individual harmonics. Then, the frequency-shifting property of the Fourier trans- form is presented for the moving-window case. By directly applying this property to the O short-time FFT, a new algorithm is developed by which computing any single harmonic requires O complex ad- ditions but only two complex multiplications. Finally, a discussion and some results are presented on the possibilities and limitations of recur- sively implementing the proposed method. Manuscript received December 1998; revised March 2000. This paper was recommended by Associate Editor J. Bioucas-Dias. The authors are with Escuela Superior de Ingenieros, Camino de los Des- cubrimientos, 41092 Sevilla, Spain. Publisher Item Identifier S 1057-7130(00)06571-X. TABLE I COMPUTATIONAL COST OF DIFFERENT APPROACHES TO OBTAIN RUNNING DFT AND A SINGLE HARMONIC * Not intended for this case. Fig. 1. Radix-2, decimation-in-time FFT applied to a windowed sequence at ( ). Fig. 2. Radix-2, decimation-in-time FFT applied to the same sequence of Fig. 1 one sample later ( ). Only butterflies shown in thicklines need re-evaluation. II. O COMPUTATION OF THE RUNNING DFT For the sake of completeness, this technique, which is not yet widely known, will be intuitively presented for with the help of Figs. 1 and 2 [7], [9]. Fig. 1 shows the butterfly structure corresponding to the radix-2, dec- imation-in-time FFT [10] of a window at instant . When a new sample, in this case , enters the window, the oldest one, , is discarded. This is accomplished by merely shifting all the butterflies upwards, as shown in Fig. 2. Note that, for convenience, all interme- diate variables have been shifted in the same way as the input data. Comparing Figs. 1 and 2, by simple inspection, it can be concluded that certain butterflies are simply shifted replicas of formerly computed butterflies. For instance, only the lowest butterfly of the first layer is 1057–7130/00$10.00 © 2000 IEEE

Upload: a-exposito

Post on 08-Feb-2017

213 views

Category:

Documents


2 download

TRANSCRIPT

IEEE TRANSACTIONS ON CIRCUITS AND SYSTEMS—II: ANALOG AND DIGITAL SIGNAL PROCESSING, VOL. 47, NO. 8, AUGUST 2000 779

Fast Non-Recursive Computation of IndividualRunning Harmonics

A. Gómez Expósito and J. A. Rosendo Macías

Abstract—It has been recently shown that the fast Fourier transformof a sequence which slides over a time-limited rectangular window can becarried out in a nonrecursive manner by means of O( ) computations.When only certain individual harmonics are needed, the application of thistechnique leads to O(log ) additions and O(log ) multiplicationsper harmonic. In this paper, an improvement is proposed by which anyharmonic can be calculated at a cost of O(log ) additions but only twocomplex multiplications. The new technique stems from the application ofthe frequency-shifting property to existing methods.

Index Terms—Discrete Fourier transform, harmonic computation, spec-tral analysis.

I. INTRODUCTION

Many applications rely on the discrete Fourier transform (DFT) oftheN samples included in a sliding rectangular window at instantn

[1], [2]

Xn(k) =

N�1

i=0

x(i+ n�N + 1)e�j(2�k=N)i: (1)

This type of DFT is known in the literature as the short-time DFT[2], [3] or, indistinctly, as the moving-window, sliding, or running DFT.When the full spectrum is required, the standard approach consists ofusing the well-known fast Fourier transform (FFT), whose complexityin the general case isN �M (M = log2N). However, the FFT is notcompetitive when a single or a few individual harmonics are needed.In such cases, the DFT is obtained directly from its definition or bymore elaborated algorithms, like that of Goertzel [4]. The total numberof operations required by any of these methods to obtain a generic har-monic is of O(N). It is also widely known that the computational costcan be made independent ofN in the moving-window case providedrecursive algorithms are acceptable [5], [6].

Recently, it has been shown that the short-time FFT can be obtainedat the cost of O(N) operations by taking advantage of the similarcontents of consecutive windows [7], [8]. This technique allows asingle harmonic to be nonrecursively and accurately computed bymeans of just O(M) mult/adds. Table I summarizes the computationalcomplexity of the different approaches proposed so far to obtain therunning DFT.

In this paper, the O(N) short-time FFT is first reviewed by means ofan example, paying special attention to the computation of individualharmonics. Then, the frequency-shifting property of the Fourier trans-form is presented for the moving-window case. By directly applyingthis property to the O(N) short-time FFT, a new algorithm is developedby which computing any single harmonic requires O(M) complex ad-ditions but only two complex multiplications. Finally, a discussion andsome results are presented on the possibilities and limitations of recur-sively implementing the proposed method.

Manuscript received December 1998; revised March 2000. This paper wasrecommended by Associate Editor J. Bioucas-Dias.

The authors are with Escuela Superior de Ingenieros, Camino de los Des-cubrimientos, 41092 Sevilla, Spain.

Publisher Item Identifier S 1057-7130(00)06571-X.

TABLE ICOMPUTATIONAL COST OFDIFFERENT APPROACHES TO

OBTAIN RUNNING DFT AND A SINGLE HARMONIC

* Not intended for this case.

Fig. 1. Radix-2, decimation-in-time FFT applied to a windowed sequence atn = 7 (N = 8).

Fig. 2. Radix-2, decimation-in-time FFT applied to the same sequence ofFig. 1 one sample later (n = 8). Only butterflies shown in thicklines needre-evaluation.

II. O(N) COMPUTATION OF THERUNNING DFT

For the sake of completeness, this technique, which is not yet widelyknown, will be intuitively presented forN = 8 with the help of Figs. 1and 2 [7], [9].

Fig. 1 shows the butterfly structure corresponding to the radix-2, dec-imation-in-time FFT [10] of a window at instantn = 7. When a newsample, in this casex(8), enters the window, the oldest one,x(0), isdiscarded. This is accomplished by merely shifting all the butterfliesupwards, as shown in Fig. 2. Note that, for convenience, all interme-diate variables have been shifted in the same way as the input data.

Comparing Figs. 1 and 2, by simple inspection, it can be concludedthat certain butterflies are simply shifted replicas of formerly computedbutterflies. For instance, only the lowest butterfly of the first layer is

1057–7130/00$10.00 © 2000 IEEE

780 IEEE TRANSACTIONS ON CIRCUITS AND SYSTEMS—II: ANALOG AND DIGITAL SIGNAL PROCESSING, VOL. 47, NO. 8, AUGUST 2000

Fig. 3. Input–output notation for a generic butterfly. The layer is denoted byl

andk represents the harmonic.

actually new. As a consequence, only two butterflies of the second layerhave to be recomputed, and so on.

Note that the set of butterflies which must be updated form a bi-nary tree. For an arbitrary value ofN , the number of such butterflies isclearlyN � 1, instead of theN � M=2 that would be needed using aconventional in-place computation. The total cost is thenN � 1 com-plex multiplications and2N�2 complex additions. Further savings arepossible in the real-data case by exploiting the well-known symmetriesimplicit in the DFT. The price paid for the computational reduction isthe extra memory required to store theN �M=2 intermediate complexvariables(N=2 per layer), in addition to theN harmonics.

III. COMPUTATION OF INDIVIDUAL RUNNING HARMONICS

From the intuitive presentation above, it is also evident that onlyMhalf butterflies have to be updated when a single harmonic is of interest.This involvesM complex mult/adds in the general case, but onlyMcomplex additions if the zero-frequency harmonic is sought.

Let yk(l; n) denote the intermediate variable of layerl required tocompute thekth harmonic at instantn. Then, for anyk, the boundaryconditionsyk(0; n) = x(n) andyk(M;n) = Xn(k) apply, whereXn(k) represents the desired harmonic andx(n) is the most recentsignal sample. Taking into account the cyclic symmetry of the twiddlefactors, the following general relationship [7] can be used to obtain theoutput of a butterfly in terms of its two inputs (see Fig. 3):

yk(l; n) = yk(l� 1; n� 2M�l) +W 2 �kN � yk(l� 1; n): (2)

ComputingXn(k) involves evaluating the above expression forl =1; 2; . . . ;M .

IV. FREQUENCY-SHIFTING PROPERTY OF THESHORT-TIME DFT

In this section, the frequency-shifting property of the short-time DFTwill be introduced.

Let us define the following sequence:

y(i) = x(i) � e�j(2�p=N)i (3)

whose short-time DFT, per (1), is

Yn(k) =

N�1

i=0

x(i+ n�N + 1)e�j(2�p=N)(i+n�N+1)

� e�j(2�k=N)i (4)

=

N�1

i=0

x(i+ n�N + 1)[e�j(2�pi=N) � e�j(2�p=N)(n+1)]

� e�j(2�k=N)i: (5)

Rearranging terms yields

Yn(k) = e�j(2�p=N)(n+1)

N�1

i=0

x(i+ n�N + 1)e�j(2�(k+p)=N)i: (6)

The right-most term in the above equation can be now identified asthe(k+ p)th harmonic of the original sequence. Hence, the followingrelationship is obtained:

Yn(k) = e�j(2�p=N)(n+1) �Xn(k+ p) (7)

which, keeping in mind (3), can be interpreted as follows: modulating asignal with the complex exponential in the discrete-time domain trans-lates into a shift in the frequency domain plus a rotation.

Actually, for a finite-length sequence completely embraced by asingle window(n = N � 1), (7) reduces to

Y (k) = X(k+ p)

which compactly represents the well-known frequency-shifting prop-erty of the regular DFT [10]. Therefore, the harmonic rotation is a directconsequence of the moving window.

V. PROPOSEDMETHOD

The new method derives from the application of the fre-quency-shifting property to the O(N) short-time FFT algorithm.Remember that, while computing a generic harmonic requiresMmultiplications plusM additions, the zero-frequency harmonic in-volves no multiplications. Based on this observation, thepth harmonicof the input sequence,x(i), can be obtained more efficiently from thezero-frequency harmonic of the modulated sequence,y(i), by settingk = 0 in (7).

Formally, every time a new sample is available, the algorithm pro-ceeds as follows.

1) Modulate the input signal

y(0; n) = y(n) = x(n)e�j(2�p=N)n: (8)

2) For l = 1; 2; . . . ;M , compute the intermediate variables from(2)

y(l; n) = y(l� 1; n� 2M�l) + y(l� 1; n): (9)

3) Finally, rotate the resulting harmonicYn(0) = y(M;n)

Xn(p) = ej(2�p=N)(n+1) � Yn(0): (10)

Clearly, the computational cost of this technique isM complex ad-ditions (step 2) plus two complex multiplications (steps 1 and 3). Inaddition, sincejXn(p)j = jYn(0)j, the last complex multiplication isnot required if only the harmonic amplitude is of interest. This is thelowest computational effort reported up to date for a nonrecursive al-gorithm.

As far as memory requirement is concerned, the proposed algorithmneedsN complex locations to store the intermediate variables(N=2variables in the first layer,N=4 variables in the second layer, and soon). Additionally, the twiddle factors used to modulate the input signaland to rotate the output harmonic can be computed on-line or retrievedfrom a precomputed look-up table.

VI. REAL DATA

In the presentation of the method above, it has been assumed that theinput samples are complex. When data is real, a minor modification ofthe three-step procedure is possible to further reduce the computationalcost. Instead of modulating the input signal, keeping in mind that

e�j(2�p=N)(n�N=2) = (�1)pe�j(2�pn=N)

the output of the left-most butterfly can be modulated. The real-dataalgorithm can then be restated as follows.

IEEE TRANSACTIONS ON CIRCUITS AND SYSTEMS—II: ANALOG AND DIGITAL SIGNAL PROCESSING, VOL. 47, NO. 8, AUGUST 2000 781

Fig. 4. Relative error of computing the harmonic magnitude for several implementations (fixed-point arithmetic).

1) Modulate the output of the first layer

y(1; n) = [x(n) + (�1)p � x(n�N=2)]e�j(2�p=N)n:

2) For l = 2; 3; . . . ;M , compute the intermediate variables using(9).

3) Rotate the resulting harmonicYn(0) = y(M;n) using (10).

With this modification, the first addition is real rather than complex.Also, the first complex multiplication reduces to two real multiplica-tions. The main difference, however, lies in the firstN=2 variablesbeing real instead of complex.

VII. A LTERNATIVE IMPLEMENTATIONS AND RESULTS

The second step of the proposed procedure obviously performs a run-ning sum of the modulated samplesy(n) (when a new sample arrivesthe oldest one is discarded). Hence, this step can be mathematically andcompactly stated by the following recursive expression:

Yn(0) = Yn�1(0) + y(n)� y(n�N) (11)

which requires only two sums. By contrast, the proposed procedurecarries outM additions but is nonrecursive, even though partial re-sults of former computations are resorted to when computingYn(0).Sometimes, the words “recursive procedure” are used in a misleadingmanner for a “nested procedure” where thedivide and conquerstrategyis recursively applied (like in all kinds of FFT algorithms). As in (11),feedback should always be present for an algorithm to be called “re-cursive."

Combining step 1 and (11) yields

Yn(0) =Yn�1(0) + x(n)e�j(2�pn=N)� x(n�N)e�j(2�pn=N)

(12)

and, rearranging terms

Yn(0) = Yn�1(0) + [x(n)� x(n�N)]e�j(2�pn=N): (13)

Equations (13) and (10) constitute one of the recursive implemen-tations of the DFT appeared in the literature [5]. Note, however, thatalthough (12) and (13) are mathematically equivalent, they can actu-ally provide different results depending on the hardware adopted (com-puters do not exactly obey the distributive property).

A much more popular recursive expression can be easily obtained bywriting (1) at two consecutive instants and substracting both equations([6], [11]), yielding

Xn(p) = [Xn�1(p) + x(n)� x(n�N)]ej(2�p=N): (14)

In what follows, it will be shown, both for fixed- and floating-pointarithmetic, that recursive procedures may not be reliable enough in thelong term, which is the pay-off for the computational saving achieved.

In addition to the nonrecursive version of the proposed method, threerecursive schemes were tested. They will be labeled below as follows.

• Recursive Algorithm #1: based on (12) and (10).• Recursive Algorithm #2: based on (13) and (10).• Recursive Algorithm #3: based on (14).

The following signal was used for the tests:

int [1000� random(500)] � sin2�n

16

where the function int(x) designates the integer part ofx, andrandom(x) is a random integer between zero and the integerx� 1.

In all cases, the window sizeN is set to 16 and the first harmonic iscomputed (p = 1). The relative error of the magnitude of this harmonicwith respect to the output of the basic DFT version, given by (1), wasused to monitor the behavior of every tested algorithm.

Fig. 4 shows the resultant errors when fixed-point arithmetic is usedin the computations and the performance index is computed and regis-tered every 500 samples.

The output of the Recursive algorithm #3 decreases steadily and re-mains around zero (�100% error) after approximately 6000 sampleshave been processed (for clarity of presentation, it is not shown in thefigure). By contrast, the nonrecursive scheme is virtually free of error.This behavior is in accordance with the theoretical predictions made in

782 IEEE TRANSACTIONS ON CIRCUITS AND SYSTEMS—II: ANALOG AND DIGITAL SIGNAL PROCESSING, VOL. 47, NO. 8, AUGUST 2000

Fig. 5. Relative error of computing the harmonic magnitude for several implementations (floating-point arithmetic).

[7], where it was shown that the error variance grows linearly with timein the former case, but it is just a function of the number of butterfliesin the latter.

It is worth noting that the output of the Recursive Algorithm #1,based on (12), is identical to that of the nonrecursive implementation.This happens because the fixed-point addition is an exact operationprovided overflows do not take place. Note, however, that the RecursiveAlgorithm #2, apparently equivalent to version #1, behaves erratically.

The same experiment was repeated using floating-point arithmetic,and the results are shown in Fig. 5. This time, the output error is reg-istered every105 samples. As in the fixed-point case, the error of thebutterfly-based nonrecursive scheme remains negligible throughout thesimulation. However, the error of the Recursive Algorithm #1 increasescontinuously and becomes larger than that of version #2. Again, theerror of version #3 is not included for clarity of presentation (it reaches40% at the end of the simulation period). Larger and unpredictable de-viations have been obtained with other input signals an longer simula-tion times. Therefore, only nonrecursive schemes are completely reli-able in the long term when floating-point arithmetic is employed.

VIII. C ONCLUSION

In this paper, the problem of efficiently computing a single runningharmonic in a nonrecursive manner has been addressed. The proposedmethod is based on the idea that any harmonic can be obtained by ro-tating the zero-frequency harmonic of a modified input signal. Thismodified sequence is obtained by modulation of the original signal. Asa result, only two complex multiplications are required, instead of theM complex multiplications of existing nonrecursive algorithms. In ad-dition, the resultingM complex sums can be recursively obtained bymeans of just two sums, but this scheme may lead to long-term devia-tions when floating-point arithmetic is adopted.

REFERENCES

[1] A. G. Phadke and J. S. Thorp,Computer Relaying for Power Sys-tems. New York: Wiley, 1988.

[2] A. V. Oppenheim and R. V. Schafer,Discrete-Time Signal Pro-cessing. Englewood Cliffs, NJ: Prentice-Hall, 1989.

[3] J. S. Lim and A. V. Oppenheim,Advanced Topics on Signal Pro-cessing. Englewood Cliffs, NJ: Prentice-Hall, 1988.

[4] G. Goertzel, “An algorithm for the evaluation of finite trigonometricseries,”Amer. Math., vol. 65, pp. 34–35, 1968.

[5] J. H. Halberstein, “Recursive, complex fourier analysis for real-time ap-plications,”Proc. IEEE, vol. 54, p. 903, June 1966.

[6] J. L. Aravena, “Recursive moving window DFT algorithm,”IEEE Trans.Comput., vol. 39, pp. 145–148, Jan. 1990.

[7] M. Covell and J. Richardson, “A new, efficient structure for theshort-time fourier transform, with an application in code-division sonarimaging,” inProc. ICASSP’91, vol. 3, Toronto, 1991, pp. 2041–2044.

[8] A. Gómez Expósito and J. A. Rosendo Macías, “Fast harmonic com-putation for digital relaying,”IEEE Trans. Power Delivery, vol. 14, pp.1263–1268, Oct. 1998.

[9] B. Farhang-Boroujeny and Y. C. Lim, “A comment on the computa-tional complexity of sliding FFT,”IEEE Trans. Circuits Syst., vol. 39,pp. 875–876, Dec. 1992.

[10] E. O. Brigham, The Fast Fourier Transform and its Applica-tions. Englewood Cliffs, NJ: Prentice-Hall, 1988.

[11] J. A. Rosendo Macías and A. Gómez Expósito, “Efficientmoving-window DFT algorithms,”IEEE Trans. Circuits Syst. II,vol. 45, pp. 256–260, Feb. 1998.