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

# NAG Library Routine DocumentC09EYF

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.

## 1  Purpose

C09EYF extracts a selected set of discrete wavelet transform (DWT) coefficients from the full set of coefficients stored in compact form, as computed by C09ECF (two-dimensional DWT).

## 2  Specification

 SUBROUTINE C09EYF ( ILEV, CINDEX, LENC, C, D, LDD, ICOMM, IFAIL)
 INTEGER ILEV, CINDEX, LENC, LDD, ICOMM(180), IFAIL REAL (KIND=nag_wp) C(LENC), D(LDD,*)

## 3  Description

C09EYF is intended to be used after a call to C09ECF (two-dimensional DWT), which in turn should be preceded by a call to C09ABF (two-dimensional wavelet filter initialization). Given an initial two-dimensional data set $A$, a prior call to C09ECF computes the approximation coefficients (at the highest requested level) and three sets of detail coeficients at all levels and stores these in compact form in a one-dimensional array C. C09EYF can then extract either the approximation coefficients or one of the sets of detail coefficients at one of the levels into a matrix $D$. The dimensions of $D$ depend on the level extracted and are available from the arrays DWTLVM and DWTLVN as returned by C09ECF which contain the first and second dimensions respectively. See Section 2.1 in the C09 Chapter Introduction for a discussion of the two-dimensional DWT.
None.

## 5  Parameters

