/* An array of complex values is stored as an array of pairs of floats, each pair consisting of the real part followed by the imaginary part. The array can be 1-D or 2-D, and the lengths of the first and second axes are given by nx and ny respectively. */ typedef struct { int allocated; /* true if memory has been allocated */ float *data; /* 1-D or 2-D array of data */ int nx, ny; /* size of array of data */ float *workx, *worky; /* scratch space used by FFT routines */ } CmplxArray; /* real and imaginary parts of a complex 1-D array */ # define RPIX1D(z,i) ((z)->data[2*i]) # define IPIX1D(z,i) ((z)->data[2*i+1]) /* real and imaginary parts of a complex 2-D array */ # define RPIX2D(z,i,j) ((z)->data[2 * (i + (z)->nx * j)]) # define IPIX2D(z,i,j) ((z)->data[2 * (i + (z)->nx * j) + 1]) /* complex array memory management */ void InitCmplxArray (CmplxArray *); int AllocCmplxArray (CmplxArray *, int, int); void FreeCmplxArray (CmplxArray *); /* forward and inverse Fourier transforms of 2-D complex arrays */ int fft2d (CmplxArray *); int ifft2d (CmplxArray *); /* utility functions for complex arrays */ void FFTShift (CmplxArray *); void CpyCmplx (CmplxArray *, CmplxArray *); /* These are the Fourier transform functions written by Paul Swarztrauber. */ # if defined(NO_UNDERSCORE) # define FTDREC_U ftdrec # define CFFTI cffti # define CFFTF cfftf # define CFFTB cfftb # else # define CFFTI cffti_ # define CFFTF cfftf_ # define CFFTB cfftb_ # endif void CFFTI (int *, float *); void CFFTF (int *, float *, float *); void CFFTB (int *, float *, float *);