6 static int rev(int i, int n)
12 j = (j << 1) | (i & 1);
19 static complex omega(int k, int n)
21 return cos(2*M_PI*k/n) + I*sin(2*M_PI*k/n);
24 static void fft(double *x, double *y, int n)
27 for (int i=0; i<n; i++)
28 omegas[i] = omega(i, n);
30 for (int i=0; i<n; i++)
33 for (int i=1; i<n; i*=2)
34 for (int j=0; j<n; j+=2*i)
35 for (int k=0; k<i; k++)
39 complex o = omegas[(n/(2*i))*k % n];
47 double x[8] = { 0, 1, 0, 1, 0, 1, 0, 1 };
50 for (int i=0; i<8; i++)
51 printf("%f + %fi\n", creal(y[i]), cimag(y[i]));