c09ca computes the one-dimensional discrete wavelet transform (DWT) at a single level. The initialization method C09 Communication class constructor must be called first to set up the DWT options.

# Syntax

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

#### Parameters

n
Type: System..::..Int32
On entry: the number of elements, $n$, in the data array $x$.
Constraint: this must be the same as the value n passed to the initialization method c09aa.
x
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: x contains the input dataset ${x}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$.
ca
Type: array<System..::..Double>[]()[][]
An array of size [lenc]
On exit: ${\mathbf{ca}}\left[i-1\right]$ contains the $i$th approximation coefficient, ${C}_{a}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{n}_{c}$.
cd
Type: array<System..::..Double>[]()[][]
An array of size [lenc]
On exit: ${\mathbf{cd}}\left[\mathit{i}-1\right]$ contains the $\mathit{i}$th detail coefficient, ${C}_{d}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{n}_{c}$.
communications
Type: NagLibrary..::..C09..::..C09Communications
An Object of type C09.c09caCommunications.
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

c09ca computes the one-dimensional DWT of a given input data array, ${x}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$, at a single level. For a chosen wavelet filter pair, the output coefficients are obtained by applying convolution and downsampling by two to the input, $x$. The approximation (or smooth) coefficients, ${C}_{a}$, are produced by the low pass filter and the detail coefficients, ${C}_{d}$, by the high pass filter. To reduce distortion effects at the ends of the data array, several end extension methods are commonly used. Those provided are: periodic or circular convolution end extension, half-point symmetric end extension, whole-point symmetric end extension or zero end extension. The number ${n}_{c}$, of coefficients ${C}_{a}$ or ${C}_{d}$ is returned by the initialization method C09 Communication class constructor.

# References

Daubechies I (1992) Ten Lectures on Wavelets SIAM, Philadelphia

# Error Indicators and Warnings

Errors or warnings detected by the method:
${\mathbf{ifail}}=1$
On entry, n is inconsistent with the value passed to the initialization method C09 Communication class constructor.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{lenc}}<{n}_{c}$, where ${n}_{c}$ is the value returned in nwc by the call to the initialization method C09 Communication class constructor.
${\mathbf{ifail}}=6$
On entry, the initialization method C09 Communication class constructor has not been called first or it has been called with ${\mathbf{wtrans}}=\text{"M"}$, or the communication array icomm has become corrupted.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-1000$
The array lengths are not the same for arrays
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

# Accuracy

The accuracy of the wavelet transform depends only on the floating-point operations used in the convolution and downsampling and should thus be close to machine precision.

None.

None.

# Example

This example computes the one-dimensional discrete wavelet decomposition for $8$ values using the Daubechies wavelet, ${\mathbf{wavnam}}=\text{"DB4"}$, with zero end extension.

Example program (C#): c09cae.cs

Example program data: c09cae.d

Example program results: c09cae.r