0

I have read in a lot of different places that an FFT algorithm needs to have an input array size that is a power of two, like 512 or 1024. I also found a lot of different algorithms that compute FFT, like Cooley-Tuckey and Bluestein (this one also works with numbers that follow prime factors like 2,3,5,7).

Well, I'm using KissFFT and inputting an array of length 200. Why is it working? Does someone know what is happening in this case? Is it truncating the size to 128 (2^7), or maybe using another algorithm? If it is using another algorithm, does it still give the right answer but just take longer to compute? (Time is not actually a problem for me in this case.)

Justin
  • 6,611
  • 3
  • 36
  • 57
Will
  • 804
  • 2
  • 8
  • 17
  • when I was implementing FFT some time ago I've been resizing data length to 2^n (and filled "new cells" with zeros) and it worked so it could be implemented this way – fex Oct 28 '14 at 17:33

2 Answers2

0

I finally found some useful information, here it goes:

  • First, the Cooley and Tukey algorithm link

  • Second, MATLAB: "You can use nextpow2 to pad the signal you pass to fft. Doing so can speed up the computation of the FFT when the signal length is not an exact power of 2." link

Thank you all

Will
  • 804
  • 2
  • 8
  • 17
0

If you absolutely must have an FFT with length not a power of two there are at least two ways to do it reasonably efficiently:

(1) If the length you want is a product of small numbers you can generalise the method used when the length is an exact power of two.

(2) You can actually build an FFT with arbitrary length out of convolutions done with vectors which are longer than that arbitrary length, and these longer vectors can have length a power of two, which means that you can do FFT by convolutions by power-of-two FFT. See for example http://www.engineeringproductivitytools.com/stuff/T0001/PT11.HTM. This makes use of the identity that AB = (A-B)^2 - A^2 - B^2. You want to end up with a sum of terms that look a bit like f(Xi) exp(ij). Using a convolution you can combine something that looks a bit like f(Xi)exp(-i^2) with exp((i-j)^2) so that exponents add giving you exp(-2ij+j^2) and you can take the j^2 off in the post-processing - the reference shows you how to do this properly so the exponents are actually correct, of course.

mcdowella
  • 19,301
  • 2
  • 19
  • 25