fork download
  1. #include <fftw.h>
  2. #include <math.h>
  3.  
  4. int main()
  5. {
  6. fftw_plan pl1,pl2;
  7. fftw_complex in[128], mid[128], out[128];
  8. int i;
  9.  
  10. for (i=0; i<128; i++)
  11. {
  12. in[i].re = sin (M_PI*i/16);
  13. in[i].im = sin (M_PI*i/24);
  14. }
  15.  
  16. pl1 = fftw_create_plan (128, FFTW_FORWARD, FFTW_ESTIMATE);
  17. pl2 = fftw_create_plan (128, FFTW_BACKWARD, FFTW_ESTIMATE);
  18.  
  19. fftw_one (pl1, in, mid);
  20. fftw_one (pl2, mid, out);
  21. for (i=0; i<128; i++)
  22. {
  23. out[i].re /= 128;
  24. out[i].im /= 128;
  25. }
  26.  
  27. fftw_destroy_plan (pl2);
  28. fftw_destroy_plan (pl1);
  29.  
  30. for (i=0; i<128; i++)
  31. printf ("%d: in=(%f,%f), out=(%f,%f), d=(%f,%f)\n", i, in[i].re, in[i].im,
  32. out[i].re, out[i].im, out[i].re - in[i].re, out[i].im - in[i].im);
  33.  
  34. return 0;
  35. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:18: error: fftw.h: No such file or directory
prog.cpp: In function ‘int main()’:
prog.cpp:6: error: ‘fftw_plan’ was not declared in this scope
prog.cpp:6: error: expected `;' before ‘pl1’
prog.cpp:7: error: ‘fftw_complex’ was not declared in this scope
prog.cpp:7: error: expected `;' before ‘in’
prog.cpp:12: error: ‘in’ was not declared in this scope
prog.cpp:16: error: ‘pl1’ was not declared in this scope
prog.cpp:16: error: ‘FFTW_FORWARD’ was not declared in this scope
prog.cpp:16: error: ‘FFTW_ESTIMATE’ was not declared in this scope
prog.cpp:16: error: ‘fftw_create_plan’ was not declared in this scope
prog.cpp:17: error: ‘pl2’ was not declared in this scope
prog.cpp:17: error: ‘FFTW_BACKWARD’ was not declared in this scope
prog.cpp:19: error: ‘in’ was not declared in this scope
prog.cpp:19: error: ‘mid’ was not declared in this scope
prog.cpp:19: error: ‘fftw_one’ was not declared in this scope
prog.cpp:20: error: ‘out’ was not declared in this scope
prog.cpp:27: error: ‘fftw_destroy_plan’ was not declared in this scope
prog.cpp:32: error: ‘printf’ was not declared in this scope
stdout
Standard output is empty