hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_sum_fft_realherm_1d (c06pa)

Purpose

nag_sum_fft_realherm_1d (c06pa) calculates the discrete Fourier transform of a sequence of nn real data values or of a Hermitian sequence of nn complex data values stored in compact form in a double array.

Syntax

[x, ifail] = c06pa(direct, x, n)
[x, ifail] = nag_sum_fft_realherm_1d(direct, x, n)

Description

Given a sequence of nn real data values xj xj , for j = 0,1,,n1j=0,1,,n-1, nag_sum_fft_realherm_1d (c06pa) calculates their discrete Fourier transform (in the Forward direction) defined by
n1
k = 1/(sqrt(n))xj × exp(i(2πjk)/n),  k = 0,1,,n1.
j = 0
z^k = 1n j=0 n-1 xj × exp( -i 2πjk n ) ,   k= 0, 1, , n-1 .
The transformed values k z^k  are complex, but they form a Hermitian sequence (i.e., nk z^ n-k  is the complex conjugate of k z^k ), so they are completely determined by nn real numbers (since 0 z^0  is real, as is n / 2 z^ n/2  for nn even).
Alternatively, given a Hermitian sequence of nn complex data values zj zj , this function calculates their inverse (backward) discrete Fourier transform defined by
n1
k = 1/(sqrt(n))zj × exp(i(2πjk)/n),  k = 0,1,,n1.
j = 0
x^k = 1n j=0 n-1 zj × exp( i 2πjk n ) ,   k= 0, 1, , n-1 .
The transformed values k x^k  are real.
(Note the scale factor of 1/(sqrt(n)) 1n  in the above definitions.)
A call of nag_sum_fft_realherm_1d (c06pa) with direct = 'F'direct='F' followed by a call with direct = 'B'direct='B' will restore the original data.
nag_sum_fft_realherm_1d (c06pa) uses a variant of the fast Fourier transform (FFT) algorithm (see Brigham (1974)) known as the Stockham self-sorting algorithm, which is described in Temperton (1983).
The same functionality is available using the forward and backward transform function pair: nag_sum_fft_real_2d (c06pv) and nag_sum_fft_hermitian_2d (c06pw) on setting n = 1n=1. This pair use a different storage solution; real data is stored in a double array, while Hermitian data (the first unconjugated half) is stored in a complex array.

References

Brigham E O (1974) The Fast Fourier Transform Prentice–Hall
Temperton C (1983) Self-sorting mixed-radix 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'direct='F' or 'B''B'.
2:     x( n + 2 n+2 ) – double array
If x is declared with bounds (0 : n + 1)(0:n+1) in the function from which nag_sum_fft_realherm_1d (c06pa) is called, then:
  • if direct = 'F'direct='F', x(j)xj must contain xjxj, for j = 0,1,,n1j=0,1,,n-1;
  • if direct = 'B'direct='B', x(2 × k)x2×k and x(2 × k + 1)x2×k+1 must contain the real and imaginary parts respectively of zkzk, for k = 0,1,,n / 2k=0,1,,n/2. (Note that for the sequence zkzk to be Hermitian, the imaginary part of z0z0, and of zn / 2zn/2  for nn even, must be zero.)
3:     n – int64int32nag_int scalar
nn, the number of data values. The total number of prime factors of n, counting repetitions, must not exceed 3030.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

work

Output Parameters

1:     x( n + 2 n+2 ) – double array
  • if direct = 'F'direct='F' and x is declared with bounds (0 : n + 1)(0:n+1), x(2 × k)x2×k and x(2 × k + 1)x2×k+1 will contain the real and imaginary parts respectively of kz^k, for k = 0,1,,n / 2k=0,1,,n/2;
  • if direct = 'B'direct='B' and x is declared with bounds (0 : n + 1)(0:n+1), x(j)xj will contain jx^j, for j = 0,1,,n1j=0,1,,n-1.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,n < 1n<1.
  ifail = 2ifail=2
On entry,direct'F'direct'F' or 'B''B'.
  ifail = 4ifail=4
On entry,n has more than 3030 prime factors.
  ifail = 5ifail=5
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 × log(n), but also depends on the factorization of nn. nag_sum_fft_realherm_1d (c06pa) is faster if the only prime factors of nn are 22, 33 or 55; and fastest of all if nn is a power of 22.

Example

function nag_sum_fft_realherm_1d_example
direct = 'F';
x = [0.34907;
     0.5489;
     0.74776;
     0.94459;
     1.1385;
     1.3285;
     1.5137;
     0;
     0];
n = int64(7);
[xOut, ifail] = nag_sum_fft_realherm_1d(direct, x, n)
 

xOut =

    2.4836
         0
   -0.2660
    0.5309
   -0.2577
    0.2030
   -0.2564
    0.0581
         0


ifail =

                    0


function c06pa_example
direct = 'F';
x = [0.34907;
     0.5489;
     0.74776;
     0.94459;
     1.1385;
     1.3285;
     1.5137;
     0;
     0];
n = int64(7);
[xOut, ifail] = c06pa(direct, x, n)
 

xOut =

    2.4836
         0
   -0.2660
    0.5309
   -0.2577
    0.2030
   -0.2564
    0.0581
         0


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013