int n, x; double Nf = 1.0/N; for (n=0; n<N; n++) { F[n][0] = 0.0; F[n][1] = 0.0; } for (n=0; n<N; n++) { for (x=0; x<N; x++) { F[n][0] += Nf * f[x][0] * cos((2.0*M_PI*x)/N*n) - Nf * f[x][1] * sin((2.0*M_PI*x)/N*n); F[n][1] += Nf * f[x][0] * sin((2.0*M_PI*x)/N*n) + Nf * f[x][1] * cos((2.0*M_PI*x)/N*n); } } } int main() { double f[][2] = {{0.0, 1.0}, {1.0, 0.0}, {0.0, 1.0}, {1.0, 0.0}, {0.0, 1.0}, {1.0, 0.0}, {0.0, 1.0}, {1.0, 0.0}}; double F[8][2], f2[8][2]; cArrayDump("f", f, 8); SFT(f, 8, F); // 離散傅立葉轉換 SFT 222