// Cxfft.java complex FFT and inverse FTT without using Complex type // also FFT convolution public class Cxfft { public static double[] fft(double A[], double trans) // A real,imag real,imag ... // trans=1.0 for FFT -1.0 for IFFT // fill in zeros to make A.length a power of 2 // fill in zero for imag if not available { // PURPOSE : TO PERFORM THE BASIC FFT AND INVERSE FFT COMPUTATION // // Written by : Jon Squire , 24 MAY 1983 // JSS REVISED to ISO standard packages 26 AUGUST 1990 // JSS Cleanup 19 October 1990 // JSS 9 Sept 1996, Clean up generic formal parameters // JSS 1 April 1997, Convert to C++ then Java // double tmpr, tmpi; double wxr, wxi; double wr, wi; int i, js, ix, m, isp, mmax; double ph1; int n = A.length/2; js = 1; for(ix=1; ix ix) { tmpr = A[2*(js-1)]; tmpi = A[2*(js-1)+1]; A[2*(js-1)] = A[2*(ix-1)]; A[2*(js-1)+1] = A[2*(ix-1)+1]; A[2*(ix-1)] = tmpr; A[2*(ix-1)+1] = tmpi; } m = n / 2; while(m < js && m > 0) { js = js - m; m = m / 2; } js = js + m; } mmax = 1; while(mmax < n) // compute transform { isp = mmax + mmax; ph1 = Math.PI * trans/(double)mmax; wxr = Math.cos(ph1); wxi = Math.sin(ph1); wr = 1.0; wi = 0.0; for(m=0; m