Next Previous Contents

7. fftw.ct

This section describes functions from file fftw.ct.

7.1 FFT

[f] = FFT(u; dim)
 FFT(u) gives the complex Fast Fourier Transform of u.
   If u's rank is more than one, the transform is computed
   only along the first dimension (many independent 1D
   transforms).

   FFT(u,dim) computes the FFT along the specified dimension.
   The first dimension is labeled 1 and so on.

   For vector u, f=FFT(u) is equivalent with

   n = length(u); f = czeros(n);
   for (j=1; j<=n; j++)
       f[j] = sum(u*exp(-(j-1)*(0:n-1)*2i*pi/n));

   All Fourier transform functions in Tela can take the transform
   along any dimension in a multidimensional array, and the transform
   length is not restricted. The function FFT should be used only in
   case of complex input data. Use realFFT for real input array.

   Functions FFT, realFFT, sinqFFT, cosFFT and their inverses
   are the most efficient when the transform length n is a product
   of small primes.

   Functions sinFFT and invsinFFT are efficient when n+1 is
   a product of small primes
           
   Functions cosFFT and invcosFFT are efficient when n-1 is
   a product of small primes
           
See also: invFFT, realFFT, sinFFT, cosFFT, sinqFFT, cosqFFT, Lomb.
   Error codes:
   -1: First argument not a numeric array
   -2: Second argument not integer
   -3: Second argument out of range
   

7.2 invFFT

[f] = invFFT(u; dim)
 invFFT() is the inverse of FFT().
   For vector f, u=invFFT(f) is equivalent with

   n = length(f); u = czeros(n);
   for (j=1; j<=n; j++)
       u[j] = (1/n)*sum(f*exp((j-1)*(0:n-1)*2i*pi/n));

   Differences with FFT: sign of i is plus, scale factor 1/n.
   
See also: FFT.
   Error codes:
   -1: First argument not a numeric array
   -2: Second argument not integer
   -3: Second argument out of range
   

7.3 invrealFFT

[f] = invrealFFT(u; dim,oddevenspec)
 invrealFFT() is the inverse of realFFT().
   invrealFFT(u,dim,"even") and invrealFFT(u,dim,"odd") specifies
   even or odd transform length, respectively.
   invrealFFT(u,dim,N) uses the same evenness as the integer N has.

   If the evenness is not specified explicitly, the imaginary parts
   of the highest frequency components are tested. If they are all zero
   the transform length is even, otherwise odd. However, this automatic
   method will fail if the imaginary parts are not EXACTLY zero. If you
   use multiple FFTs to solve a PDE, for example, you should probably
   specify the evenness explicitly.
See also: realFFT.
   Error codes:
   -1: First argument not a complex array
   -2: Second argument not integer
   -3: Second argument out of range
   -4: Third argument not "even", "odd" or an integer
   

7.4 realFFT

[f] = realFFT(u; dim)
 realFFT(u) gives the Fast Fourier Transform of real array u.
   If u's rank is more than one, the transform is computed
   only along the first dimension (many independent 1D
   transforms).

   realFFT(u,dim) computes the FFT along the specified dimension.
   The first dimension is labeled 1 and so on.

   The result of realFFT() is the same as FFT() except that only
   nonnegative frequency components are returned. The result is
   always complex array. The first component (0 frequency) has always
   zero imaginary part. If the transform length is even, the last
   component has zero imaginary part as well. Notice that these
   conventions are different from some generally used C and Fortran
   library routines, which return a real array force-fitted
   in the same space as the input array by not storing the zero
   imaginary parts. The Tela convention allows you to manipulate the
   result in k-space more easily because it is already complex.

   realFFT is the most efficient when the transform length is
   a product of small primes.
   
See also: invrealFFT, FFT, sinFFT, cosFFT, sinqFFT, cosqFFT, Lomb.
   Error codes:
   -1: First argument not a real array
   -2: Second argument not integer
   -3: Second argument out of range
   


Next Previous Contents