NAG Library Routine Document

c09dcf (dim1_mxolap_multi_fwd)

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

Fortran Interface
Subroutine c09dcf ( n, x, keepa, lenc, c, nwl, na, icomm, ifail)
Integer, Intent (In):: n, lenc, nwl
Integer, Intent (Inout):: icomm(100), ifail
Integer, Intent (Out):: na
Real (Kind=nag_wp), Intent (In):: x(n)
Real (Kind=nag_wp), Intent (Out):: c(lenc)
Character (1), Intent (In):: keepa
C Header Interface
#include <nagmk26.h>
void  c09dcf_ (const Integer *n, const double x[], const char *keepa, const Integer *lenc, double c[], const Integer *nwl, Integer *na, Integer icomm[], Integer *ifail, const Charlen length_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 argument 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
Arguments

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 argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation 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

c09dcf is not threaded in any implementation.

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)