In these routines, all dimensions being transformed must be even and their
largest prime factors must be no larger than 19. All transforms are done in
place and a normalization is applied in each case. The X dimension of the
array must always be dimensioned to 2 more than the dimension of the real
space image to allow space for an extra column of complex numbers. The sizes
passed to the routines are always the real-space image sizes. Thus, in
Fortran, an array would be dimensioned as:
real*4 array(nx+2, ny) or: complex array((nx+2)/2, ny)
There are no separate Fortran wrappers for these routines; their names are defined so that they can be called directly from Fortran. From C, include "cfft.h" to have the function name defined with an underscore on Unix-type systems and with capital letters on Windows. Pass all arguments by reference (as pointers).
All functions exit with an error message to standard out if the image size is not allowed or the direction parameter is incorrect.
Header to include: cfft.h
void odfft(float *array, int *nxp, int *nyp, int *idirp)
void odfftc(float *array, int nx, int ny, int idir)
void todfft(float *array, int *nxp, int *nyp, int *idirp)
void todfftc(float *array, int nx, int ny, int idir)
void thrdfft(float *array, float *brray, int *nxp, int *nyp, int *nzp,
int *idirp)
void thrdfftc(float *array, float *brray, int nx, int ny, int nz, int idir)
Performs nyp 1-D FFT'S in place. The data are organized as nyp lines of
data of length nxp in the real space image, which must be contained in a
float array whose X dimension is nxp + 2. The origin of the transform
is at the first point on each line. The direction of the transform is
determined by idirp:
0 Forward (Real --> Complex) exp(+2PIirs)
1 Reverse (Complex --> Real) exp(-2PIirs)
-1 Forward (Complex --> Complex) exp(+2PIirs)
-2 Reverse (Complex --> Complex) exp(-2PIirs)
-3 Reverse (Real --> Complex) exp(-2PIirs)
For Real/complex or Complex/real, only the unique portion of the transform
is written to the array (positive frequencies). For Complex/complex, the
entire transform is written.
Can be called from either C or Fortran by this name.
Function to call odfft from C with arguments passed by value
Performs a two-dimensional FFT in place in array. The data are organized
as nyp rows of nxp values in the real space image, which must be
contained in a float array whose X dimension is nxp + 2. The direction
of the transform is determined by idirp:
0 forward transform : exp(+2PIirs)
1 inverse transform : exp(-2PIirs)
-1 inverse transform but no complex conjugate
The origin of the transform is at the first point. The Y coordinate of the
transform progresses from Y = 0 on the first line, to Y = nyp / 2 - 1 on
the middle line, then from -nyp / 2 on the next line up, to -1 on the
last line.
Can be called from either C or Fortran by this name.
Function to call todfft from C with arguments passed by value
Performs a three-dimensional FFT in place on data in array.
Data are organized as nzp slices each consisting of nyp rows of nxp
values in the real-space image, which must be contained in a float array
whose X dimension is nxp + 2. brray is for working storage and must be
dimensioned to at least (nxp + 2) * nzp. The direction of the
transform is determined by idirp:
0 forward transform
1 inverse transform (for sake of completeness)
-1 inverse transform with no complex conjugate in 2D FFTs
The latter is needed for proper phases and should be used.
The origin of the transform is at the first point. The Y coordinate of the
transform progresses from Y = 0 on the first line, to Y = nyp / 2 - 1 on
the middle line, then from -nyp / 2 on the next line up, to -1 on the
last line. Similarly the Z coordinate progresses from Z = 0 on the first
slice to Z = nzp / 2 - 1, then from -nzp / 2 to -1.
Can be called from either C or Fortran by this name.
Function to call thrdfft from C with arguments passed by value