The interface to the FFTPACK library is performed via the fftpack
module, which is responsible for making sure that the arrays sent to the
FFTPACK routines are in the right format (contiguous memory locations, right
numerical storage format, etc). It provides interfaces to the following FFTPACK
routines, which are also the names of the Python functions:
cffti(
i)
cfftf(
data, savearea)
cfftb(
data, savearea)
rffti(
i)
rfftf(
data, savearea)
rfftb(
data, savearea)
The routines which start with c expect arrays of complex numbers, the
routines which start with r expect real numbers only. The routines
which end with i are the initalization functions, those which end with
f perform the forward FFTs and those which end with b perform
the backwards FFTs.
The initialization functions require a single integer argument corresponding to
the size of the dataset, and returns a work array. The forward and backwards
FFTs require two array arguments - the first is the data array, the second is
the work array returned by the initialization function. They return arrays
corresponding to the coefficients of the FFT, with the first element in the
returned array corresponding to the DC component, the second one to the first
fundamental, etc.The length of the returned array is 1 + half the length of the
input array in the case of real FFTs, and the same size as the input array in
the case of complex data.
>>> import numarray.fft.fftpack as fftpack
>>> x = cos(arange(30.0)/30.0*2*pi)
>>> w = fftpack.rffti(30)
>>> f = fftpack.rfftf(x, w)
>>> print f[0:5]
[ -5.68989300e-16 +0.00000000e+00j 1.50000000e+01 -3.08862614e-15j
6.86516117e-16 -1.00588467e-15j 1.12688689e-15 -3.19983494e-15j
-1.52158521e-15 +1.14787259e-15j]