#include #include /* fft on a set of n points given by A_re and A_im. Bit-reversal permuted roots-of-unity lookup table * is given by W_re and W_im. More specifically, W is the array of first n/2 nth roots of unity stored * in a permuted bitreversal order. * * FFT - Decimation In Time FFT with input array in correct order and output array in bit-reversed order. * * REQ: n should be a power of 2 to work. * * Note: - See www.cs.berkeley.edu/~randit for her thesis on VIRAM FFTs and other details about VHALF section of the algo * (thesis link - http://www.cs.berkeley.edu/~randit/papers/csd-00-1106.pdf) * - See the foll. CS267 website for details of the Decimation In Time FFT implemented here. * (www.cs.berkeley.edu/~demmel/cs267/lecture24/lecture24.html) * - Also, look "Cormen Leicester Rivest [CLR] - Introduction to Algorithms" book for another variant of Iterative-FFT */ void fft(int n, double *A_re, double *A_im, double *W_re, double *W_im) { double w_re, w_im, u_re, u_im, t_re, t_im; int m, g, b; int i, mt, k; /* for each stage */ for (m=n; m>=2; m=m>>1) { /* m = n/2^s; mt = m/2; */ mt = m >> 1; /* for each group of butterfly */ for (g=0,k=0; g