Next Previous Contents

7. fft.ct

This section describes functions from file fft.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.
   Error codes:
   -1: First argument not a numeric array
   -2: Second argument not integer
   -3: Second argument out of range
   

7.2 cosFFT

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

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

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

   n = length(u); f = zeros(n);
   for (j=1; j<=n; j++)
       f[j] = u[1] - (-1)^j*u[n] + 2*sum(u[2:n-1]*cos((1:n-2)*(j-1)*pi/(n-1)));

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

7.3 cosqFFT

[f] = cosqFFT(u; dim)
 cosqFFT computes the quarter-wave cosine Fourier transform.
   Except for the quarter-wave cosine character, it works similarly to cosFFT.
   
   For vector u, f=cosqFFT(u) is equivalent with

   n = length(u); f = zeros(n);
   for (j=1; j<=n; j++)
       f[j] = u[1] + 2*sum(u[2:n]*cos((2*j-1)*(1:n-1)*pi/(2*n)));
   
   cosqFFT is most efficient when the transform length is a product
   of small primes.
           
See also: invcosqFFT, realFFT, sinqFFT, FFT.
   Error codes:
   -1: First argument not a real array
   -2: Second argument not integer
   -3: Second argument out of range
   

7.4 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.5 invcosFFT

[f] = invcosFFT(u; dim)
 invcosFFT() is the inverse of cosFFT().
   Actually invcosFFT differs from cosFFT only by normalization,
   but it is provided as a separate function for convenience.
   
   For vector f, u=invcosFFT(f) is equivalent with

   n = length(f); u = zeros(n);
   for (j=1; j<=n; j++)
       u[j] = (f[1] - (-1)^j*f[n] + 2*sum(f[2:n-1]*cos((1:n-2)*(j-1)*pi/(n-1))))/(2*n-2)
   
See also: cosFFT.
   Error codes:
   -1: First argument not a real array
   -2: Second argument not integer
   -3: Second argument out of range
   

7.6 invcosqFFT

[f] = invcosqFFT(u; dim)
 invcosqFFT() is the inverse of cosqFFT()
   (inverse quarter-wave cosine Fourier transform).
   
   For vector f, u=invcosqFFT(f) is equivalent with

   n = length(f); u = zeros(n);
   for (j=1; j<=n; j++)
       u[j] = (1/n)*sum(f*cos((2*(1:n)-1)*(j-1)*pi/(2*n)));
   
See also: cosqFFT.
   Error codes:
   -1: First argument not a real array
   -2: Second argument not integer
   -3: Second argument out of range
   

7.7 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.8 invsinFFT

[f] = invsinFFT(u; dim)
 invsinFFT() is the inverse of sinFFT().
   Actually invsinFFT differs from sinFFT only by normalization,
   but it is provided as a separate function for convenience.
   
   For vector f, u=invsinFFT(f) is equivalent with

   n = length(f); u = zeros(n);
   for (j=1; j<=n; j++)
       u[j] = (1/(n+1))*sum(f*sin((1:n)*j*pi/(n+1)));
   
See also: sinFFT.
   Error codes:
   -1: First argument not a real array
   -2: Second argument not integer
   -3: Second argument out of range
   

7.9 invsinqFFT

[f] = invsinqFFT(u; dim)
 invsinqFFT() is the inverse of sinqFFT()
   (inverse quarter-wave sine Fourier transform).
   
   For vector f, u=invsinqFFT(f) is equivalent with

   n = length(f); u = zeros(n);
   for (j=1; j<=n; j++)
       u[j] = (1/n)*sum(f*sin((2*(1:n)-1)*j*pi/(2*n)));
   
See also: sinqFFT.
   Error codes:
   -1: First argument not a real array
   -2: Second argument not integer
   -3: Second argument out of range
   

7.10 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.
   Error codes:
   -1: First argument not a real array
   -2: Second argument not integer
   -3: Second argument out of range
   

7.11 sinFFT

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

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

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

   n = length(u); f = zeros(n);
   for (j=1; j<=n; j++)
       f[j] = 2*sum(u*sin((1:n)*j*pi/(n+1)));

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

7.12 sinqFFT

[f] = sinqFFT(u; dim)
 sinqFFT computes the quarter-wave sine Fourier transform of array u.
   Except for the quarter-wave sine character, it works similarly to sinFFT.
   
   For vector u, f=sinqFFT(u) is equivalent with

   n = length(u); f = zeros(n);
   for (j=1; j<=n; j++)
       f[j] = (-1)^(j-1)*u[n] + 2*sum(u[1:n-1]*sin((2*j-1)*(1:n-1)*pi/(2*n)));

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


Next Previous Contents