<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="Module.2004-05-19.5617">
  <name>Choosing the Best FFT Algorithm</name>
  <metadata>
  <md:version>1.3</md:version>
  <md:created>2004/05/19 09:56:17 GMT-5</md:created>
  <md:revised>2007/02/06 08:02:06.604 US/Central</md:revised>
  <md:authorlist>
      <md:author id="dljones">
      <md:firstname>Douglas</md:firstname>
      <md:othername>L.</md:othername>
      <md:surname>Jones</md:surname>
      <md:email>dl-jones@uiuc.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="dljones">
      <md:firstname>Douglas</md:firstname>
      <md:othername>L.</md:othername>
      <md:surname>Jones</md:surname>
      <md:email>dl-jones@uiuc.edu</md:email>
    </md:maintainer>
    <md:maintainer id="harika">
      <md:firstname>Harika</md:firstname>
      
      <md:surname>Basana</md:surname>
      <md:email>ilsai@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="kclarks">
      <md:firstname>Kyle</md:firstname>
      <md:othername>Evan</md:othername>
      <md:surname>Clarkson</md:surname>
      <md:email>kclarks@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>chirp z-transform</md:keyword>
    <md:keyword>FFT</md:keyword>
    <md:keyword>prime factor algorithm</md:keyword>
    <md:keyword>winograd fourier transform algorithm</md:keyword>
  </md:keywordlist>

  <md:abstract>Power-of-two-length FFTs are usually best for general use when the DFT length is somewhat at the user's discretion.
The best power-of-two algorithm may depend on the type of computer to be used.
When FFTs must be of a specific length, a prime-factor algorithm when applicable or otherwise a common-factor algorithm usually provide fastest performance, while the chirp z-transform is a single, universal method for computing an FFT of any length.</md:abstract>
</metadata>

<content>
<section id="FFTlength">
<name>Choosing an FFT length</name>
 <para id="para_1">The most commonly used FFT algorithms <emphasis>by far</emphasis> are the
<cnxn document="m12059">power-of-two-length FFT</cnxn> algorithms. 
The <cnxn document="m12033">Prime Factor Algorithm (PFA)</cnxn> and <cnxn document="m12023" target="WFTA">Winograd Fourier Transform Algorithm (WFTA)</cnxn> require somewhat fewer multiplies, but the overall difference 
usually isn't sufficient to warrant the extra difficulty.
This is particularly true now that most processors have single-cycle pipelined hardware multipliers,
so the total operation count is more relevant.
As can be seen from the following table, for similar lengths the split-radix algorithm is comparable
in total operations to the Prime Factor Algorithm, and is considerably better than the WFTA, although the
PFA and WTFA require fewer multiplications and more additions.
Many processors now support single cycle multiply-accumulate (MAC) operations; in the power-of-two algorithms all multiplies can be combined with adds in MACs, so the number of additions is the most
relevant indicator of computational cost.

<table id="table1">
<name>Representative FFT Operation Counts</name>
<tgroup cols="5"><thead>
   <row>
     <entry> </entry>   
     <entry>FFT length</entry>
     <entry>Multiplies (real)</entry>
     <entry>Adds(real)</entry>
     <entry>Mults + Adds</entry>
   </row>
 </thead>
 <tbody>
 <row>
  <entry>Radix 2</entry>
  <entry>1024</entry>
  <entry>10248</entry>
  <entry>30728</entry>
  <entry>40976</entry>
 </row> 
 <row>
   <entry>Split Radix</entry>
   <entry>1024</entry>
   <entry>7172</entry>
   <entry>27652</entry>
   <entry>34824</entry>
 </row> 
 <row>
   <entry>Prime Factor Alg</entry>
   <entry>1008</entry>
   <entry>5804</entry>
   <entry>29100</entry>
   <entry>34904</entry>
 </row> 
 <row>
  <entry>Winograd FT Alg</entry> 
  <entry>1008</entry>
  <entry>3548</entry>
  <entry>34416</entry>
  <entry>37964</entry>
 </row> 
 </tbody>
 
</tgroup>
</table>

The <cnxn document="m12023" target="WFTA">Winograd Fourier Transform Algorithm</cnxn> is particularly  difficult to program and is rarely used in practice. 
For applications in which the transform length is somewhat arbitrary (such
as fast convolution or general spectrum analysis), the length is usually chosen to be a power of two.
When a particular length is required (for example, in the USA each carrier has exactly 416 frequency channels in each band in the <link src="http://en.wikipedia.org/wiki/AMPS">AMPS</link> cellular telephone standard), a <cnxn document="m12033">Prime Factor Algorithm</cnxn> for all the relatively prime 
terms is preferred, with a <cnxn document="m12025">Common Factor Algorithm</cnxn> for other non-prime lengths.
<cnxn document="m12023">Winograd's short-length modules</cnxn> 
should be used for the prime-length factors that are not powers of two.
The <cnxn document="m12013">chirp z-transform</cnxn> offers a universal way to compute
any length <cnxn document="m12032">DFT</cnxn> (for example, <link src="http://www.mathworks.com/products/matlab/">Matlab</link> reportedly uses this method for lengths other than a power of two), at a few times higher cost than that of a CFA or PFA optimized for that specific length.
The <cnxn document="m12013">chirp z-transform</cnxn>, along with <cnxn document="m12023" target="Radersconv">Rader's conversion</cnxn>, assure us that algorithms of
<m:math>
   <m:apply>
     <m:ci type="fn">O</m:ci>
     <m:apply>
       <m:times/>
         <m:ci>N</m:ci>
         <m:apply>
           <m:log/>
           <m:ci>N</m:ci>          
         </m:apply>
     </m:apply>
   </m:apply> 
 </m:math> complexity
