Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "fftw3.h"
- using namespace std;
- // macros for the real and imaginary parts
- #define REAL 0
- #define IMAG 1
- // length of the complex arrays
- #define N 8
- void fft(fftw_complex *in, fftw_complex *out)
- {
- // create a DFT plan
- fftw_plan plan = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
- // execute the plan
- fftw_execute(plan);
- // do some cleaning
- fftw_destroy_plan(plan);
- fftw_cleanup();
- }
- int main()
- {
- cout << "Start program" << endl;
- // input array
- fftw_complex x[N];
- // output array
- fftw_complex y[N];
- // fill the first array with some numbers
- for (int i = 0; i < N; ++i) {
- x[i][REAL] = i + 1; // i.e., { 1, 2, 3, 4, 5, 6, 7, 8 }
- x[i][IMAG] = 0;
- }
- // compute the FFT of x and store the results in y
- fft(x, y);
- cout << "Hello world!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment