hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_wav_1d_multi_inv (c09cd)

Purpose

nag_wav_1d_multi_inv (c09cd) computes the inverse one-dimensional multi-level discrete wavelet transform (DWT). This function reconstructs data from (possibly filtered or otherwise manipulated) wavelet transform coefficients calculated by nag_wav_1d_multi_fwd (c09cc) from an original set of data. The initialization function nag_wav_1d_init (c09aa) must be called first to set up the DWT options.

Syntax

[y, ifail] = c09cd(nwl, c, n, icomm, 'lenc', lenc)
[y, ifail] = nag_wav_1d_multi_inv(nwl, c, n, icomm, 'lenc', lenc)

Description

nag_wav_1d_multi_inv (c09cd) performs the inverse operation of nag_wav_1d_multi_fwd (c09cc). That is, given a set of wavelet coefficients, computed by nag_wav_1d_multi_fwd (c09cc) using a DWT as set up by the initialization function nag_wav_1d_init (c09aa), on a real data array of length nn, nag_wav_1d_multi_inv (c09cd) will reconstruct the data array yiyi, for i = 1,2,,ni=1,2,,n, from which the coefficients were derived. If the original input dataset is level 00, then it is possible to terminate reconstruction at a higher level by specifying fewer than the number of levels used in the call to nag_wav_1d_multi_fwd (c09cc). This results in a partial reconstruction.

References

None.

Parameters

Compulsory Input Parameters

1:     nwl – int64int32nag_int scalar
The number, nlnl, of levels to be used in the inverse multi-level transform. The number of levels must less than or equal to the number used in the computation of the wavelet coefficients.
Constraint: 1nwlnfwd1nwlnfwd, where nfwdnfwd is the value used in a preceding call to nag_wav_1d_multi_fwd (c09cc).
2:     c(lenc) – double array
lenc, the dimension of the array, must satisfy the constraint lencnclencnc, where ncnc is the total number of coefficients that correspond to a transform with nfwdnfwd levels and is unchanged from the preceding call to nag_wav_1d_multi_fwd (c09cc).
The coefficients of a multi-level wavelet transform of the dataset.
Let q(i)q(i) be the number of coefficients (of each type) at level ii, for i = nfwd,nfwd1,,1i=nfwd,nfwd-1,,1. Then, setting k1 = q(nfwd)k1=q(nfwd) and kj + 1 = kj + q(nfwdj + 1)kj+1=kj+q(nfwd-j+1), for j = 1,2,,nfwdj=1,2,,nfwd, the coefficients are stored in c as follows:
c(i)ci, for i = 1,2,,k1i=1,2,,k1
Contains the level nfwdnfwd approximation coefficients, anfwdanfwd.
c(i)ci, for i = k1 + 1,,k2i=k1+1,,k2
Contains the level nfwdnfwd detail coefficients dnfwddnfwd.
c(i)ci, for i = kj + 1,,kj + 1i=kj+1,,kj+1
Contains the level nfwdj + 1nfwd-j+1 detail coefficients, for j = 2,3,,nfwdj=2,3,,nfwd.
The values q(i)q(i), for i = nfwd,nfwd1,,1i=nfwd,nfwd-1,,1, are contained in dwtlev which is produced as output by a preceding call to nag_wav_1d_multi_fwd (c09cc). See nag_wav_1d_multi_fwd (c09cc) for details.
3:     n – int64int32nag_int scalar
nn, the length of the data array, yy, to be reconstructed. For a full reconstruction from nfwdnfwd levels, this is the same as parameter n in the preceding call to nag_wav_1d_multi_fwd (c09cc). For a partial reconstruction of nl < nfwdnl<nfwd levels, this will be equal to dwtlev(nl + 2)dwtlevnl+2 as returned from nag_wav_1d_multi_fwd (c09cc).
4:     icomm(100100) – int64int32nag_int array
Contains details of the discrete wavelet transform and the problem dimension for the forward transform previously computed by nag_wav_1d_multi_fwd (c09cc).

Optional Input Parameters

1:     lenc – int64int32nag_int scalar
Default: The dimension of the array c.
The dimension of the array c as declared in the (sub)program from which nag_wav_1d_multi_inv (c09cd) is called.
Constraint: lencnclencnc, where ncnc is the total number of coefficients that correspond to a transform with nfwdnfwd levels and is unchanged from the preceding call to nag_wav_1d_multi_fwd (c09cc).

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     y(n) – double array
The dataset reconstructed from the multi-level wavelet transform coefficients and the transformation options supplied to the initialization function nag_wav_1d_init (c09aa).
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,nwl < 1nwl<1,
ornwl > nwl> the number of levels used in the computation of the wavelet coefficients by a call to nag_wav_1d_multi_fwd (c09cc).
  ifail = 2ifail=2
