NAG Library Function Document
nag_mlmodwt (c09dcc) computes the one-dimensional multi-level maximal overlap discrete wavelet transform (MODWT). The initialization function nag_wfilt (c09aac)
must be called first to set up the MODWT options.
||nag_mlmodwt (Integer n,
const double x,
nag_mlmodwt (c09dcc) computes the multi-level MODWT for a data set,
, in one dimension. For a chosen number of levels,
is returned by the initialization function nag_wfilt (c09aac)
, 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
coefficients being returned in the output array, c
is the number of approximation coefficients and
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
. In the present implementation, for simplicity,
are chosen to be equal by adding zero padding to the wavelet filters where necessary.
Percival D B and Walden A T (2000) Wavelet Methods for Time Series Analysis Cambridge University Press
n – IntegerInput
On entry: the number of elements, , in the data array .
this must be the same as the value n
passed to the initialization function nag_wfilt (c09aac)
x[n] – const doubleInput
contains the input dataset
keepa – Nag_WaveletCoefficientsInput
: 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.
- Retain approximation coefficients for all levels computed.
- Retain approximation coefficients for only the final level computed.
lenc – IntegerInput
: the dimension of the array c
must be large enough to contain the number of wavelet coefficients.
, the total number of coefficients,
, is returned in nwc
by the call to the initialization function nag_wfilt (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,
, 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
detail coefficients are stored at each level, with the storage increased at the final level to contain the
detail coefficients and
approximation coefficients are stored for each level computed, requiring
, since the numbers of stored approximation and detail coefficients are equal. The number of approximation (or detail) coefficients at each level,
, is returned in na
- if , ;
- if , .
c[lenc] – doubleOutput
: the coefficients of a multi-level wavelet transform of the dataset.
The coefficients are stored in c
- Contains the level approximation coefficients;
- Contains the level detail coefficients, for ;
- Contains the level approximation coefficients, for ;
- Contains the level i detail coefficients, for ;
denote the numbers of approximation and detail coefficients respectively, which are equal and returned in na
nwl – IntegerInput
On entry: the number of levels, , in the multi-level resolution to be performed.
is the value returned in nwlmax
(the maximum number of levels) by the call to the initialization function nag_wfilt (c09aac)
na – Integer *Output
contains the number of approximation coefficients,
, at each level which is equal to the number of detail coefficients,
. With periodic end extension (
in nag_wfilt (c09aac)
) this is the same as the length, n
, of the data array, x
icomm – IntegerCommunication Array
: contains details of the discrete wavelet transform and the problem dimension as setup in the call to the initialization function nag_wfilt (c09aac)
On exit: contains additional information on the computed transform.
fail – NagError *Input/Output
The NAG error argument (see Section 3.6
in the Essential Introduction).
6 Error Indicators and Warnings
On entry, lenc
is set too small:
On entry, argument had an illegal value.
On entry, n
is inconsistent with the value passed to the initialization function:
On entry, nwl
is larger than the maximum number of levels returned by the initialization function:
, maximum =
On entry, the initialization function nag_wfilt (c09aac)
has not been called first or it has not been called with
, or the communication array icomm
has become corrupted.
On entry, .
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
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.
8 Parallelism and Performance
The wavelet coefficients at each level can be extracted from the output array c
using the information contained in na
A set of data values (
) is decomposed using the MODWT over two levels and then the inverse (nag_imlmodwt (c09ddc)
) is applied to restore the original data set.
10.1 Program Text
Program Text (c09dcce.c)
10.2 Program Data
Program Data (c09dcce.d)
10.3 Program Results
Program Results (c09dcce.r)