Given a sequence of
$n$ complex data values
${z}_{\mathit{j}}$, for
$\mathit{j}=0,1,\dots ,n-1$, C06ECF calculates their discrete Fourier transform defined by
(Note the scale factor of
$\frac{1}{\sqrt{n}}$ in this definition.)
To compute the inverse discrete Fourier transform defined by
this routine should be preceded and followed by calls of
C06GCF to form the complex conjugates of the
${z}_{j}$ and the
${\hat{z}}_{k}$.
C06ECF uses the fast Fourier transform (FFT) algorithm (see
Brigham (1974)). There are some restrictions on the value of
$n$ (see
Section 5).
If on entry
${\mathbf{IFAIL}}={\mathbf{0}}$ or
${-{\mathbf{1}}}$, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Some indication of accuracy can be obtained by performing a subsequent inverse transform and comparing the results with the original sequence (in exact arithmetic they would be identical).
On the other hand, C06ECF is particularly slow if
$n$ has several unpaired prime factors, i.e., if the ‘square-free’ part of
$n$ has several factors.
For such values of
$n$,
C06FCF (which requires an additional
$n$ real elements of workspace) is considerably faster.
This example reads in a sequence of complex data values and prints their discrete Fourier transform. It then performs an inverse transform using C06ECF and
C06GCF, and prints the sequence so obtained alongside the original data values.