Path: utzoo!attcan!uunet!husc6!ukma!tut.cis.ohio-state.edu!mailrus!ames!sgi!karsh
From: karsh@trifolium.SGI.COM (Bruce Karsh)
Newsgroups: comp.lang.misc
Subject: Re: fft routine (was Re: m88000 benchmarks)
Message-ID: <16920@sgi.SGI.COM>
Date: 4 Jul 88 04:14:16 GMT
References: <1359@claude.oakhill.UUCP> <12295@mimsy.UUCP>
Sender: daemon@sgi.SGI.COM
Reply-To: karsh@trifoliu.UUCP (Bruce Karsh)
Organization: Silicon Graphics Inc, Mountain View, CA
Lines: 61

In article <12295@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>(N.B.: this is a language (code design) issue, not an architectural
>issue, so I have redirected followups to comp.lang.misc.)
>
>The context of the following quote is benchmarking; in this case one
>is, of course, concerned with running existing code quickly.  Yet the
>code below is all too typical: there are no comments; the variables
>have names that tell nothing.  In short, the code is unmaintainable.

 [ An fft procedure follows ]

  There is an extensive literature on the fft algorithm.  This fft procedure
is pretty simple, if you are familiar with what has been written about the
fft algorithm.  If not, then I can understand why this would look confusing.
This fft procedure seems exceptionally clear to me.  Most fft procedures that
I have seen are much more confusing than this one.

  Why should somebody who has not read about how fft's work be expected to
be able to "maintain" one?

  If I were to criticize this fft, I would point out:

     That it is lacking a bit reversal step,

     That n is a function of m.  In fact, n = 1<		/*
>		 * as k goes from to 0 n-1,
>		 * fullstep goes from n to n/2 to n/4 to ... to 2,
>		 * and halfstep goes from n/2 to n/4 to ... to 1.
>		 */
>		for (k = 0; k < m; k++) {
>			fullstep = n >> k;		/* n/2^k */
>			halfstep = fullstep >> 1;	/* n/2^(k+1) */

     This comment has at least two errors in it.  First, k goes from
     0 to m-1, not n-1.  Secondly, halfstep starts at n/4, not n/2.
     Secondly, both comments are gratuitous in that they give no more
     information than what is immediately visible in the source code.
     It's kind of like saying:

        pi=7.3232;    /* set pi to 7.3232 */

     The comment tells you something that you already know, but doesn't
     answer the question that you have!  What you don't know, and what
     you want the comment to tell you, is why are you changing the value
     of pi, and where did 7.3232 come from anyways?

--
Every time I bite my tongue, "Mr. Palomar concludes mentally,
"I must think not only of what I am about to say or not say, but
also of everything that, whether I say it or do not say it, will be
said or not said by me or by others."