On entry, lenc is too small. lenc must be at least the number of wavelet coefficients required for a transform operating on nwl levels. If nwl = lmaxnwl=lmax, the maximum number of levels as returned in nwl by the initial call to nag_wav_1d_init (c09aa), then lenc must be at least ncnc, the value returned in nwc by the same call to nag_wav_1d_init (c09aa).
  ifail = 4ifail=4
On entry, n is too small for the required level of reconstruction.
  ifail = 6ifail=6
On entry, the initialization function nag_wav_1d_init (c09aa) has not been called first or it has been called with wtrans = 'S'wtrans='S', or the communication array icomm has become corrupted.

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.

Further Comments

None.

Example

function nag_wav_1d_multi_inv_example
n = int64(64);
wavnam = 'DB4';
mode = 'zero';
wtrans = 'Multilevel';
x = [ 6.5271; 6.512; 6.5016; 6.5237; 6.4625;
6.3496; 6.4025; 6.4035; 6.4407; 6.4746;
6.5095; 6.6551; 6.61; 6.5969; 6.6083;
6.652; 6.7113; 6.7227; 6.7196; 6.7649;
6.7794; 6.8037; 6.8308; 6.7712; 6.7067;
6.769; 6.7068; 6.7024; 6.6463; 6.6098;
6.59; 6.596; 6.5457; 6.547; 6.5797;
6.5895; 6.6275; 6.6795; 6.6598; 6.6925;
6.6873; 6.7223; 6.7205; 6.6843; 6.703;
6.647; 6.6008; 6.6061; 6.6097; 6.6485;
6.6394; 6.6571; 6.6357; 6.6224; 6.6073;
6.6075; 6.6379; 6.6294; 6.5906; 6.6258;
6.6369; 6.6515; 6.6826; 6.7042];
fprintf('\n Input Data:\n');
for i=1:8:double(n)
  fprintf('%8.4f ', x(i:i+8-1));
  fprintf('\n');
end
fprintf('\n');

% Query wavelet filter dimensions
[nwl, nf, nwc, icomm, ifail] = nag_wav_1d_init(wavnam, wtrans, mode, n);

if ifail == int64(0)
  % Perform Discrete Wavelet transform
  [c, dwtlev, icomm, ifail] = nag_wav_1d_multi_fwd(x, nwc, nwl, icomm);

  if ifail == int64(0)
    fprintf(' Length of wavelet filter :             %10d\n', nf);
    fprintf(' Number of Levels :                     %10d\n\n', nwl);
    fprintf(' Number of coefficients in each level :\n     ');
    fprintf(' %8d', dwtlev);
    fprintf('\n');
    fprintf(' Total number of wavelet coefficients : %10d\n\n', nwc);
    fprintf(' Wavelet coefficients C : \n');
    for i=1:8:double(nwc)
      if i+8-1 <= numel(c)
        fprintf('%8.4f ', c(i:i+8-1));
      else
        fprintf('%8.4f ', c(i:numel(c)));
      end
      fprintf('\n');
    end
    fprintf('\n');

    % Reconstruct original data
    [y, ifail] = nag_wav_1d_multi_inv(nwl, c, n, icomm);

    if ifail == int64(0)
      fprintf('\n Reconstruction       Y : \n');
      for i=1:8:double(n)
        fprintf('%8.4f ', y(i:i+8-1));
        fprintf('\n');
      end
      fprintf('\n');
    end
  end
