NAG CL Interfacec09dcc (dim1_​mxolap_​multi_​fwd)

Settings help

CL Name Style:

1Purpose

c09dcc computes the one-dimensional multi-level maximal overlap discrete wavelet transform (MODWT). The initialization function c09aac must be called first to set up the MODWT options.

2Specification

 #include
 void c09dcc (Integer n, const double x[], Nag_WaveletCoefficients keepa, Integer lenc, double c[], Integer nwl, Integer *na, Integer icomm[], NagError *fail)
The function may be called by the names: c09dcc, nag_wav_dim1_mxolap_multi_fwd or nag_mlmodwt.

3Description

c09dcc computes the multi-level MODWT for a data set, ${\mathit{x}}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$, in one dimension. For a chosen number of levels, ${n}_{l}$, with ${n}_{l}\le {l}_{\mathrm{max}}$, where ${l}_{\mathrm{max}}$ is returned by the initialization function c09aac in nwlmax, the transform is returned as a set of coefficients for the different levels stored in a single array. Periodic reflection is currently the only available end extension method to reduce the edge effects caused by finite data sets.
The argument keepa can be set to retain both approximation and detail coefficients at each level resulting in ${n}_{l}×\left({n}_{a}+{n}_{d}\right)$ coefficients being returned in the output array, c, where ${n}_{a}$ is the number of approximation coefficients and ${n}_{d}$ is the number of detail coefficients. Otherwise, only the detail coefficients are stored for each level along with the approximation coefficients for the final level, in which case the length of the output array, c, is ${n}_{a}+{n}_{l}×{n}_{d}$. In the present implementation, for simplicity, ${n}_{a}$ and ${n}_{d}$ are chosen to be equal by adding zero padding to the wavelet filters where necessary.

4References

Percival D B and Walden A T (2000) Wavelet Methods for Time Series Analysis Cambridge University Press

5Arguments

