PDF version (NAG web site
, 64bit version, 64bit version)
NAG Toolbox: nag_sum_fft_complex_1d (c06pc)
Purpose
nag_sum_fft_complex_1d (c06pc) calculates the discrete Fourier transform of a sequence of n$n$ complex data values (using complex data type).
Syntax
Description
Given a sequence of
n$n$ complex data values
z_{j}
${z}_{\mathit{j}}$, for
j = 0,1, … ,n − 1$\mathit{j}=0,1,\dots ,n1$,
nag_sum_fft_complex_1d (c06pc) calculates their (
forward or
backward) discrete Fourier transform (DFT) defined by
(Note the scale factor of
1/(sqrt(n))
$\frac{1}{\sqrt{n}}$ in this definition.) The minus sign is taken in the argument of the exponential within the summation when the forward transform is required, and the plus sign is taken when the backward transform is required.
A call of
nag_sum_fft_complex_1d (c06pc) with
direct = 'F'${\mathbf{direct}}=\text{'F'}$ followed by a call with
direct = 'B'${\mathbf{direct}}=\text{'B'}$ will restore the original data.
nag_sum_fft_complex_1d (c06pc) uses a variant of the fast Fourier transform (FFT) algorithm (see
Brigham (1974)) known as the Stockham selfsorting algorithm, which is described in
Temperton (1983). If
n$n$ is a large prime number or if
n$n$ contains large prime factors, then the Fourier transform is performed using Bluestein's algorithm (see
Bluestein (1968)), which expresses the DFT as a convolution that in turn can be efficiently computed using FFTs of highly composite sizes.
References
Bluestein L I (1968) A linear filtering approach to the computation of the discrete Fourier transform Northeast Electronics Research and Engineering Meeting Record 10 218–219
Brigham E O (1974) The Fast Fourier Transform Prentice–Hall
Temperton C (1983) Selfsorting mixedradix fast Fourier transforms J. Comput. Phys. 52 1–23
Parameters
Compulsory Input Parameters
 1:
direct – string (length ≥ 1)
If the forward transform as defined in
Section [Description] is to be computed, then
direct must be set equal to 'F'.
If the backward transform is to be computed then
direct must be set equal to 'B'.
Constraint:
direct = 'F'${\mathbf{direct}}=\text{'F'}$ or
'B'$\text{'B'}$.
 2:
x(n) – complex array
n, the dimension of the array, must satisfy the constraint
n ≥ 1${\mathbf{n}}\ge 1$.
If
x is declared with bounds
(0 : n − 1)$(0:{\mathbf{n}}1)$ in the function from which
nag_sum_fft_complex_1d (c06pc) is called, then
x(j)${\mathbf{x}}\left(\mathit{j}\right)$ must contain
z_{j}${z}_{\mathit{j}}$, for
j = 0,1, … ,n − 1$\mathit{j}=0,1,\dots ,n1$.
Optional Input Parameters
 1:
n – int64int32nag_int scalar
Default:
The dimension of the array
x.
n$n$, the number of data values. The total number of prime factors of
n, counting repetitions, must not exceed
30$30$.
Constraint:
n ≥ 1${\mathbf{n}}\ge 1$.
Input Parameters Omitted from the MATLAB Interface
 work
Output Parameters
 1:
x(n) – complex array
The components of the discrete Fourier transform.
If
x is declared with bounds
(0 : n − 1)$(0:{\mathbf{n}}1)$ in the function from which
nag_sum_fft_complex_1d (c06pc) is called, then
ẑ_{k}${\hat{z}}_{k}$ is contained in
x(k)${\mathbf{x}}\left(k\right)$, for
0 ≤ k ≤ n − 1$0\le k\le n1$.
 2:
ifail – int64int32nag_int scalar
ifail = 0${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see
[Error Indicators and Warnings]).
Error Indicators and Warnings
Errors or warnings detected by the function:
 ifail = 1${\mathbf{ifail}}=1$

On entry,  n < 1${\mathbf{n}}<1$. 
 ifail = 2${\mathbf{ifail}}=2$

On entry,  direct ≠ 'F'${\mathbf{direct}}\ne \text{'F'}$ or 'B'$\text{'B'}$. 
 ifail = 3${\mathbf{ifail}}=3$

On entry,  n has more than 30$30$ prime factors. 
 ifail = 4${\mathbf{ifail}}=4$

An unexpected error has occurred in an internal call. Check all function calls and array dimensions. Seek expert help.
Accuracy
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).
Further Comments
The time taken is approximately proportional to n
×
log(n)$n\times \mathrm{log}\left(n\right)$, but also depends on the factorization of n$n$. nag_sum_fft_complex_1d (c06pc) is faster if the only prime factors of n$n$ are 2$2$, 3$3$ or 5$5$; and fastest of all if n$n$ is a power of 2$2$. This function requires a workspace of size 2n + 15$2n+15$ which is internally allocated. When the Bluestein’s FFT algorithm is in use, an additional workspace of size approximately 8n$8n$ is also allocated.
Example
Open in the MATLAB editor:
nag_sum_fft_complex_1d_example
function nag_sum_fft_complex_1d_example
direct = 'F';
x = [ 0.34907  0.37168i;
0.5489  0.35669i;
0.74776  0.31175i;
0.94459  0.23702i;
1.1385  0.13274i;
1.3285 + 0.00074i;
1.5137 + 0.16298i];
[xOut, ifail] = nag_sum_fft_complex_1d(direct, x)
xOut =
2.4836  0.4710i
0.5518 + 0.4968i
0.3671 + 0.0976i
0.2877  0.0586i
0.2251  0.1748i
0.1483  0.3084i
0.0198  0.5650i
ifail =
0
Open in the MATLAB editor:
c06pc_example
function c06pc_example
direct = 'F';
x = [ 0.34907  0.37168i;
0.5489  0.35669i;
0.74776  0.31175i;
0.94459  0.23702i;
1.1385  0.13274i;
1.3285 + 0.00074i;
1.5137 + 0.16298i];
[xOut, ifail] = c06pc(direct, x)
xOut =
2.4836  0.4710i
0.5518 + 0.4968i
0.3671 + 0.0976i
0.2877  0.0586i
0.2251  0.1748i
0.1483  0.3084i
0.0198  0.5650i
ifail =
0
PDF version (NAG web site
, 64bit version, 64bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013