Join GitHub today
fft is unusable of moderately large arrays with a size which is a prime number (Trac #506) #1104
Currently, using fft on arrays of size which has a prime number is extremely slow (up to 15 minutes for eg an array of size 100003). The major problem though is that the code being uninterruptible, this effectively kills the current python session. My understanding is that the fft in numpy is using fftpack converted in C, which uses a O(N^2) algorithm for prime numbers ? Would it be possible at least to make the code interruptible ?
import numpy as N
prime is a prime number
prime = 100003
a = N.random.randn(prime)
print 'scipy computing...'
print 'numpy computing...'
@charris wrote on 2007-05-12
As far as I know, there is no fast algorithm for the prime numbers other than fast convolution, i.e., http://en.wikipedia.org/wiki/Bluestein's_FFT_algorithm. As Bluestein's algorithm also works for the chirp-z transform we might prefer to implement the latter, or maybe put it in scipy.
@charris wrote on 2007-05-13
Davids patch works for me, so I am going to commit the patch and close the bug. Making a fast transform for a prime number of elements is an enhancement. We probably need a chirp-z transform, either in numpy or in scipy, but its current lack is not a bug.
@stefanv wrote on 2007-05-13
FFTW implements Bluestein's algorithm. A python implementation is available at