NAG Library Routine Document

c09aaf  (dim1_init)


    1  Purpose
    7  Accuracy


c09aaf returns the details of the chosen one-dimensional discrete wavelet filter. For a chosen mother wavelet, discrete wavelet transform type (single-level or multi-level DWT or MODWT) and end extension method, this routine returns the maximum number of levels of resolution (appropriate to a multi-level transform), the filter length, and the number of approximation coefficients (equal to the number of detail coefficients) for a single-level DWT or MODWT or the total number of coefficients for a multi-level DWT or MODWT. This routine must be called before any of the one-dimensional discrete transform routines in this chapter.


Fortran Interface
Subroutine c09aaf ( wavnam, wtrans, mode, n, nwlmax, nf, nwc, icomm, ifail)
Integer, Intent (In):: n
Integer, Intent (Inout):: ifail
Integer, Intent (Out):: nwlmax, nf, nwc, icomm(100)
Character (*), Intent (In):: wavnam
Character (1), Intent (In):: wtrans, mode
C Header Interface
#include nagmk26.h
void  c09aaf_ ( const char *wavnam, const char *wtrans, const char *mode, const Integer *n, Integer *nwlmax, Integer *nf, Integer *nwc, Integer icomm[], Integer *ifail, const Charlen length_wavnam, const Charlen length_wtrans, const Charlen length_mode)


One-dimensional discrete wavelet transforms (DWT) or maximum overlap wavelet transforms (MODWT) are characterised by the mother wavelet, the end extension method and whether multiresolution analysis is to be performed. For the selected combination of choices for these three characteristics, and for a given length, n, of the input data array, x, c09aaf returns the dimension details for the transform determined by this combination. The dimension details are: lmax, the maximum number of levels of resolution that that could be computed were a multi-level DWT/MODWT applied; nf, the filter length; nc the number of approximation (or detail) coefficients for a single-level DWT/MODWT or the total number of coefficients generated by a multi-level DWT/MODWT over lmax levels. These values are also stored in the communication array icomm, as are the input choices, so that they may be conveniently communicated to the one-dimensional transform routines in this chapter.




1:     wavnam – Character(*)Input
On entry: the name of the mother wavelet. See the C09 Chapter Introduction for details.
Haar wavelet.
wavnam='DBn', where n=2,3,,10
Daubechies wavelet with n vanishing moments (2n coefficients). For example, wavnam='DB4' is the name for the Daubechies wavelet with 4 vanishing moments (8 coefficients).
wavnam='BIORx.y', where x.y can be one of 1.1, 1.3, 1.5, 2.2, 2.4, 2.6, 2.8, 3.1, 3.3, 3.5 or 3.7
Biorthogonal wavelet of order x.y. For example wavnam='BIOR3.1' is the name for the biorthogonal wavelet of order 3.1.
Constraint: wavnam='HAAR', 'DB2', 'DB3', 'DB4', 'DB5', 'DB6', 'DB7', 'DB8', 'DB9', 'DB10', 'BIOR1.1', 'BIOR1.3', 'BIOR1.5', 'BIOR2.2', 'BIOR2.4', 'BIOR2.6', 'BIOR2.8', 'BIOR3.1', 'BIOR3.3', 'BIOR3.5' or 'BIOR3.7'.
2:     wtrans – Character(1)Input
On entry: the type of discrete wavelet transform that is to be applied.
Single-level decomposition or reconstruction by discrete wavelet transform.
Multiresolution, by a multi-level DWT or its inverse.
Single-level decomposition or reconstruction by maximal overlap discrete wavelet transform.
Multi-level resolution by a maximal overlap discrete wavelet transform or its inverse.
Constraint: wtrans='S', 'M', 'T' or 'U'.
3:     mode – Character(1)Input
On entry: the end extension method. Note that only periodic end extension is currently available for the MODWT.
Periodic end extension.
Half-point symmetric end extension.
Whole-point symmetric end extension.
Zero end extension.
  • mode='P', 'H', 'W' or 'Z' for DWT;
  • mode='P' for MODWT.
4:     n – IntegerInput
On entry: the number of elements, n, in the input data array, x.
Constraint: n2.
5:     nwlmax – IntegerOutput
On exit: the maximum number of levels of resolution, lmax, that can be computed when a multi-level discrete wavelet transform is applied. It is such that 2lmaxn<2lmax+1, for lmax an integer.
6:     nf – IntegerOutput
On exit: the filter length, nf, for the supplied mother wavelet. This is used to determine the number of coefficients to be generated by the chosen transform.
7:     nwc – IntegerOutput
On exit: for a single-level transform (wtrans='S' or 'T'), the number of approximation coefficients that would be generated for the given problem size, mother wavelet, extension method and type of transform; this is also the corresponding number of detail coefficients. For a multi-level transform (wtrans='M' or 'U') the total number of coefficients that would be generated over lmax levels and with keepa='A' for MODWT.
8:     icomm100 – Integer arrayCommunication Array
On exit: contains details of the wavelet transform and the problem dimension which is to be communicated to the one-dimensional discrete transform routines in this chapter.
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).

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:
On entry, wavnam=value was an illegal value.
On entry, wtrans=value was an illegal value.
On entry, mode=value was an illegal value.
On entry, wtrans='T' or 'U' and mode'P'.
Constraint: mode='P' when wtrans='T' or 'U'.
On entry, n=value.
Constraint: n2.
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.
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.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.


Not applicable.

Parallelism and Performance

c09aaf is not threaded in any implementation.

Further Comments



This example computes the one-dimensional multi-level resolution for 8 values by a discrete wavelet transform using the Haar wavelet with zero end extensions. The length of the wavelet filter, the number of levels of resolution, the number of approximation coefficients at each level and the total number of wavelet coefficients are printed.

Program Text

Program Text (c09aafe.f90)

Program Data

Program Data (c09aafe.d)

Program Results

Program Results (c09aafe.r)

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