#include "hc.h" // // fourier transform routines as used by rick_sh routines // based on Rick O'Connell's subroutines, which are modified // Numerical Recipes // // $Id: rick_fft_c.c,v 1.2 2006/01/22 02:46:15 becker Exp $ // void rick_cs2ab(SH_RICK_PREC *rdata,int n) { // // Transforms spectral coefficients from cos-sin series to // complex discrete fourier series. Function is real, and // transformed by realft(rdata,n/2,1). Number of data points // is n. Does not recover real component for frequency n/2. int i; SH_RICK_PREC en; en = (SH_RICK_PREC)n; rdata[0] *= en; en/=2.0; for(i=2;i i){ tempr = rdata[j]; tempi = rdata[j+1]; rdata[j] = rdata[i]; rdata[j+1] = rdata[i+1]; rdata[i] = tempr; rdata[i+1]=tempi; } m=n/2; while((m >= 2) && (j > m)){ j=j-m; m/=2; } j += m; } mmax=2; while(n > mmax){ istep=2*mmax; theta = 6.28318530717959/(isign*mmax); temp2 = sin(0.5 * theta); wpr = -2.0 * temp2 * temp2; wpi = sin(theta); wr = 1.0; wi = 0.0; for(m=1;m <= mmax;m += 2){ for(i=m;i <= n;i += istep){ j = i + mmax; tempr=wr*rdata[j]-wi*rdata[j+1]; tempi=wr*rdata[j+1]+wi*rdata[j]; rdata[j]=rdata[i]-tempr; rdata[j+1]=rdata[i+1]-tempi; rdata[i]=rdata[i]+tempr; rdata[i+1]=rdata[i+1]+tempi; } wtemp=wr; wr=wr*wpr-wi*wpi+wr; wi=wi*wpr+wtemp*wpi+wi; } mmax=istep; } }