/* simple Fourier transformation for regularly spaced data points */ /* input data is a pair of vectors reF[n], imF[n], representing */ /* F(n*dx)=F(x)=reF[n]+i*imF[n] ; dx=1/N; interval is 0<=x<=1 */ /* output is a pair of vectors reG[m], imG[m] representing the */ /* transformation. For a real function, the Fourier cosine */ /* transform will be */ /* F(n*dx)=1/(sqrt(N))*sum_m reG[m]*cos(2*pi*m*n*x/N) */ #include #include #define PI 3.1415926 #define N 200 /* increase or decrease as needs be */ void FT( double *rF, double *iF, double *rg, double *ig); double reF[N], imF[N], reG[N], imG[N]; int i,j; double dx, x; main(){ double *reF_ptr,*imF_ptr,*reG_ptr,*imG_ptr; /* build a sample function; F(x)=2.0/(1.0+(x-0.5)*(x-0.5)) */ dx=1.0/(double)N; for(i=0;i