﻿ c06ea Method
c06ea calculates the discrete Fourier transform of a sequence of $n$ real data values. (No extra workspace required.)

# Syntax

C#
```public static void c06ea(
double[] x,
int n,
out int ifail
)```
Visual Basic
```Public Shared Sub c06ea ( _
x As Double(), _
n As Integer, _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void c06ea(
array<double>^ x,
int n,
[OutAttribute] int% ifail
)```
F#
```static member c06ea :
x : float[] *
n : int *
ifail : int byref -> unit
```

#### Parameters

x
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: if x is declared with bounds $\left(0:{\mathbf{n}}-1\right)$ in the method from which c06ea is called, then ${\mathbf{x}}\left[\mathit{j}\right]$ must contain ${x}_{\mathit{j}}$, for $\mathit{j}=0,1,\dots ,n-1$.
On exit: the discrete Fourier transform stored in Hermitian form. If the components of the transform ${\stackrel{^}{z}}_{k}$ are written as ${a}_{k}+i{b}_{k}$, and if x is declared with bounds $\left(0:{\mathbf{n}}-1\right)$ in the method from which c06ea is called, then for $0\le k\le n/2$, ${a}_{k}$ is contained in ${\mathbf{x}}\left[k-1\right]$, and for $1\le k\le \left(n-1\right)/2$, ${b}_{k}$ is contained in ${\mathbf{x}}\left[n-k\right]$. (See also [] in the C06 class Chapter Introduction and [Example].)
n
Type: System..::..Int32
On entry: $n$, the number of data values. The largest prime factor of n must not exceed $19$, and the total number of prime factors of n, counting repetitions, must not exceed $20$.
Constraint: ${\mathbf{n}}>1$.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

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

# References

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

# Error Indicators and Warnings

Errors or warnings detected by the method:
${\mathbf{ifail}}=1$
At least one of the prime factors of n is greater than $19$.
${\mathbf{ifail}}=2$
n has more than $20$ prime factors.
${\mathbf{ifail}}=3$
 On entry, ${\mathbf{n}}\le 1$.
${\mathbf{ifail}}=4$
An unexpected error has occurred in an internal call. Check all method calls and array dimensions. Seek expert help.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

# 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).

# Parallelism and Performance

None.

The time taken is approximately proportional to $n×\mathrm{log}\left(n\right)$, but also depends on the factorization of $n$. c06ea is faster if the only prime factors of $n$ are $2$, $3$ or $5$; and fastest of all if $n$ is a power of $2$.
On the other hand, c06ea 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$, (C06FAF not in this release) (which requires additional real workspace) is considerably faster.