[SciPy-user] FFTW use

Robert Kern robert.kern at gmail.com
Tue Mar 11 13:30:31 EDT 2008


On Tue, Mar 11, 2008 at 11:58 AM, Charrett, Thomas
<t.charrett at cranfield.ac.uk> wrote:
> Hello,
>
>  I'm fairly new to using python, having converted from matlab and I have some questions concerning the FFT functions in scipy.fftpack.
>
>  I have some matlab code which calculates the fft of an image (2d array) before carrying out some processing and then doing the inverse transform. However the same code converted to Python gives a different result. I've been trying to track down the problem and it appears that the problem occurs when calculate the fft, with matlab calculating slightly different values than scipy.
>
>  I've have tried to build scipy to use the FFTW library that Matlab uses and think I have succeeded (scipy.show_config() says fftw3 is available). Does fft2 and fftn automatically use FFTW when installed?

Yes.

>  If not how would I set this? Are the functions in scipy.fftpack the correct ones? - I have seen post suggesting scipy.fftw which doesn't appear to exist.

The scipy.fftpack module is misleadingly named. The functions in there
will use whatever FFT backend it was built with, not just FFTPACK.

>  Also I say I've tried to build scipy with FFTW as the instructions for windows are unclear and it took my a while to get it working - could someone post some instructions on the correct way to compile scipy with FFTW.
>
>  I used MinGW and MSYS to compile FFTW  using the configure and make files, copied libfftw3.a and fftw3.h to a new folder. Downloaded the prebuilt atlas version from the scipy webpage and used the following in my site.cfg file:
>
>  [atlas]
>  library_dirs = C:\build\atlas3.6.0_WinNT_P3
>  atlas_libs = lapack, f77blas, cblas, atlas
>  [fftw3]
>  library_dirs = [path to fftw files]
>  include_dirs = [path to fftw libs]
>  libraries = fftw3
>
>  I then ran and installed the result using
>
>  python setup.py config --compiler=mingw32 build --compiler=mingw32 bdist_wininst
>
>  When I import scipy, scipy.test() crashed

Can you run scipy.test(verbosity=2)? The name of the test will be
printed before it is executed. Please show us this name so we can
figure out which test is crashing.

>  but the fftpack.test() works fine, However my fft results look exactly the same am I actually using FFTW?

If you attach the build output, we could answer that definitively. The
results *should* look the same.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco



More information about the SciPy-User mailing list