end
 

 Input Data:
  6.5271   6.5120   6.5016   6.5237   6.4625   6.3496   6.4025   6.4035 
  6.4407   6.4746   6.5095   6.6551   6.6100   6.5969   6.6083   6.6520 
  6.7113   6.7227   6.7196   6.7649   6.7794   6.8037   6.8308   6.7712 
  6.7067   6.7690   6.7068   6.7024   6.6463   6.6098   6.5900   6.5960 
  6.5457   6.5470   6.5797   6.5895   6.6275   6.6795   6.6598   6.6925 
  6.6873   6.7223   6.7205   6.6843   6.7030   6.6470   6.6008   6.6061 
  6.6097   6.6485   6.6394   6.6571   6.6357   6.6224   6.6073   6.6075 
  6.6379   6.6294   6.5906   6.6258   6.6369   6.6515   6.6826   6.7042 

 Length of wavelet filter :                      8
 Number of Levels :                              6

 Number of coefficients in each level :
             7        7        8       10       14       21       35
 Total number of wavelet coefficients :        102

 Wavelet coefficients C : 
  0.0000  -0.0227  -0.3446   2.7574 -10.1970  44.8800  15.9443   0.0010 
 -0.4881 -10.2673  11.3258  -1.7469   2.0785  -0.7334  -0.0054  -0.1402 
 -5.8980  -1.1527   5.5613   2.1352   0.3203  -0.4004   0.0010   0.5229 
  0.5055  -2.7274  -0.0911  -0.2806  -0.3669   2.9467  -0.3799  -0.1552 
  0.0218   0.0922   5.4626  -2.1620   0.5196  -0.0287  -0.0199   0.0920 
 -0.0134  -0.1298  -5.5168   2.3105  -0.5383  -0.0155   0.3057   0.6186 
 -1.5542   0.2682   0.1566   0.0030  -0.0152  -0.0589   0.0126   0.0063 
  0.0171  -0.0268   0.0077  -0.0189   0.0207   0.0104  -0.3207  -0.6062 
  1.6288  -0.2414  -0.0671   3.1657  -1.1462   0.2785   0.0523  -0.0030 
 -0.0270  -0.0442   0.0090   0.0171  -0.0230  -0.0015   0.0213  -0.0402 
 -0.0263  -0.0099   0.0021  -0.0250   0.0210  -0.0028  -0.0298  -0.0095 
  0.0034   0.0281  -0.0188  -0.0002  -0.0173  -0.0076  -0.0014   0.0184 
 -0.0318   0.0048   0.0047  -3.2555   1.1710  -0.2913 


 Reconstruction       Y : 
  6.5271   6.5120   6.5016   6.5237   6.4625   6.3496   6.4025   6.4035 
  6.4407   6.4746   6.5095   6.6551   6.6100   6.5969   6.6083   6.6520 
  6.7113   6.7227   6.7196   6.7649   6.7794   6.8037   6.8308   6.7712 
  6.7067   6.7690   6.7068   6.7024   6.6463   6.6098   6.5900   6.5960 
  6.5457   6.5470   6.5797   6.5895   6.6275   6.6795   6.6598   6.6925 
  6.6873   6.7223   6.7205   6.6843   6.7030   6.6470   6.6008   6.6061 
  6.6097   6.6485   6.6394   6.6571   6.6357   6.6224   6.6073   6.6075 
  6.6379   6.6294   6.5906   6.6258   6.6369   6.6515   6.6826   6.7042 


function c09cd_example
n = int64(64);
wavnam = 'DB4';
mode = 'zero';
wtrans = 'Multilevel';
x = [ 6.5271; 6.512; 6.5016; 6.5237; 6.4625;
6.3496; 6.4025; 6.4035; 6.4407; 6.4746;
6.5095; 6.6551; 6.61; 6.5969; 6.6083;
6.652; 6.7113; 6.7227; 6.7196; 6.7649;
6.7794; 6.8037; 6.8308; 6.7712; 6.7067;
6.769; 6.7068; 6.7024; 6.6463; 6.6098;
6.59; 6.596; 6.5457; 6.547; 6.5797;
6.5895; 6.6275; 6.6795; 6.6598; 6.6925;
6.6873; 6.7223; 6.7205; 6.6843; 6.703;
6.647; 6.6008; 6.6061; 6.6097; 6.6485;
6.6394; 6.6571; 6.6357; 6.6224; 6.6073;
6.6075; 6.6379; 6.6294; 6.5906; 6.6258;
6.6369; 6.6515; 6.6826; 6.7042];
fprintf('\n Input Data:\n');
for i=1:8:double(n)
  fprintf('%8.4f ', x(i:i+8-1));
  fprintf('\n');
end
fprintf('\n');

% Query wavelet filter dimensions
[nwl, nf, nwc, icomm, ifail] = c09aa(wavnam, wtrans, mode, n);