Note: the following notation is used in this section:
• ${n}_{\mathrm{cm}}$ is the number of wavelet coefficients in the first dimension, which, at level ILEV, is equal to ${\mathbf{DWTLVM}}\left({\mathbf{NWL}}-{\mathbf{ILEV}}+1\right)$ as returned by a call to C09ECF transforming NWL levels.
• ${n}_{\mathrm{cn}}$ is the number of wavelet coefficients in the second dimension, which, at level ILEV, is equal to ${\mathbf{DWTLVN}}\left({\mathbf{NWL}}-{\mathbf{ILEV}}+1\right)$ as returned by a call to C09ECF transforming NWL levels.
1:     $\mathrm{ILEV}$ – INTEGERInput
On entry: the level at which coefficients are to be extracted.
Constraints:
• $1\le {\mathbf{ILEV}}\le {\mathbf{NWL}}$, where NWL is as used in a preceding call to C09ECF;
• if ${\mathbf{CINDEX}}=0$, ${\mathbf{ILEV}}={\mathbf{NWL}}$.
2:     $\mathrm{CINDEX}$ – INTEGERInput
On entry: identifies which coefficients to extract. The coefficients are identified as follows:
${\mathbf{CINDEX}}=0$
The approximation coefficients, produced by application of the low pass filter over columns and rows of the original matrix ($\mathrm{LL}$). The approximation coefficients are available only for ${\mathbf{ILEV}}={\mathbf{NWL}}$, where NWL is the value used in a preceding call to C09ECF.
${\mathbf{CINDEX}}=1$
The vertical detail coefficients produced by applying the low pass filter over columns of the original matrix and the high pass filter over rows ($\mathrm{LH}$).
${\mathbf{CINDEX}}=2$
The horizontal detail coefficients produced by applying the high pass filter over columns of the original matrix and the low pass filter over rows ($\mathrm{HL}$).
${\mathbf{CINDEX}}=3$
The diagonal detail coefficients produced by applying the high pass filter over columns and rows of the original matrix ($\mathrm{HH}$).
Constraint: $0\le {\mathbf{CINDEX}}\le 3$ when ${\mathbf{ILEV}}={\mathbf{NWL}}$ as used in C09ECF, otherwise $1\le {\mathbf{CINDEX}}\le 3$.
3:     $\mathrm{LENC}$ – INTEGERInput
On entry: the dimension of the array C as declared in the (sub)program from which C09EYF is called.
Constraint: LENC must be unchanged from the value used in the preceding call to C09ECF..
4:     $\mathrm{C}\left({\mathbf{LENC}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: DWT coefficients, as computed by a preceding call to C09ECF.
5:     $\mathrm{D}\left({\mathbf{LDD}},*\right)$ – REAL (KIND=nag_wp) arrayOutput
Note: the second dimension of the array D must be at least ${n}_{\mathrm{cn}}$.
On exit: the requested coefficients.
If ${\mathbf{ILEV}}={\mathbf{NWL}}$ (as used in C09ECF) and ${\mathbf{CINDEX}}=0$, the ${n}_{\mathit{cm}}$ by ${n}_{\mathit{cn}}$ approximation coefficients ${a}_{ij}$ are stored in ${\mathbf{D}}\left(i,\mathit{j}\right)$, for $\mathit{i}=1,2,\dots ,{n}_{\mathit{cm}}$ and $\mathit{j}=1,2,\dots ,{n}_{\mathit{cn}}$.
Otherwise the ${n}_{\mathit{cm}}$ by ${n}_{\mathit{cn}}$ level ILEV detail coefficients (of type specified by CINDEX) ${d}_{ij}$ are stored in ${\mathbf{D}}\left(i,\mathit{j}\right)$, for $\mathit{i}=1,2,\dots ,{n}_{\mathit{cm}}$ and $\mathit{j}=1,2,\dots ,{n}_{\mathit{cn}}$.
6:     $\mathrm{LDD}$ – INTEGERInput
On entry: the first dimension of the array D as declared in the (sub)program from which C09EYF is called.
Constraint: ${\mathbf{LDD}}\ge {n}_{\mathrm{cm}}$.
7:     $\mathrm{ICOMM}\left(180\right)$ – 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 C09ABF.
8:     $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ 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\text{​ 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 $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
On entry, ${\mathbf{ILEV}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ILEV}}\ge 1$.
On entry, ${\mathbf{ILEV}}=〈\mathit{\text{value}}〉$ and ${\mathbf{NWL}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ILEV}}\le {\mathbf{NWL}}$, where NWL is the number of levels used in the call to C09ECF.
${\mathbf{IFAIL}}=2$
On entry, ${\mathbf{CINDEX}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{CINDEX}}\le 3$.
On entry, ${\mathbf{CINDEX}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{CINDEX}}\ge 0$.
${\mathbf{IFAIL}}=3$
On entry, ${\mathbf{LENC}}=〈\mathit{\text{value}}〉$ and ${n}_{\mathrm{ct}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{LENC}}\ge {n}_{\mathrm{ct}}$, where ${n}_{\mathrm{ct}}$ is the number of DWT coefficients computed in a previous call to C09ECF.
${\mathbf{IFAIL}}=4$
On entry, ${\mathbf{LDD}}=〈\mathit{\text{value}}〉$ and ${n}_{\mathrm{cm}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{LDD}}\ge {n}_{\mathrm{cm}}$, where ${n}_{\mathrm{cm}}$ is the number of DWT coefficients in the first dimension at the selected level ILEV.
${\mathbf{IFAIL}}=5$
On entry, ${\mathbf{ILEV}}=〈\mathit{\text{value}}〉$ and ${\mathbf{NWL}}=〈\mathit{\text{value}}〉$, but ${\mathbf{CINDEX}}=0$.
Constraint: ${\mathbf{CINDEX}}>0$ when ${\mathbf{ILEV}}<{\mathbf{NWL}}$ in the preceding call to C09ECF.
${\mathbf{IFAIL}}=6$
Either the initialization routine has not been called first or ICOMM has been corrupted.
Either the initialization routine was called with ${\mathbf{WTRANS}}=\text{'S'}$ or ICOMM has been corrupted.
${\mathbf{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.
${\mathbf{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.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

Not applicable.

Not applicable.

None.

## 10  Example

See Section 10 in C09ABF, C09ECF and C09EZF.

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