[Numpy-discussion] performance of the numpy

David Cournapeau david@ar.media.kyoto-u.ac...
Wed Sep 24 00:57:35 CDT 2008

frank wang wrote:
> Hi, I am new user from matlab world. So I always compare with matlab.
> in my code, i have a large array with about 100000 data. when I perform
> c=fft(b)
> d=abs(c)
> plot(d)
> I got good response. however, when i try to execute:
> plot(abs(fft(b)))

Can you post the exact script you used ? To be sure you are using the
fft/abs/plot you think you are using (does the abs comes from python, or
is it numpy.abs ? Without the imports, we can't tell).

My first wild guess that your size is not factorisable in small numbers.
Are you always using the same dataset (more exactly, the same number of
data ?). Because numpy uses (light version of ) fftpack, which does not
handle well numbers which are not factorisable in small numbers. In
particular, if your size is a prime number, fftpack effectively is O(N^2).

In General, it is a good idea to use the next power of 2 if at all
possible; another solution is to use scipy.fftpack, which if you have
for example fftw installed, deals with prime numbers.

Otherwise, I don't see what could be different between doing each step
after the other, and everything at once.



More information about the Numpy-discussion mailing list