How to use FFTW: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
* Step1: Download FFTW ([[http://www.fftw.org/download.html]]) | * Step1: Download FFTW ([[http://www.fftw.org/download.html]]) | ||
* Step2: Extract and Configure it (my path: /home/jafarabadi/Documents/fftw-3.3.4) | * Step2: Extract and Configure it (my path: /home/jafarabadi/Documents/fftw-3.3.4) | ||
<code>cd /home/jafarabadi/Documents/fftw-3.3.4 | |||
chmod ''x configure | |||
./configure | |||
make | |||
make install</code> | |||
* Step | * Step 3: Add library to project: first open [your_project_name].pro file in Qt Creator and add this line: | ||
<code>LIBS''= -lfftw3<code> | |||
* Step 4: Example | |||
</code>#include <fftw3.h></code> | |||
<code>int N; | |||
fftw_complex *in, '''out; | |||
in = (fftw_complex''') fftw_malloc(sizeof(fftw_complex)'''N); | |||
out = (fftw_complex''') fftw_malloc(sizeof(fftw_complex)*N); | |||
fftw_destroy_plan(my_plan); | fftw_plan my_plan; | ||
my_plan = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE); | |||
fftw_execute(my_plan); | |||
fftw_destroy_plan(my_plan); | |||
fftw_free(in); | |||
fftw_free(out); | |||
// A short tutorial: http://www2.math.uu.se/~figueras/fftw_tutorial/text/fftw_tutorial.pdf</code> | // A short tutorial: http://www2.math.uu.se/~figueras/fftw_tutorial/text/fftw_tutorial.pdf</code> |
Revision as of 10:17, 25 February 2015
How to compute FFT using FFTW in Qt
Getting Start
Note that I do this in Ubuntu operating system, in Windows some steps are different.
- Step1: Download FFTW ([[1]])
- Step2: Extract and Configure it (my path: /home/jafarabadi/Documents/fftw-3.3.4)
cd /home/jafarabadi/Documents/fftw-3.3.4
chmod ''x configure
./configure
make
make install
- Step 3: Add library to project: first open [your_project_name].pro file in Qt Creator and add this line:
LIBS''= -lfftw3<code>
* Step 4: Example
#include <fftw3.h>
int N;
fftw_complex *in, '''out;
in = (fftw_complex''') fftw_malloc(sizeof(fftw_complex)'''N);
out = (fftw_complex''') fftw_malloc(sizeof(fftw_complex)*N);
fftw_plan my_plan;
my_plan = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute(my_plan);
fftw_destroy_plan(my_plan);
fftw_free(in);
fftw_free(out);
// A short tutorial: http://www2.math.uu.se/~figueras/fftw_tutorial/text/fftw_tutorial.pdf