c09 Chapter Contents
c09 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_wfilt (c09aac)

## 1  Purpose

nag_wfilt (c09aac) 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 function 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 function must be called before any of the one-dimensional discrete transform functions in this chapter.

## 2  Specification

 #include #include
 void nag_wfilt (Nag_Wavelet wavnam, Nag_WaveletTransform wtrans, Nag_WaveletMode mode, Integer n, Integer *nwlmax, Integer *nf, Integer *nwc, Integer icomm[], NagError *fail)

## 3  Description

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$, nag_wfilt (c09aac) returns the dimension details for the transform determined by this combination. The dimension details are: ${l}_{\mathrm{max}}$, the maximum number of levels of resolution that that could be computed were a multi-level DWT/MODWT applied; ${n}_{f}$, the filter length; ${n}_{c}$ 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 ${l}_{\mathrm{max}}$ 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 functions in this chapter.
None.

## 5  Arguments

1:    $\mathbf{wavnam}$Nag_WaveletInput
On entry: the name of the mother wavelet. See the c09 Chapter Introduction for details.
${\mathbf{wavnam}}=\mathrm{Nag_Haar}$
Haar wavelet.
${\mathbf{wavnam}}=\mathrm{Nag_Daubechies}\mathbit{n}$, where $\mathbit{n}=2,3,\dots ,10$
Daubechies wavelet with $\mathbit{n}$ vanishing moments ($2\mathbit{n}$ coefficients). For example, ${\mathbf{wavnam}}=\mathrm{Nag_Daubechies4}$ is the name for the Daubechies wavelet with $4$ vanishing moments ($8$ coefficients).
${\mathbf{wavnam}}=\mathrm{Nag_Biorthogonal}\mathbit{x}_\mathbit{y}$, where $\mathbit{x}_\mathbit{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 $\mathbit{x}$.$\mathbit{y}$. For example ${\mathbf{wavnam}}=\mathrm{Nag_Biorthogonal1_1}$ is the name for the Biorthogonal wavelet of order $1.1$.
Constraint: ${\mathbf{wavnam}}=\mathrm{Nag_Haar}$, $\mathrm{Nag_Daubechies2}$, $\mathrm{Nag_Daubechies3}$, $\mathrm{Nag_Daubechies4}$, $\mathrm{Nag_Daubechies5}$, $\mathrm{Nag_Daubechies6}$, $\mathrm{Nag_Daubechies7}$, $\mathrm{Nag_Daubechies8}$, $\mathrm{Nag_Daubechies9}$, $\mathrm{Nag_Daubechies10}$, $\mathrm{Nag_Biorthogonal1_1}$, $\mathrm{Nag_Biorthogonal1_3}$, $\mathrm{Nag_Biorthogonal1_5}$, $\mathrm{Nag_Biorthogonal2_2}$, $\mathrm{Nag_Biorthogonal2_4}$, $\mathrm{Nag_Biorthogonal2_6}$, $\mathrm{Nag_Biorthogonal2_8}$, $\mathrm{Nag_Biorthogonal3_1}$, $\mathrm{Nag_Biorthogonal3_3}$, $\mathrm{Nag_Biorthogonal3_5}$ or $\mathrm{Nag_Biorthogonal3_7}$.
2:    $\mathbf{wtrans}$Nag_WaveletTransformInput
On entry: the type of discrete wavelet transform that is to be applied.
${\mathbf{wtrans}}=\mathrm{Nag_SingleLevel}$
Single-level decomposition or reconstruction by discrete wavelet transform.
${\mathbf{wtrans}}=\mathrm{Nag_MultiLevel}$
Multiresolution, by a multi-level DWT or its inverse.
${\mathbf{wtrans}}=\mathrm{Nag_MODWTSingle}$
Single-level decomposition or reconstruction by maximal overlap discrete wavelet transform.
${\mathbf{wtrans}}=\mathrm{Nag_MODWTMulti}$
Multi-level resolution by a maximal overlap discrete wavelet transform or its inverse.
Constraint: ${\mathbf{wtrans}}=\mathrm{Nag_SingleLevel}$, $\mathrm{Nag_MultiLevel}$, $\mathrm{Nag_MODWTSingle}$ or $\mathrm{Nag_MODWTMulti}$.
3:    $\mathbf{mode}$Nag_WaveletModeInput
On entry: the end extension method. Note that only periodic end extension is currently available for the MODWT.
${\mathbf{mode}}=\mathrm{Nag_Periodic}$
Periodic end extension.
${\mathbf{mode}}=\mathrm{Nag_HalfPointSymmetric}$
Half-point symmetric end extension.
${\mathbf{mode}}=\mathrm{Nag_WholePointSymmetric}$
Whole-point symmetric end extension.
${\mathbf{mode}}=\mathrm{Nag_ZeroPadded}$
Zero end extension.
Constraints:
• ${\mathbf{mode}}=\mathrm{Nag_Periodic}$, $\mathrm{Nag_HalfPointSymmetric}$, $\mathrm{Nag_WholePointSymmetric}$ or $\mathrm{Nag_ZeroPadded}$ for DWT;
• ${\mathbf{mode}}=\mathrm{Nag_Periodic}$ for MODWT.
4:    $\mathbf{n}$IntegerInput
On entry: the number of elements, $n$, in the input data array, $x$.
Constraint: ${\mathbf{n}}\ge 2$.
5:    $\mathbf{nwlmax}$Integer *Output
On exit: the maximum number of levels of resolution, ${l}_{\mathrm{max}}$, that can be computed when a multi-level discrete wavelet transform is applied. It is such that ${2}^{{l}_{\mathrm{max}}}\le n<{2}^{{l}_{\mathrm{max}}+1}$, for ${l}_{\mathrm{max}}$ an integer.
6:    $\mathbf{nf}$Integer *Output
On exit: the filter length, ${n}_{f}$, for the supplied mother wavelet. This is used to determine the number of coefficients to be generated by the chosen transform.
7:    $\mathbf{nwc}$Integer *Output
On exit: for a single-level transform (${\mathbf{wtrans}}=\mathrm{Nag_SingleLevel}$ or $\mathrm{Nag_MODWTSingle}$), 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 (${\mathbf{wtrans}}=\mathrm{Nag_MultiLevel}$ or $\mathrm{Nag_MODWTMulti}$) the total number of coefficients that would be generated over ${l}_{\mathrm{max}}$ levels and with ${\mathbf{keepa}}=\mathrm{Nag_StoreAll}$ for MODWT.
8:    $\mathbf{icomm}\left[100\right]$IntegerCommunication Array
On exit: contains details of the wavelet transform and the problem dimension which is to be communicated to the one-dimensional discrete discrete transform functions in this chapter.
9:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.2.1.2 in the Essential Introduction for further information.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
On entry, ${\mathbf{wtrans}}=\mathrm{Nag_MODWTSingle}$ or $\mathrm{Nag_MODWTMulti}$ and ${\mathbf{mode}}\ne \mathrm{Nag_Periodic}$.
Constraint: ${\mathbf{mode}}=\mathrm{Nag_Periodic}$ when ${\mathbf{wtrans}}=\mathrm{Nag_MODWTSingle}$ or $\mathrm{Nag_MODWTMulti}$.
NE_INT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 2$.
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 3.6.6 in the Essential Introduction for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 3.6.5 in the Essential Introduction for further information.

Not applicable.

Not applicable.

None.

## 10  Example

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.

### 10.1  Program Text

Program Text (c09aace.c)

### 10.2  Program Data

Program Data (c09aace.d)

### 10.3  Program Results

Program Results (c09aace.r)