Skip to content

Fastest Fourier Transform in the West

The Fastest Fourier Transform in the West (FFTW) is a software library for computing discrete Fourier transforms (DFTs) developed by Matteo Frigo and Steven G. Johnson at the Massachusetts Institute of Technology.

FFTW Windows Def to DLLs

These DLLs were created by us, cross-compiled from GNU/Linux using MinGW; the 64-bit version is possible thanks to the mingw-w64 project. You should be able to call them from any compiler. In order to link to them from Visual C++, you will need to create .lib "import libraries" using the lib.exe program included with VC++. Run:

lib /def:libfftw3-3.def
lib /def:libfftw3f-3.def
lib /def:libfftw3l-3.def

DFT Example

#include <fftw3.h>
// ...
fftw_complex * input = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * DATA_SIZE);
fftw_complex * test  = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * DATA_SIZE);
fftw_complex * out1  = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * DATA_SIZE);
fftw_complex * out2  = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * DATA_SIZE);

fftw_plan plan_forward  = fftw_plan_dft_1d(DATA_SIZE, input, out1, FFTW_FORWARD, FFTW_ESTIMATE);
fftw_plan plan_backward = fftw_plan_dft_1d(DATA_SIZE, out1, out2, FFTW_BACKWARD, FFTW_ESTIMATE);

// read_file("res/test/fft_input.txt", DATA_SIZE, input);  // original signal file.
// read_file("res/test/fft_forward.txt", DATA_SIZE, test); // forward result file.

fftw_execute(plan_forward);
fftw_execute(plan_backward);

// Recovered input data divided by N:
for (int i = 0; i < DATA_SIZE; ++i) {
    out2[i][0] /= static_cast<double>(DATA_SIZE);
    out2[i][1] /= static_cast<double>(DATA_SIZE);
}

fftw_destroy_plan(plan_forward);
fftw_destroy_plan(plan_backward);

fftw_free(input);
fftw_free(test);
fftw_free(out1);
fftw_free(out2);

See also

Favorite site

Documentation

Sample code

References


  1. Using_the_Fast_Fourier_Transform_Library_FFTW_in_OpenCV.pdf 

  2. Fftw3-user_manual.pdf