C09DCF (PDF version)
C09 Chapter Contents
C09 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

C09DCF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

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

2  Specification

SUBROUTINE C09DCF ( N, X, KEEPA, LENC, C, NWL, NA, ICOMM, IFAIL)
INTEGER  N, LENC, NWL, NA, ICOMM(100), IFAIL
REAL (KIND=nag_wp)  X(N), C(LENC)
CHARACTER(1)  KEEPA

3  Description

C09DCF computes the multi-level MODWT for a data set, xi, for i=1,2,,n, in one dimension. For a chosen number of levels, nl, with nllmax, where lmax is returned by the initialization routine C09AAF 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 parameter KEEPA can be set to retain both approximation and detail coefficients at each level resulting in nl×na+nd coefficients being returned in the output array, C, where na is the number of approximation coefficients and nd 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 na+nl×nd. In the present implementation, for simplicity, na and nd are chosen to be equal by adding zero padding to the wavelet filters where necessary.

4  References

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

5  Parameters

1:     N – INTEGERInput
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 routine C09AAF.
2:     XN – REAL (KIND=nag_wp) arrayInput
On entry: X contains the input dataset xi, for i=1,2,,n.
3:     KEEPA – CHARACTER(1)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.
KEEPA='A'
Retain approximation coefficients for all levels computed.
KEEPA='F'
Retain approximation coefficients for only the final level computed.
Constraint: KEEPA='A' or 'F'.
4:     LENC – INTEGERInput
On entry: the dimension of the array C as declared in the (sub)program from which C09DCF is called. C must be large enough to contain the number of wavelet coefficients.
If KEEPA='F', the total number of coefficients, nc, is returned in NWC by the call to the initialization routine C09AAF and corresponds to the MODWT being continued for the maximum number of levels possible for the given data set. When the number of levels, nl, 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 nd detail coefficients are stored at each level, with the storage increased at the final level to contain the na approximation coefficients.
If KEEPA='A', nd detail coefficients and na approximation coefficients are stored for each level computed, requiring LENCnl×na+nd=2×nl×na, since the numbers of stored approximation and detail coefficients are equal. The number of approximation (or detail) coefficients at each level, na, is returned in NA.
Constraints:
  • if KEEPA='F', LENCnl+1×na;
  • if KEEPA='A', LENC2×nl×na.
5:     CLENC – REAL (KIND=nag_wp) arrayOutput
On exit: the coefficients of a multi-level wavelet transform of the dataset.
The coefficients are stored in C as follows:
If KEEPA='F',
C1:na
Contains the level nl approximation coefficients;
C na + i-1 × nd+1 : na + i × nd
Contains the level nl-i+1 detail coefficients, for i=1,2,,nl;
If KEEPA='A',
C i-1×na+1 : i×na
Contains the level nl-i+1 approximation coefficients, for i=1,2,,nl;
C nl×na+i-1×nd+1 : nl×na+i×nd
Contains the level i detail coefficients, for i=1,2,,nl;
The values na and nd denote the numbers of approximation and detail coefficients respectively, which are equal and returned in NA.
6:     NWL – INTEGERInput
On entry: the number of levels, nl, in the multi-level resolution to be performed.
Constraint: 1NWLlmax, where lmax is the value returned in NWLMAX (the maximum number of levels) by the call to the initialization routine C09AAF.
7:     NA – INTEGEROutput
On exit: NA contains the number of approximation coefficients, na, at each level which is equal to the number of detail coefficients, nd. With periodic end extension (MODE='P' in C09AAF) this is the same as the length, N, of the data array, X.
8:     ICOMM100 – INTEGER arrayCommunication Array
On entry: contains details of the discrete wavelet transform and the problem dimension as setup in the call to the initialization routine C09AAF.
On exit: contains additional information on the computed transform.
9:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry, N is inconsistent with the value passed to the initialization routine: N=value, N should be value.
IFAIL=2
On entry, KEEPA=value was an illegal value.
IFAIL=4
On entry, LENC is set too small: LENC=value.
Constraint: LENCvalue.
IFAIL=6
On entry, NWL=value.
Constraint: NWL1.
On entry, NWL is larger than the maximum number of levels returned by the initialization function: NWL=value, maximum = value.
IFAIL=8
On entry, the initialization routine C09AAF has not been called first or it has not been called with WTRANS='U', or the communication array ICOMM has become corrupted.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

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

8  Parallelism and Performance

Not applicable.

9  Further Comments

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

10  Example

A set of data values (N=64) is decomposed using the MODWT over two levels and then the inverse (C09DDF) is applied to restore the original data set.

10.1  Program Text

Program Text (c09dcfe.f90)

10.2  Program Data

Program Data (c09dcfe.d)

10.3  Program Results

Program Results (c09dcfe.r)


C09DCF (PDF version)
C09 Chapter Contents
C09 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015