Board index » delphi » Bug in SWAG FFT routine

Bug in SWAG FFT routine

     A while ago, I posted a Fast Fourier Transform (FFT) routine, written in
Pascal, in the Pascal Newsgroup.  This routine included code for the (complex)
FFT, additional code for finding the sine/cosine transform of a set of real
data points, and a brief driver that made up some data, then analyzed it.

     This week, I received a query from John Stockton, who noticed that if he
made a minor change to my driver routine (specifying a different frequency),
he got a coefficient that was the negative of what he expected.

     Sigh.  There was a bug in the routine.  My only excuse (and it is a lame
one) is that there were so many times one HAD to perform a complex conjugate
operation on the second half of the data series that I simply did one too many.

     The bug is in the routine "fftofreal".  Towards the end of the routine,
there is code that sets the cosine and sine terms of the output series.  Both
sine terms should have minus signs to the right of the assignment symbol.  The
following is the CORRECT code fragment --

        WITH mixed.coefslot.freqterms[index], temp3 DO
         BEGIN
           cosineterm := realpart/2;
           sineterm := -imagpart/2
         END;
        WITH mixed.coefslot.freqterms[minusindex], temp2 DO
         BEGIN
           cosineterm := realpart/2;
           sineterm := -imagpart/2
         END

[The bug was the missing minus sign in the next-to-last line above].

     I would be grateful if whoever maintains the SWAG archives can
incorporate this "fix".  I would appreciate hearing when this has been done.  
I apologize to anyone who might have been "bitten" by this bug.

Bob Schor
Pascal Enthusiast

 

Re:Bug in SWAG FFT routine


Could someone kindly let me know what the SWAG archive is, and what SWAG
stands for?  Cheers. Stefan

--
===============================================================================
Stefan A. Deutscher, s...@utk.edu, (001)-423-[522-7845|974-7838|574-5897]
                                             home^    UTK^     ORNL^
===============================================================================

Re:Bug in SWAG FFT routine


Quote
In article <4bcp8n$...@gaia.ns.utk.edu>, Deutscher <sad@utkux4> wrote:

:Could someone kindly let me know what the SWAG archive is, and what SWAG
:stands for?  Cheers. Stefan

:-)

 91041 Sep 6 12:13 ftp://garbo.uwasa.fi/pc/ts/tsfaqp28.zip
 tsfaqp28.zip Common Turbo Pascal Questions and Timo's answers

   All the best, Timo

....................................................................
Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa
t...@uwasa.fi http://uwasa.fi/~ts BBS 961-3170972; FIN-65101,  Finland

Re:Bug in SWAG FFT routine


Quote
In article <4bcp8n$...@gaia.ns.utk.edu> sad@utkux4 "Deutscher" writes:
> Could someone kindly let me know what the SWAG archive is, and what SWAG
> stands for?  Cheers. Stefan

From the c.l.p.b FAQ posted every week:

  *************************************************************************
   2.4   Notable sources of information
  *************************************************************************

  * SWAG.
  . Available from Garbo and SimTel directory turbopas/
  . 1st time: get swaga-c.zip...swags-z.zip + swag.zip.
  . Updating: get the latest swagYYMM.zip only.

    A free archive of Turbo Pascal code, updated quarterly, produced by
    the 'Source Ware Archival Group'. Note that the inital download is ~5Mb

    Many people would consider SWAG essential before posting here!
  -------------------------------------------------------------------------

[Well, if Timo can do this, why can't I ;-)   ]

--
* TQ 1.0 * Stolen Sigs!
Risus Sardonicus :-]
[GRAN...@BRAVO.aston.ac.uk]

Other Threads