# NAG Library Routine Document

## 1Purpose

c09ebf computes the inverse two-dimensional discrete wavelet transform (DWT) at a single level. The initialization routine c09abf must be called first to set up the DWT options.

## 2Specification

Fortran Interface
 Subroutine c09ebf ( m, n, ca, ldca, ch, ldch, cv, ldcv, cd, ldcd, b, ldb,
 Integer, Intent (In) :: m, n, ldca, ldch, ldcv, ldcd, ldb, icomm(180) Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: ca(ldca,*), ch(ldch,*), cv(ldcv,*), cd(ldcd,*) Real (Kind=nag_wp), Intent (Inout) :: b(ldb,n)
#include nagmk26.h
 void c09ebf_ (const Integer *m, const Integer *n, const double ca[], const Integer *ldca, const double ch[], const Integer *ldch, const double cv[], const Integer *ldcv, const double cd[], const Integer *ldcd, double b[], const Integer *ldb, const Integer icomm[], Integer *ifail)

## 3Description

c09ebf performs the inverse operation of routine c09eaf. That is, given sets of approximation, horizontal, vertical and diagonal coefficients computed by routine c09eaf using a DWT as set up by the initialization routine c09abf, on a real matrix, $B$, c09ebf will reconstruct $B$.

None.

## 5Arguments

1:     $\mathbf{m}$ – IntegerInput
On entry: number of rows, $m$, of data matrix $B$.
Constraint: this must be the same as the value m passed to the initialization routine c09abf.
2:     $\mathbf{n}$ – IntegerInput
On entry: number of columns, $n$, of data matrix $B$.
Constraint: this must be the same as the value n passed to the initialization routine c09abf.
3:     $\mathbf{ca}\left({\mathbf{ldca}},*\right)$ – Real (Kind=nag_wp) arrayInput
Note: the second dimension of the array ca must be at least ${n}_{\mathrm{cn}}$ where ${n}_{\mathrm{cn}}$ is the argument nwcn returned by routine c09abf.
On entry: contains the ${n}_{\mathrm{cm}}$ by ${n}_{\mathrm{cn}}$ matrix of approximation coefficients, ${C}_{a}$. This array will normally be the result of some transformation on the coefficients computed by routine c09eaf.
4:     $\mathbf{ldca}$ – IntegerInput
On entry: the first dimension of the array ca as declared in the (sub)program from which c09ebf is called.
Constraint: ${\mathbf{ldca}}\ge {n}_{\mathrm{cm}}$ where ${n}_{\mathrm{cm}}={n}_{\mathrm{ct}}/\left(4{n}_{\mathrm{cn}}\right)$ and ${n}_{\mathrm{cn}}$, ${n}_{\mathrm{ct}}$ are returned by the initialization routine c09abf.
5:     $\mathbf{ch}\left({\mathbf{ldch}},*\right)$ – Real (Kind=nag_wp) arrayInput
Note: the second dimension of the array ch must be at least ${n}_{\mathrm{cn}}$ where ${n}_{\mathrm{cn}}$ is the argument nwcn returned by routine c09abf.
On entry: contains the ${n}_{\mathrm{cm}}$ by ${n}_{\mathrm{cn}}$ matrix of horizontal coefficients, ${C}_{h}$. This array will normally be the result of some transformation on the coefficients computed by routine c09eaf.
6:     $\mathbf{ldch}$ – IntegerInput
On entry: the first dimension of the array ch as declared in the (sub)program from which c09ebf is called.
Constraint: ${\mathbf{ldch}}\ge {n}_{\mathrm{cm}}$ where ${n}_{\mathrm{cm}}={n}_{\mathrm{ct}}/\left(4{n}_{\mathrm{cn}}\right)$ and ${n}_{\mathrm{cn}}$, ${n}_{\mathrm{ct}}$ are returned by the initialization routine c09abf.
7:     $\mathbf{cv}\left({\mathbf{ldcv}},*\right)$ – Real (Kind=nag_wp) arrayInput
Note: the second dimension of the array cv must be at least ${n}_{\mathrm{cn}}$ where ${n}_{\mathrm{cn}}$ is the argument nwcn returned by routine c09abf.
On entry: contains the ${n}_{\mathrm{cm}}$ by ${n}_{\mathrm{cn}}$ matrix of vertical coefficients, ${C}_{v}$. This array will normally be the result of some transformation on the coefficients computed by routine c09eaf.
8:     $\mathbf{ldcv}$ – IntegerInput
On entry: the first dimension of the array cv as declared in the (sub)program from which c09ebf is called.
Constraint: ${\mathbf{ldcv}}\ge {n}_{\mathrm{cm}}$ where ${n}_{\mathrm{cm}}={n}_{\mathrm{ct}}/\left(4{n}_{\mathrm{cn}}\right)$ and ${n}_{\mathrm{cn}}$, ${n}_{\mathrm{ct}}$ are returned by the initialization routine c09abf.
9:     $\mathbf{cd}\left({\mathbf{ldcd}},*\right)$ – Real (Kind=nag_wp) arrayInput
Note: the second dimension of the array cd must be at least ${n}_{\mathrm{cn}}$ where ${n}_{\mathrm{cn}}$ is the argument nwcn returned by routine c09abf.
On entry: contains the ${n}_{\mathrm{cm}}$ by ${n}_{\mathrm{cn}}$ matrix of diagonal coefficients, ${C}_{d}$. This array will normally be the result of some transformation on the coefficients computed by routine c09eaf.
10:   $\mathbf{ldcd}$ – IntegerInput
On entry: the first dimension of the array cd as declared in the (sub)program from which c09ebf is called.
Constraint: ${\mathbf{ldcd}}\ge {n}_{\mathrm{cm}}$ where ${n}_{\mathrm{cm}}={n}_{\mathrm{ct}}/\left(4{n}_{\mathrm{cn}}\right)$ and ${n}_{\mathrm{cn}}$, ${n}_{\mathrm{ct}}$ are returned by the initialization routine c09abf.
11:   $\mathbf{b}\left({\mathbf{ldb}},{\mathbf{n}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: the $m$ by $n$ reconstructed matrix, $B$, based on the input approximation, horizontal, vertical and diagonal coefficients and the transform options supplied to the initialization routine c09abf.
12:   $\mathbf{ldb}$ – IntegerInput
On entry: the first dimension of the array b as declared in the (sub)program from which c09ebf is called.
Constraint: ${\mathbf{ldb}}\ge {\mathbf{m}}$.
13:   $\mathbf{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.
14:   $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $-1\text{​ 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\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 argument, 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{ldca}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ldca}}\ge 〈\mathit{\text{value}}〉$, the number of wavelet coefficients in the first dimension.
On entry, ${\mathbf{ldcd}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ldcd}}\ge 〈\mathit{\text{value}}〉$, the number of wavelet coefficients in the first dimension.
On entry, ${\mathbf{ldch}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ldch}}\ge 〈\mathit{\text{value}}〉$, the number of wavelet coefficients in the first dimension.
On entry, ${\mathbf{ldcv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ldcv}}\ge 〈\mathit{\text{value}}〉$, the number of wavelet coefficients in the first dimension.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{ldb}}=〈\mathit{\text{value}}〉$ and ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ldb}}\ge {\mathbf{m}}$.
${\mathbf{ifail}}=4$
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}=〈\mathit{\text{value}}〉$, the value of m on initialization (see c09abf).
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}=〈\mathit{\text{value}}〉$, the value of n on initialization (see c09abf).
${\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{'M'}$ or icomm has been corrupted.
${\mathbf{ifail}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{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.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

## 7Accuracy

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.

## 8Parallelism and Performance

c09ebf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.