1: $\mathbf{n}$Integer Input
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 function c09aac.
2: $\mathbf{x}\left[{\mathbf{n}}\right]$const double Input
On entry: x contains the input dataset ${x}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$.
3: $\mathbf{keepa}$Nag_WaveletCoefficients Input
On entry: determines whether the approximation coefficients are stored in array c for every level of the computed transform or else only for the final level. In both cases, the detail coefficients are stored in c for every level computed.
${\mathbf{keepa}}=\mathrm{Nag_StoreAll}$
Retain approximation coefficients for all levels computed.
${\mathbf{keepa}}=\mathrm{Nag_StoreFinal}$
Retain approximation coefficients for only the final level computed.
Constraint: ${\mathbf{keepa}}=\mathrm{Nag_StoreAll}$ or $\mathrm{Nag_StoreFinal}$.
4: $\mathbf{lenc}$Integer Input
On entry: the dimension of the array c. c must be large enough to contain the number of wavelet coefficients.
If ${\mathbf{keepa}}=\mathrm{Nag_StoreFinal}$, the total number of coefficients, ${n}_{c}$, is returned in nwc by the call to the initialization function c09aac and corresponds to the MODWT being continued for the maximum number of levels possible for the given data set. When the number of levels, ${n}_{l}$, is chosen to be less than the maximum, then the number of stored coefficients is correspondingly smaller and lenc can be reduced by noting that ${n}_{d}$ detail coefficients are stored at each level, with the storage increased at the final level to contain the ${n}_{a}$ approximation coefficients.
If ${\mathbf{keepa}}=\mathrm{Nag_StoreAll}$, ${n}_{d}$ detail coefficients and ${n}_{a}$ approximation coefficients are stored for each level computed, requiring ${\mathbf{lenc}}\ge {n}_{l}×\left({n}_{a}+{n}_{d}\right)=2×{n}_{l}×{n}_{a}$, since the numbers of stored approximation and detail coefficients are equal. The number of approximation (or detail) coefficients at each level, ${n}_{a}$, is returned in na.
Constraints:
• if ${\mathbf{keepa}}=\mathrm{Nag_StoreFinal}$, ${\mathbf{lenc}}\ge \left({n}_{l}+1\right)×{n}_{a}$;
• if ${\mathbf{keepa}}=\mathrm{Nag_StoreAll}$, ${\mathbf{lenc}}\ge 2×{n}_{l}×{n}_{a}$.
5: $\mathbf{c}\left[{\mathbf{lenc}}\right]$double Output
On exit: the coefficients of a multi-level wavelet transform of the dataset.
The coefficients are stored in c as follows:
If ${\mathbf{keepa}}=\mathrm{Nag_StoreFinal}$,
${\mathbf{C}}\left(1:{n}_{a}\right)$
Contains the level ${n}_{l}$ approximation coefficients;
${\mathbf{C}}\left({n}_{a}+\left(i-1\right)×{n}_{d}+1:{n}_{a}+i×{n}_{d}\right)$
Contains the level $\left({n}_{l}-\mathit{i}+1\right)$ detail coefficients, for $\mathit{i}=1,2,\dots ,{n}_{l}$;
If ${\mathbf{keepa}}=\mathrm{Nag_StoreAll}$,
${\mathbf{C}}\left(\left(i-1\right)×{n}_{a}+1:i×{n}_{a}\right)$
Contains the level $\left({n}_{l}-\mathit{i}+1\right)$ approximation coefficients, for $\mathit{i}=1,2,\dots ,{n}_{l}$;
${\mathbf{C}}\left({n}_{l}×{n}_{a}+\left(i-1\right)×{n}_{d}+1:{n}_{l}×{n}_{a}+i×{n}_{d}\right)$
Contains the level i detail coefficients, for $\mathit{i}=1,2,\dots ,{n}_{l}$;
The values ${n}_{a}$ and ${n}_{d}$ denote the numbers of approximation and detail coefficients respectively, which are equal and returned in na.
6: $\mathbf{nwl}$Integer Input
On entry: the number of levels, ${n}_{l}$, in the multi-level resolution to be performed.
Constraint: $1\le {\mathbf{nwl}}\le {l}_{\mathrm{max}}$, where ${l}_{\mathrm{max}}$ is the value returned in nwlmax (the maximum number of levels) by the call to the initialization function c09aac.
7: $\mathbf{na}$Integer * Output
On exit: na contains the number of approximation coefficients, ${n}_{a}$, at each level which is equal to the number of detail coefficients, ${n}_{d}$. With periodic end extension (${\mathbf{mode}}=\mathrm{Nag_Periodic}$ in c09aac) this is the same as the length, n, of the data array, x.
8: $\mathbf{icomm}\left[100\right]$Integer Communication Array
On entry: contains details of the discrete wavelet transform and the problem dimension as setup in the call to the initialization function c09aac.
On exit: contains additional information on the computed transform.
9: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_ARRAY_DIM_LEN
On entry, lenc is set too small: ${\mathbf{lenc}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lenc}}\ge ⟨\mathit{\text{value}}⟩$.
NE_BAD_PARAM
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INITIALIZATION
On entry, n is inconsistent with the value passed to the initialization function: ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$, n should be $⟨\mathit{\text{value}}⟩$.
On entry, nwl is larger than the maximum number of levels returned by the initialization function: ${\mathbf{nwl}}=⟨\mathit{\text{value}}⟩$, maximum = $⟨\mathit{\text{value}}⟩$.
On entry, the initialization function c09aac has not been called first or it has not been called with ${\mathbf{wtrans}}=\mathrm{Nag_MODWTMulti}$, or the communication array icomm has become corrupted.
NE_INT
On entry, ${\mathbf{nwl}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nwl}}\ge 1$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

7Accuracy

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.

8Parallelism and Performance

c09dcc is not threaded in any implementation.

9Further Comments

The wavelet coefficients at each level can be extracted from the output array c using the information contained in na on exit.

10Example

A set of data values (${\mathbf{n}}=64$) is decomposed using the MODWT over two levels and then the inverse (c09ddc) is applied to restore the original data set.

10.1Program Text

Program Text (c09dcce.c)

10.2Program Data

Program Data (c09dcce.d)

10.3Program Results

Program Results (c09dcce.r)