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_sngl_inv (c09cb)

Purpose

nag_wav_1d_sngl_inv (c09cb) computes the inverse one-dimensional discrete wavelet transform (DWT) at a single level. The initialization function nag_wav_1d_init (c09aa) must be called first to set up the DWT options.

Syntax

[y, ifail] = c09cb(ca, cd, n, icomm, 'lenc', lenc)
[y, ifail] = nag_wav_1d_sngl_inv(ca, cd, n, icomm, 'lenc', lenc)

Description

nag_wav_1d_sngl_inv (c09cb) performs the inverse operation of nag_wav_1d_sngl_fwd (c09ca). That is, given sets of ncnc approximation coefficients and detail coefficients, computed by nag_wav_1d_sngl_fwd (c09ca) 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_sngl_inv (c09cb) will reconstruct the data array yiyi, for i = 1,2,,ni=1,2,,n, from which the coefficients were derived.

References

None.

Parameters

Compulsory Input Parameters

1:     ca(lenc) – double array
lenc, the dimension of the array, must satisfy the constraint lencnclencnc, where ncnc is the value returned in nwc by the call to the initialization function nag_wav_1d_init (c09aa).
The ncnc approximation coefficients, CaCa. These will normally be the result of some transformation on the coefficients computed by nag_wav_1d_sngl_fwd (c09ca).
2:     cd(lenc) – double array
lenc, the dimension of the array, must satisfy the constraint lencnclencnc, where ncnc is the value returned in nwc by the call to the initialization function nag_wav_1d_init (c09aa).
The ncnc detail coefficients, CdCd. These will normally be the result of some transformation on the coefficients computed by nag_wav_1d_sngl_fwd (c09ca).
3:     n – int64int32nag_int scalar
nn, the length of the original data array from which the wavelet coefficients were computed by nag_wav_1d_sngl_fwd (c09ca) and the length of the data array y that is to be reconstructed by this function.
Constraint: This must be the same as the value n passed to the initialization function nag_wav_1d_init (c09aa).
4:     icomm(100100) – int64int32nag_int array
Contains details of the discrete wavelet transform and the problem dimension and, possibly, additional information on the previously computed forward transform.

Optional Input Parameters

1:     lenc – int64int32nag_int scalar
Default: The dimension of the arrays ca, cd. (An error is raised if these dimensions are not equal.)
The dimension of the arrays ca and cd as declared in the (sub)program from which nag_wav_1d_sngl_inv (c09cb) is called.
Constraint: lencnclencnc, where ncnc is the value returned in nwc by the call to the initialization function nag_wav_1d_init (c09aa).

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     y(n) – double array
The reconstructed data based on approximation and detail coefficients CaCa and CdCd and the transform 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, lenc < nclenc<nc, where ncnc is the value returned in nwc by the call to the initialization function nag_wav_1d_init (c09aa).
  ifail = 4ifail=4
On entry, n is inconsistent with the value passed to the initialization function nag_wav_1d_init (c09aa).
  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 = 'M'wtrans='M', 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_sngl_inv_example
n = int64(8);
wavnam = 'DB4';
mode = 'zero';
wtrans = 'Single Level';
x = [1; 3; 5; 7; 6; 4; 5; 2];
fprintf('\n Input Data:\n');
fprintf('%8.4f ', x);
fprintf('\n');

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

if ifail == int64(0)
  % Compute the transform
  [ca, cd, icomm, ifail] = nag_wav_1d_sngl_fwd(x, nwc, icomm);

  if ifail == int64(0)
    fprintf(' Approximation coefficients CA :\n');
    fprintf('%8.4f ', ca);
    fprintf('\n');
    fprintf(' Detail coefficients        CD :\n');
    fprintf('%8.4f ', cd);
    fprintf('\n');

    % Reconstruct original data
    [y, ifail] = nag_wav_1d_sngl_inv(ca, cd, n, icomm);

    if ifail == int64(0)
      fprintf(' Reconstruction       Y : \n');
      fprintf('%8.4f ', y);
      fprintf('\n');
    end
  end
end
 

 Input Data:
  1.0000   3.0000   5.0000   7.0000   6.0000   4.0000   5.0000   2.0000 
 Approximation coefficients CA :
  0.0011  -0.0043  -0.0174   4.4778   8.9557   7.3401   2.5816 
 Detail coefficients        CD :
  0.0237   0.0410  -0.5966   1.7763  -0.7517   0.3332  -0.1188 
 Reconstruction       Y : 
  1.0000   3.0000   5.0000   7.0000   6.0000   4.0000   5.0000   2.0000 

function c09cb_example
n = int64(8);
wavnam = 'DB4';
mode = 'zero';
wtrans = 'Single Level';
x = [1; 3; 5; 7; 6; 4; 5; 2];
fprintf('\n Input Data:\n');
fprintf('%8.4f ', x);
fprintf('\n');

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

if ifail == int64(0)
  % Compute the transform
  [ca, cd, icomm, ifail] = c09ca(x, nwc, icomm);

  if ifail == int64(0)
    fprintf(' Approximation coefficients CA :\n');
    fprintf('%8.4f ', ca);
    fprintf('\n');
    fprintf(' Detail coefficients        CD :\n');
    fprintf('%8.4f ', cd);
    fprintf('\n');

    % Reconstruct original data
    [y, ifail] = c09cb(ca, cd, n, icomm);

    if ifail == int64(0)
      fprintf(' Reconstruction       Y : \n');
      fprintf('%8.4f ', y);
      fprintf('\n');
    end
  end
end
 

 Input Data:
  1.0000   3.0000   5.0000   7.0000   6.0000   4.0000   5.0000   2.0000 
 Approximation coefficients CA :
  0.0011  -0.0043  -0.0174   4.4778   8.9557   7.3401   2.5816 
 Detail coefficients        CD :
  0.0237   0.0410  -0.5966   1.7763  -0.7517   0.3332  -0.1188 
 Reconstruction       Y : 
  1.0000   3.0000   5.0000   7.0000   6.0000   4.0000   5.0000   2.0000 


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