exist for <emphasis>any</emphasis> DFT length
<m:math>
 <m:ci>N</m:ci>
</m:math>.
</para>
</section>
<section id="poweroftwo">
<name>Selecting a power-of-two-length algorithm</name>
<para id="element-292">The choice of a power-of-two algorithm may not just depend on computational complexity.
The latest extensions of the <cnxn document="m12031">split-radix algorithm</cnxn> offer the lowest known power-of-two FFT operation counts, but the 10%-30% difference may not make up for other factors such as regularity of structure or data flow, <cnxn document="m12021">FFT programming tricks</cnxn>, or special hardware features.
For example, the <cnxn document="m12016">decimation-in-time radix-2 FFT</cnxn> is the fastest FFT on <link src="http://www.ti.com/">Texas Instruments'</link> TMS320C54x DSP microprocessors, because this processor family has special assembly-language instructions that accelerate this particular algorithm.
On other hardware, <cnxn document="m12027">radix-4 algorithms</cnxn> may be more efficient.
Some devices, such as <link src="http://www.amis.com">AMI Semiconductor's</link> <link src="http://www.amis.com/products/dsp/toccata_plus.html">Toccata</link> ultra-low-power DSP microprocessor family, have on-chip FFT accelerators; it is always faster and more power-efficient to use these accelerators and whatever radix they prefer.
For <cnxn document="m12022">fast convolution</cnxn>, the <cnxn document="m12018">decimation-in-frequency</cnxn> algorithms may be preferred because the bit-reversing can be bypassed; however, most DSP microprocessors provide zero-overhead bit-reversed indexing hardware and prefer decimation-in-time algorithms, so this may not be true for such machines.
Good, compiler- or hardware-friendly programming always matters more than modest differences in raw operation counts, so manufacturers' or good third-party FFT libraries are often the best choice.
The module <cnxn document="m12021">FFT programming tricks</cnxn> references some good, free FFT software (including the <link src="http://www.fftw.org/">FFTW</link> package) that is carefully coded to be compiler-friendly; such codes are likely to be considerably faster than codes written by the casual programmer.</para>
</section>
<section id="multidFFTs">
<name>Multi-dimensional FFTs</name>
<para id="element-666">Multi-dimensional FFTs pose additional possibilities and problems.
The orthogonality and separability of multi-dimensional DFTs allows them to be efficiently computed by a series of one-dimensional FFTs along each dimension.
(For example, a two-dimensional DFT can quickly be computed by performing FFTs of each row of the data matrix
followed by FFTs of all columns, or vice-versa.)
<term>Vector-radix FFTs</term> have been developed with higher efficiency per sample than row-column algorithms.
Multi-dimensional datasets, however, are often large and frequently exceed the cache size of the processor, and excessive cache misses may increase the computational time greatly, thus overwhelming any minor complexity reduction from a vector-radix algorithm.
Either vector-radix FFTs must be carefully programmed to match the cache limitations of a specific processor, or a row-column approach should be used with matrix transposition in between to ensure data locality for high cache utilization throughout the computation.</para>
</section>
<section id="fewPoints">
<name>Few time or frequency samples</name>
<para id="element-162">FFT algorithms gain their efficiency through intermediate computations that can be reused to compute many DFT frequency samples at once.
Some applications require only a handful of frequency samples to be computed; when that number is of order less than <m:math>
   <m:apply>
     <m:ci type="fn">O</m:ci>
         <m:apply>
           <m:log/>
           <m:ci>N</m:ci>          
         </m:apply>
   </m:apply> 
 </m:math>,
direct computation of those values via <cnxn document="m12024">Goertzel's algorithm</cnxn> is faster.
This has the additional advantage that any frequency, not just the equally-spaced DFT frequency samples,
can be selected.
<cite src="#Sorensen">Sorensen and Burrus</cite> developed algorithms for when most input samples are zero or only a block of DFT frequencies are needed, but the computational cost is of the same order.
</para>
<para id="element-968">Some applications, such as time-frequency analysis via the <cnxn document="m10570">short-time Fourier transform</cnxn> or <cnxn document="m10570">spectrogram</cnxn>, require DFTs of overlapped blocks of discrete-time samples.
When the step-size between blocks is less than
 <m:math>
   <m:apply>
     <m:ci type="fn">O</m:ci>
         <m:apply>
           <m:log/>
           <m:ci>N</m:ci>          
         </m:apply>
   </m:apply> 
 </m:math>,
the <cnxn document="m12029">running FFT</cnxn> will be most efficient.
(Note that any <cnxn document="12032">window</cnxn> must be applied via frequency-domain convolution,
which is quite efficient for sinusoidal windows such as the <cnxn document="12032">Hamming window</cnxn>.)
For step-sizes of 
 <m:math>
   <m:apply>
     <m:ci type="fn">O</m:ci>
         <m:apply>
           <m:log/>
           <m:ci>N</m:ci>          
         </m:apply>
   </m:apply> 
 </m:math> or greater,
computation of the DFT of each successive block via an FFT is faster.</para>
</section>


</content>
    <bib:file>
    <bib:entry id="Sorensen">
      <bib:article>
	<bib:author>H.V. Sorensen and C.S. Burrus</bib:author>
	<bib:title>Efficient computation of the DFT with only a subset of input or output points</bib:title>
	<bib:journal>IEEE Transactions on Signal Processing</bib:journal>
	<bib:year>1993</bib:year>
	<bib:volume>41</bib:volume>
	<bib:number>3</bib:number>
	<bib:pages>1184-1200</bib:pages>
      </bib:article>
    </bib:entry>
  </bib:file>
</document>
