C09 Chapter Contents
C09 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentC09FDF

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

C09FDF computes the inverse three-dimensional multi-level discrete wavelet transform (IDWT). This routine reconstructs data from (possibly filtered or otherwise manipulated) wavelet transform coefficients calculated by C09FCF from an original input array. The initialization routine C09ACF must be called first to set up the IDWT options.

## 2  Specification

 SUBROUTINE C09FDF ( NWL, LENC, C, M, N, FR, B, LDB, SDB, ICOMM, IFAIL)
 INTEGER NWL, LENC, M, N, FR, LDB, SDB, ICOMM(260), IFAIL REAL (KIND=nag_wp) C(LENC), B(LDB,SDB,FR)

## 3  Description

C09FDF performs the inverse operation of C09FCF. That is, given a set of wavelet coefficients, computed by C09FCF using a DWT as set up by the initialization routine C09ACF, on a real three-dimensional array, $A$, C09FDF will reconstruct $A$. The reconstructed array is referred to as $B$ in the following since it will not be identical to $A$ when the DWT coefficients have been filtered or otherwise manipulated prior to reconstruction. If the original input array is level $0$, then it is possible to terminate reconstruction at a higher level by specifying fewer than the number of levels used in the call to C09FCF. This results in a partial reconstruction.

None.

## 5  Parameters

1:     NWL – INTEGERInput
On entry: the number, ${n}_{l}$, of levels to be used in the inverse multi-level transform.
Constraint: $1\le {\mathbf{NWL}}\le {n}_{\mathrm{fwd}}$, where ${n}_{\mathrm{fwd}}$ is the value used in a preceding call to C09FCF.
2:     LENC – INTEGERInput
On entry: the dimension of the array C as declared in the (sub)program from which C09FDF is called.
Constraint: ${\mathbf{LENC}}\ge {n}_{\mathrm{ct}}$, where ${n}_{\mathrm{ct}}$ is the total number of wavelet coefficients that correspond to a transform with NWL levels.
3:     C(LENC) – REAL (KIND=nag_wp) arrayInput
On entry: the coefficients of the multi-level discrete wavelet transform. This will normally be the result of some transformation on the coefficients computed by routine C09FCF.
4:     M – INTEGERInput
On entry: the number of elements, $m$, in the first dimension of the reconstructed array $B$. For a full reconstruction of ${n}_{\mathrm{fwd}}$ levels this must be the same as parameter M used in a preceding call to C09FCF. For reconstruction of ${n}_{l}<{n}_{\mathrm{fwd}}$ levels this must be equal to ${\mathbf{DWTLVM}}\left({n}_{l}+1\right)$ as returned from C09FCF.
5:     N – INTEGERInput
On entry: the number of elements, $n$, in the second dimension of the reconstructed array $B$. For a full reconstruction of ${n}_{\mathrm{fwd}}$ levels this must be the same as parameter N used in a preceding call to C09FCF. For a partial reconstruction of ${n}_{l}<{n}_{\mathrm{fwd}}$ levels this must be equal to ${\mathbf{DWTLVN}}\left({n}_{l}+1\right)$ as returned from C09FCF.
6:     FR – INTEGERInput
On entry: the number of elements, $\mathit{fr}$, in the third dimension of the reconstructed array $B$. For a full reconstruction of ${n}_{\mathrm{fwd}}$ levels this must be the same as parameter FR used in a preceding call to C09FCF. For a partial reconstruction of ${n}_{l}<{n}_{\mathrm{fwd}}$ levels this must be equal to ${\mathbf{DWTLVFR}}\left({n}_{l}+1\right)$ as returned from C09FCF.
7:     B(LDB,SDB,FR) – REAL (KIND=nag_wp) arrayOutput
On exit: the $m$ by $n$ by $\mathit{fr}$ reconstructed array, $B$, based on the input multi-level wavelet transform coefficients and the transform options supplied to the initialization routine C09ACF.
8:     LDB – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which C09FDF is called.
Constraint: ${\mathbf{LDB}}\ge {\mathbf{M}}$.
9:     SDB – INTEGERInput
On entry: the second dimension of the array B as declared in the (sub)program from which C09FDF is called.
Constraint: ${\mathbf{SDB}}\ge {\mathbf{N}}$.
10:   ICOMM($260$) – 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 C09ACF.
11:   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{NWL}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{NWL}}\ge 1$.
On entry, ${\mathbf{NWL}}=⟨\mathit{\text{value}}⟩$ and ${n}_{\mathrm{fwd}}=⟨\mathit{\text{value}}⟩$ where ${n}_{\mathrm{fwd}}$ is the number of levels used in the computation of the wavelet coefficients by a call to C09FCF.
Constraint: ${\mathbf{NWL}}\le {n}_{\mathrm{fwd}}$.
${\mathbf{IFAIL}}=2$
On entry, ${\mathbf{LDB}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{M}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{LDB}}\ge {\mathbf{M}}$.
On entry, ${\mathbf{SDB}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{N}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{SDB}}\ge {\mathbf{N}}$.
${\mathbf{IFAIL}}=3$
On entry, ${\mathbf{LENC}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{LENC}}\ge ⟨\mathit{\text{value}}⟩$, the number of wavelet coefficients required for a transform operating on NWL levels. If ${\mathbf{NWL}}={l}_{\mathrm{max}}$, the maximum number of levels as returned in NWL by the initial call to C09ACF, then LENC must be at least ${n}_{\mathrm{ct}}$, the value returned in NWCT by the same call to C09ACF.
${\mathbf{IFAIL}}=4$
On entry, ${\mathbf{FR}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{FR}}\ge ⟨\mathit{\text{value}}⟩$, the number of coefficients in the third dimension at the required level of reconstruction.
On entry, ${\mathbf{M}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{M}}\ge ⟨\mathit{\text{value}}⟩$, the number of coefficients in the first dimension at the required level of reconstruction.
On entry, ${\mathbf{N}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{N}}\ge ⟨\mathit{\text{value}}⟩$, the number of coefficients in the second dimension at the required level of reconstruction.
${\mathbf{IFAIL}}=6$
Either the initialization routine has not been called first or the communication array ICOMM has been corrupted.
The initialization routine was called with ${\mathbf{WTRANS}}=\text{'S'}$.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.

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