Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_sum_fft_real_1d_nowork (c06ea)

Purpose

nag_sum_fft_real_1d_nowork (c06ea) calculates the discrete Fourier transform of a sequence of n$n$ real data values. (No extra workspace required.)
Note: this function is scheduled to be withdrawn, please see c06ea in Advice on Replacement Calls for Withdrawn/Superseded Routines..

Syntax

[x, ifail] = c06ea(x, 'n', n)
[x, ifail] = nag_sum_fft_real_1d_nowork(x, 'n', n)

Description

Given a sequence of n$n$ real data values xj ${x}_{\mathit{j}}$, for j = 0,1,,n1$\mathit{j}=0,1,\dots ,n-1$, nag_sum_fft_real_1d_nowork (c06ea) calculates their discrete Fourier transform defined by
 n − 1 ẑk = 1/(sqrt(n)) ∑ xj × exp( − i(2πjk)/n),  k = 0,1, … ,n − 1. j = 0
$z^k = 1n ∑ j=0 n-1 xj × exp( -i 2πjk n ) , k= 0, 1, …, n-1 .$
(Note the scale factor of 1/(sqrt(n)) $\frac{1}{\sqrt{n}}$ in this definition.) The transformed values k ${\stackrel{^}{z}}_{k}$ are complex, but they form a Hermitian sequence (i.e., nk ${\stackrel{^}{z}}_{n-k}$ is the complex conjugate of k ${\stackrel{^}{z}}_{k}$), so they are completely determined by n$n$ real numbers (see also the C06 Chapter Introduction).
To compute the inverse discrete Fourier transform defined by
 n − 1 ŵk = 1/(sqrt(n)) ∑ xj × exp( + i(2πjk)/n), j = 0
$w^k = 1n ∑ j=0 n-1 xj × exp( +i 2πjk n ) ,$
this function should be followed by a call of nag_sum_conjugate_hermitian_rfmt (c06gb) to form the complex conjugates of the k ${\stackrel{^}{z}}_{k}$.
nag_sum_fft_real_1d_nowork (c06ea) uses the fast Fourier transform (FFT) algorithm (see Brigham (1974)). There are some restrictions on the value of n$n$ (see Section [Parameters]).

References

Brigham E O (1974) The Fast Fourier Transform Prentice–Hall

Parameters

Compulsory Input Parameters

1:     x(n) – double array
n, the dimension of the array, must satisfy the constraint n > 1${\mathbf{n}}>1$.
x(j + 1)${\mathbf{x}}\left(\mathit{j}+1\right)$ must contain xj${x}_{\mathit{j}}$, for j = 0,1,,n1$\mathit{j}=0,1,\dots ,n-1$.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array x.
n$n$, the number of data values. The largest prime factor of n must not exceed 19$19$, and the total number of prime factors of n, counting repetitions, must not exceed 20$20$.
Constraint: n > 1${\mathbf{n}}>1$.

None.

Output Parameters

1:     x(n) – double array
The discrete Fourier transform stored in Hermitian form. If the components of the transform k${\stackrel{^}{z}}_{k}$ are written as ak + i bk${a}_{k}+i{b}_{k}$, and if x is declared with bounds (0 : n1)$\left(0:{\mathbf{n}}-1\right)$ in the function from which nag_sum_fft_real_1d_nowork (c06ea) is called, then for 0 k n / 2$0\le k\le n/2$, ak${a}_{k}$ is contained in x(k)${\mathbf{x}}\left(k\right)$, and for 1 k (n1) / 2 $1\le k\le \left(n-1\right)/2$, bk${b}_{k}$ is contained in x(nk)${\mathbf{x}}\left(n-k\right)$. (See also Section [Real transforms] in the C06 Chapter Introduction and Section [Example].)
2:     ifail – int64int32nag_int scalar
${\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$
At least one of the prime factors of n is greater than 19$19$.
ifail = 2${\mathbf{ifail}}=2$
n has more than 20$20$ prime factors.
ifail = 3${\mathbf{ifail}}=3$
 On entry, n ≤ 1${\mathbf{n}}\le 1$.
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).

The time taken is approximately proportional to n × log(n)$n×\mathrm{log}\left(n\right)$, but also depends on the factorization of n$n$. nag_sum_fft_real_1d_nowork (c06ea) 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$.
On the other hand, nag_sum_fft_real_1d_nowork (c06ea) is particularly slow if n$n$ has several unpaired prime factors, i.e., if the ‘square-free’ part of n$n$ has several factors. For such values of n$n$, nag_sum_fft_real_1d_rfmt (c06fa) (which requires additional double workspace) is considerably faster.

Example

```function nag_sum_fft_real_1d_nowork_example
x = [0.34907;
0.5489;
0.74776;
0.94459;
1.1385;
1.3285;
1.5137];
[xOut, ifail] = nag_sum_fft_real_1d_nowork(x)
```
```

xOut =

2.4836
-0.2660
-0.2577
-0.2564
0.0581
0.2030
0.5309

ifail =

0

```
```function c06ea_example
x = [0.34907;
0.5489;
0.74776;
0.94459;
1.1385;
1.3285;
1.5137];
[xOut, ifail] = c06ea(x)
```
```

xOut =

2.4836
-0.2660
-0.2577
-0.2564
0.0581
0.2030
0.5309

ifail =

0

```