[SciPy-user] Numpy/Scipy rfft transformations do not match?

Jeffery Kline jeffery.kline@gmail....
Mon Jun 15 14:35:38 CDT 2009


This is from an old thread about rfft versions in numpy and scipy.
(http://mail.scipy.org/pipermail/scipy-user/2009-March/020131.html)

I'm writing in support of numpy's rfft output format.

In my application, I am interested in the real portion of the rfft of
a n-dimensional array. With numpy.rfft, the syntax is elegant:

X=npfft.rfft(X, axis=j).real

With scipy.rfft, the syntax is more complicated. It requires something like

index=range(1,n,2)
index.insert(0,0)
X=spfft.rfft(X, axis=j).take(index,axis=j)

Occasionally, for debugging/testing, I recreate the full spectrum with
the resulting output from rfft. To do this with numpy's rfft is
natural and easy to read.  The corresponding code with scipy's rfft
output is more involved.

Similar statements hold with respect to the corresponding irfft functions.

Finally, speed is an issue for me. I currently have no benefit to
using scipy over numpy -- scipy's rfft returns somewhat faster for me,
but after collecting the array elements I need, the cost is larger in
time.  Possibly for sufficiently large arrays, I will see a benefit,
but the cost in code development is not currently worth it for me.
--Jeff


More information about the SciPy-user mailing list