Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_wav_2d_sngl_inv (c09eb)

Purpose

nag_wav_2d_sngl_inv (c09eb) computes the inverse two-dimensional discrete wavelet transform (DWT) at a single level. The initialization function nag_wav_2d_init (c09ab) must be called first to set up the DWT options.

Syntax

[b, ifail] = c09eb(m, n, ca, ch, cv, cd, icomm)
[b, ifail] = nag_wav_2d_sngl_inv(m, n, ca, ch, cv, cd, icomm)

Description

nag_wav_2d_sngl_inv (c09eb) performs the inverse operation of function nag_wav_2d_sngl_fwd (c09ea). That is, given sets of approximation, horizontal, vertical and diagonal coefficients computed by function nag_wav_2d_sngl_fwd (c09ea) using a DWT as set up by the initialization function nag_wav_2d_init (c09ab), on a real matrix, $B$, nag_wav_2d_sngl_inv (c09eb) will reconstruct $B$.

None.

Parameters

Compulsory Input Parameters

1:     $\mathrm{m}$int64int32nag_int scalar
Number of rows, $m$, of data matrix $B$.
Constraint: this must be the same as the value m passed to the initialization function nag_wav_2d_init (c09ab).
2:     $\mathrm{n}$int64int32nag_int scalar
Number of columns, $n$, of data matrix $B$.
Constraint: this must be the same as the value n passed to the initialization function nag_wav_2d_init (c09ab).
3:     $\mathrm{ca}\left(\mathit{ldca},:\right)$ – double array
The first dimension of the array ca must be at least ${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 function nag_wav_2d_init (c09ab).
The second dimension of the array ca must be at least $\mathit{ncn}$ where ${n}_{\mathrm{cn}}$ is the argument nwcn returned by function nag_wav_2d_init (c09ab).
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 function nag_wav_2d_sngl_fwd (c09ea).
4:     $\mathrm{ch}\left(\mathit{ldch},:\right)$ – double array
The first dimension of the array ch must be at least ${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 function nag_wav_2d_init (c09ab).
The second dimension of the array ch must be at least $\mathit{ncn}$ where ${n}_{\mathrm{cn}}$ is the argument nwcn returned by function nag_wav_2d_init (c09ab).
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 function nag_wav_2d_sngl_fwd (c09ea).
5:     $\mathrm{cv}\left(\mathit{ldcv},:\right)$ – double array
The first dimension of the array cv must be at least ${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 function nag_wav_2d_init (c09ab).
The second dimension of the array cv must be at least $\mathit{ncn}$ where ${n}_{\mathrm{cn}}$ is the argument nwcn returned by function nag_wav_2d_init (c09ab).
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 function nag_wav_2d_sngl_fwd (c09ea).
6:     $\mathrm{cd}\left(\mathit{ldcd},:\right)$ – double array
The first dimension of the array cd must be at least ${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 function nag_wav_2d_init (c09ab).
The second dimension of the array cd must be at least $\mathit{ncn}$ where ${n}_{\mathrm{cn}}$ is the argument nwcn returned by function nag_wav_2d_init (c09ab).
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 function nag_wav_2d_sngl_fwd (c09ea).
7:     $\mathrm{icomm}\left(180\right)$int64int32nag_int array
Contains details of the discrete wavelet transform and the problem dimension as setup in the call to the initialization function nag_wav_2d_init (c09ab).

None.

Output Parameters

1:     $\mathrm{b}\left(\mathit{ldb},{\mathbf{n}}\right)$ – double array
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 function nag_wav_2d_init (c09ab).
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
${\mathbf{ifail}}=1$
ldca is too small, the number of wavelet coefficients in the first dimension.
ldcd is too small, the number of wavelet coefficients in the first dimension.
ldch is too small, the number of wavelet coefficients in the first dimension.
ldcv is too small, the number of wavelet coefficients in the first dimension.
${\mathbf{ifail}}=2$
Constraint: $\mathit{ldb}\ge {\mathbf{m}}$.
${\mathbf{ifail}}=4$
Constraint: ${\mathbf{m}}=_$, the value of m on initialization (see nag_wav_2d_init (c09ab)).
Constraint: ${\mathbf{n}}=_$, the value of n on initialization (see nag_wav_2d_init (c09ab)).
${\mathbf{ifail}}=6$
Either the initialization function has not been called first or icomm has been corrupted.
Either the initialization function was called with ${\mathbf{wtrans}}=\text{'M'}$ or icomm has been corrupted.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

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.

None.

Example

See Example in nag_wav_2d_sngl_fwd (c09ea).
```function c09eb_example

fprintf('c09eb example results\n\n');

m = int64(6);
n = int64(6);
wavnam = 'DB4';
mode = 'Half';
wtrans = 'Single level';
a = [8, 7, 3, 3, 1, 1;
4, 6, 1, 5, 2, 9;
8, 1, 4, 9, 3, 7;
9, 3, 8, 2, 4, 3;
1, 3, 7, 1, 5, 2;
4, 3, 7, 7, 6, 1];

fprintf('\nInput data a:\n');
disp(a);
[nwl, nf, nwct, nwcn, icomm, ifail] = c09ab(wavnam, wtrans, mode, m, n);

nwcm = double(nwct)/(4*double(nwcn));

% Perform Discrete Wavelet transform
[ca, ch, cv, cd, ifail] = c09ea(a, icomm);

fprintf('Approximation coefficients    CA:\n');
disp(ca);
fprintf('Diagonal coefficients         CD:\n');
disp(cd);
fprintf('Horizontal coefficients       CH:\n');
disp(ch);
fprintf('Vertical coefficients         CV:\n');
disp(cv);

% Reconstruct original data
[b, ifail] = c09eb(m, n, ca, ch, cv, cd, icomm);
fprintf('Reconstruction       b:\n');
disp(b);

```
```c09eb example results

Input data a:
8     7     3     3     1     1
4     6     1     5     2     9
8     1     4     9     3     7
9     3     8     2     4     3
1     3     7     1     5     2
4     3     7     7     6     1

Approximation coefficients    CA:
6.3591   10.3477    8.0995   10.3210    8.7587    3.5783
11.5754    6.3762   12.1704    7.4521    8.6977   14.8535
2.0630    8.4499   15.4726   12.1764    3.8920    2.7112
10.2143    6.2445   13.8571    8.1060    7.7701   13.2127
6.3353    8.7805   10.2727   10.0472    6.8614    7.5814
11.7141   11.1018    5.2923    8.1272   14.5540    2.5729

Diagonal coefficients         CD:
0.4777    1.0230   -0.3147    0.0625    0.0831   -1.3316
1.0689    1.5671   -2.1422    0.5565    1.7593   -2.8097
-0.9555   -1.9276    0.9195   -0.2228   -0.5125    2.6989
0.2899    0.4453   -0.5695    0.1541    0.4749   -0.7946
0.4944    1.4145    0.3488   -0.1187   -0.6212   -1.5177
-1.3753   -2.5224    1.7581   -0.4316   -1.1835    3.7547

Horizontal coefficients       CH:
0.4100   -0.1827    1.5354    0.0784    0.8101   -1.3594
2.3496   -0.9422    2.3780   -1.0540    2.7743   -2.2648
-1.2690    0.0152   -6.9338   -1.7435   -1.6917    1.2388
0.6317   -0.0969    2.3300    0.4637    0.6365   -0.1162
-0.2343    0.3923    5.5457    2.1818    0.2103   -0.8573
-1.8880    0.8142   -4.8552    0.0736   -2.7395    3.3590

Vertical coefficients         CV:
1.5365    5.9678    3.4309   -1.0585   -5.0275   -4.8492
0.6779   -0.0294   -5.3274    1.6483    4.8689   -1.8383
-1.1065   -2.8791    0.1535    0.0982    0.8417    2.8923
-0.1359   -2.6633   -5.8549    1.8440    6.2403    0.5697
1.4244    5.2140    1.6410   -0.4669   -3.2369   -4.5757
1.0288    2.2521    0.0574   -0.1359   -0.5170   -2.6854

Reconstruction       b:
8.0000    7.0000    3.0000    3.0000    1.0000    1.0000
4.0000    6.0000    1.0000    5.0000    2.0000    9.0000
8.0000    1.0000    4.0000    9.0000    3.0000    7.0000
9.0000    3.0000    8.0000    2.0000    4.0000    3.0000
1.0000    3.0000    7.0000    1.0000    5.0000    2.0000
4.0000    3.0000    7.0000    7.0000    6.0000    1.0000

```