/ * Time Lift 2FFT and IFFT Algorithm C Language Realization * // * Author: Junyi Sun // * Copyright 2004-2005 * // * mail: ccnusjy@yahoo.com.cn * / # include
Complex x [n], * w; / * Enter a sequence, transform core * / int size_x = 0; / * Enter the size of the sequence, only 2 power * / double pi; / * circumference * /
INT main () {Int i, method; void fft (); / * Fast Fourier transform * / void ifft (); voidin (); / * Initialization transformation nuclear * / void change (); / * index * / Void add (complex, complex *); / * complex addition * / void mul (complex, complex, complex *); / * complex multiplication * / void sub (complex, complex, complex *); / * complex Subtraction * / Void Divi (Complex, Complex, Complex *); / * Complex Different * / Void Output (); / * Output * / System ("CLS"); PI = Atan (1) * 4; Printf (" Please input the size of x: / n "); scanf ("% d ", & size_x); Printf (" "please input the data in x [n]: / n"); for (i = 0; i / * Fast Fourier Transform * / Void FFT () {INT i = 0, J = 0, K = 0, L = 0; COMPLEX Up, Down, Product; Change (); for (i = 0; i < LOG (size_x) / log (2); i ) {/ * first-class butterfly calculation * / l = 1 << i; for (j = 0; j / * Fast Fourier transform * / void ifft () {INT i = 0, J = 0, K = 0, L = Size_x; Complex Up, Down; For (i = 0; INT) (LOG (SIZE_X) / log (2)); i ) {/ * 1st butterfly calculation * / l / = 2; for (j = 0; j / * Calculation, X (N) code bits inverted * / void change () {complex temp; unsigned short i = 0, j = 0, k = 0; Double T; for (i = 0; i / * Results of Fourier Transform * / void Output () {INT I; Printf ("The Result is Follows / N"); for (i = 0; i