Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

How to use FFTW: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=How to compute <span class="caps">FFT</span> using <span class="caps">FFTW</span> in Qt=
[[Category:Learning::HowTo]]


==Getting Start==
= 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.'''
'''Note that I do this in Ubuntu operating system, in Windows some steps are different.'''


* Step1: Download <span class="caps">FFTW</span> ([[http:www.fftw.orgdownload.html]])
* Step1: Download FFTW ([[http://www.fftw.org/download.html]])


* Step2: Extract and Configure it (my path: /home/jafarabadi/Documents/fftw-3.3.4)<br />
* Step2: Extract and Configure it (my path: /home/jafarabadi/Documents/fftw-3.3.4)<br /><code>cd /home/jafarabadi/Documents/fftw-3.3.4<br />chmod ''x configure<br />./configure<br />make<br />make install</code>
<br />* Step 3: Add library to project: first open [your_project_name].pro file in Qt Creator and add this line:<br /><code>LIBS''= -lfftw3<code>


* Step 3: Add library to project: first open [your_project_name].pro file in Qt Creator and add this line:<br />
* Step 4: Example<br /></code>#include &lt;fftw3.h&amp;gt;</code><br /><code>int N;


* Step 4: Example<br />
fftw_complex *in, '''out;<br />in = (fftw_complex''') fftw_malloc(sizeof(fftw_complex)'''N);<br />out = (fftw_complex''') fftw_malloc(sizeof(fftw_complex)*N);


* Step 5: Enjoy <span class="smiley">:)</span> [Written by Ali Jafarabdi :: Qt is an awesome programming language.]
fftw_plan my_plan;<br />my_plan = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);<br />fftw_execute(my_plan);


===Categories:===
fftw_destroy_plan(my_plan);<br />fftw_free(in);<br />fftw_free(out);


* [[:Category:Learning|Learning]]
// A short tutorial: http://www2.math.uu.se/~figueras/fftw_tutorial/text/fftw_tutorial.pdf</code>
** [[:Category:Learning::HowTo|HowTo]]

Revision as of 09:57, 24 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<br />chmod ''x configure<br />./configure<br />make<br />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<br />

#include <fftw3.h&gt;

int N;

fftw_complex *in, '''out;<br />in = (fftw_complex''') fftw_malloc(sizeof(fftw_complex)'''N);<br />out = (fftw_complex''') fftw_malloc(sizeof(fftw_complex)*N);

fftw_plan my_plan;<br />my_plan = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);<br />fftw_execute(my_plan);

fftw_destroy_plan(my_plan);<br />fftw_free(in);<br />fftw_free(out);

// A short tutorial: http://www2.math.uu.se/~figueras/fftw_tutorial/text/fftw_tutorial.pdf