1 #include "fftw3.h"
2 #include <stdio.h>
3 #define N 8
4 int main()
5 {
6 int i;
7 fftw_complex *din,*out;
8 fftw_plan p;
9 din = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
10 out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
11 if((din==NULL)||(out==NULL))
12 {
13 printf("Error:insufficient available memory
");
14 }
15 else
16 {
17 for(i=0; i<N; i++)/*测试数据*/
18 {
19 din[i][0] = i+1;
20 din[i][1] = 0;
21 }
22 }
23 p = fftw_plan_dft_1d(N, din, out, FFTW_FORWARD,FFTW_ESTIMATE);
24 fftw_execute(p); /* repeat as needed */
25 fftw_destroy_plan(p);
26 fftw_cleanup();
27 for(i=0;i<N;i++)/*OUTPUT*/
28 {
29 printf("%f,%fi
",din[i][0],din[i][1]);
30 }
31 printf("
");
32 for(i=0;i<N;i++)/*OUTPUT*/
33 {
34 printf("%f,%fi
",out[i][0],out[i][1]);
35 }
36
37 if(din!=NULL) fftw_free(din);
38 if(out!=NULL) fftw_free(out);
39 getchar();
40 return 0;
41 }