if ifail == int64(0)
  % Perform Discrete Wavelet transform
  [c, dwtlev, icomm, ifail] = c09cc(x, nwc, nwl, icomm);

  if ifail == int64(0)
    fprintf(' Length of wavelet filter :             %10d\n', nf);
    fprintf(' Number of Levels :                     %10d\n\n', nwl);
    fprintf(' Number of coefficients in each level :\n     ');
    fprintf(' %8d', dwtlev);
    fprintf('\n');
    fprintf(' Total number of wavelet coefficients : %10d\n\n', nwc);
    fprintf(' Wavelet coefficients C : \n');
    for i=1:8:double(nwc)
      if i+8-1 <= numel(c)
        fprintf('%8.4f ', c(i:i+8-1));
      else
        fprintf('%8.4f ', c(i:numel(c)));
      end
      fprintf('\n');
    end
    fprintf('\n');

    % Reconstruct original data
    [y, ifail] = c09cd(nwl, c, n, icomm);

    if ifail == int64(0)
      fprintf('\n Reconstruction       Y : \n');
      for i=1:8:double(n)
        fprintf('%8.4f ', y(i:i+8-1));
        fprintf('\n');
      end
      fprintf('\n');
    end
  end
end
 

 Input Data:
  6.5271   6.5120   6.5016   6.5237   6.4625   6.3496   6.4025   6.4035 
  6.4407   6.4746   6.5095   6.6551   6.6100   6.5969   6.6083   6.6520 
  6.7113   6.7227   6.7196   6.7649   6.7794   6.8037   6.8308   6.7712 
  6.7067   6.7690   6.7068   6.7024   6.6463   6.6098   6.5900   6.5960 
  6.5457   6.5470   6.5797   6.5895   6.6275   6.6795   6.6598   6.6925 
  6.6873   6.7223   6.7205   6.6843   6.7030   6.6470   6.6008   6.6061 
  6.6097   6.6485   6.6394   6.6571   6.6357   6.6224   6.6073   6.6075 
  6.6379   6.6294   6.5906   6.6258   6.6369   6.6515   6.6826   6.7042 

 Length of wavelet filter :                      8
 Number of Levels :                              6

 Number of coefficients in each level :
             7        7        8       10       14       21       35
 Total number of wavelet coefficients :        102

 Wavelet coefficients C : 
  0.0000  -0.0227  -0.3446   2.7574 -10.1970  44.8800  15.9443   0.0010 
 -0.4881 -10.2673  11.3258  -1.7469   2.0785  -0.7334  -0.0054  -0.1402 
 -5.8980  -1.1527   5.5613   2.1352   0.3203  -0.4004   0.0010   0.5229 
  0.5055  -2.7274  -0.0911  -0.2806  -0.3669   2.9467  -0.3799  -0.1552 
  0.0218   0.0922   5.4626  -2.1620   0.5196  -0.0287  -0.0199   0.0920 
 -0.0134  -0.1298  -5.5168   2.3105  -0.5383  -0.0155   0.3057   0.6186 
 -1.5542   0.2682   0.1566   0.0030  -0.0152  -0.0589   0.0126   0.0063 
  0.0171  -0.0268   0.0077  -0.0189   0.0207   0.0104  -0.3207  -0.6062 
  1.6288  -0.2414  -0.0671   3.1657  -1.1462   0.2785   0.0523  -0.0030 
 -0.0270  -0.0442   0.0090   0.0171  -0.0230  -0.0015   0.0213  -0.0402 
 -0.0263  -0.0099   0.0021  -0.0250   0.0210  -0.0028  -0.0298  -0.0095 
  0.0034   0.0281  -0.0188  -0.0002  -0.0173  -0.0076  -0.0014   0.0184 
 -0.0318   0.0048   0.0047  -3.2555   1.1710  -0.2913 


 Reconstruction       Y : 
  6.5271   6.5120   6.5016   6.5237   6.4625   6.3496   6.4025   6.4035 
  6.4407   6.4746   6.5095   6.6551   6.6100   6.5969   6.6083   6.6520 
  6.7113   6.7227   6.7196   6.7649   6.7794   6.8037   6.8308   6.7712 
  6.7067   6.7690   6.7068   6.7024   6.6463   6.6098   6.5900   6.5960 
  6.5457   6.5470   6.5797   6.5895   6.6275   6.6795   6.6598   6.6925 
  6.6873   6.7223   6.7205   6.6843   6.7030   6.6470   6.6008   6.6061 
  6.6097   6.6485   6.6394   6.6571   6.6357   6.6224   6.6073   6.6075 
  6.6379   6.6294   6.5906   6.6258   6.6369   6.6515   6.6826   6.7042 



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013