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_init (c09aa)

Purpose

nag_wav_1d_init (c09aa) returns the details of the chosen one-dimensional discrete wavelet filter. For a chosen mother wavelet, discrete wavelet transform type (single-level or multi-level DWT) and end extension method, this function returns the maximum number of levels of resolution (appropriate to a multi-level transform), the filter length, and the number of approximation coefficients (equal to the number of detail coefficients) for a single-level DWT or the total number of coefficients for a multi-level DWT. This function must be called before any of the one-dimensional discrete transform functions in this chapter.

Syntax

[nwl, nf, nwc, icomm, ifail] = c09aa(wavnam, wtrans, mode, n)
[nwl, nf, nwc, icomm, ifail] = nag_wav_1d_init(wavnam, wtrans, mode, n)

Description

One-dimensional discrete wavelet transforms (DWT) are characterised by the mother wavelet, the end extension method and whether multiresolution analysis is to be performed. For the selected combination of choices for these three characteristics, and for a given length, nn, of the input data array, xx, nag_wav_1d_init (c09aa) returns the dimension details for the transform determined by this combination. The dimension details are: lmaxlmax, the maximum number of levels of resolution that that could be computed were a multi-level DWT applied; nfnf, the filter length; ncnc the number of approximation (or detail) coefficients for a single-level DWT or the total number of coefficients generated by a multi-level DWT over lmaxlmax levels. These values are also stored in the communication array icomm, as are the input choices, so that they may be conveniently communicated to the one-dimensional transform functions in this chapter.

References

None.

Parameters

Compulsory Input Parameters

1:     wavnam – string
The name of the mother wavelet. See the C09 Chapter Introduction for details.
wavnam = 'HAAR'wavnam='HAAR'
Haar wavelet.
wavnam = 'DBn'wavnam='DBn', where n = 2,3,,10n=2,3,,10
Daubechies wavelet with nn vanishing moments (2n2n coefficients). For example, wavnam = 'DB4'wavnam='DB4' is the name for the Daubechies wavelet with 44 vanishing moments (88 coefficients).
wavnam = 'BIORxwavnam='BIORx.y'y', where xx.yy can be one of 1.1, 1.3, 1.5, 2.2, 2.4, 2.6, 2.8, 3.1, 3.3, 3.5 or 3.7
Biorthogonal wavelet of order xx.yy. For example wavnam = 'BIOR3.1'wavnam='BIOR3.1' is the name for the biorthogonal wavelet of order 3.13.1.
Constraint: wavnam = 'HAAR'wavnam='HAAR', 'DB2''DB2', 'DB3''DB3', 'DB4''DB4', 'DB5''DB5', 'DB6''DB6', 'DB7''DB7', 'DB8''DB8', 'DB9''DB9', 'DB10''DB10', 'BIOR1.1''BIOR1.1', 'BIOR1.3''BIOR1.3', 'BIOR1.5''BIOR1.5', 'BIOR2.2''BIOR2.2', 'BIOR2.4''BIOR2.4', 'BIOR2.6''BIOR2.6', 'BIOR2.8''BIOR2.8', 'BIOR3.1''BIOR3.1', 'BIOR3.3''BIOR3.3', 'BIOR3.5''BIOR3.5' or 'BIOR3.7''BIOR3.7'.
2:     wtrans – string (length ≥ 1)
The type of discrete wavelet transform that is to be applied.
wtrans = 'S'wtrans='S'
Single-level decomposition or reconstruction by discrete wavelet transform.
wtrans = 'M'wtrans='M'
Multiresolution, by a multi-level DWT or its inverse.
Constraint: wtrans = 'S'wtrans='S' or 'M''M'.
3:     mode – string (length ≥ 1)
The end extension method.
mode = 'P'mode='P'
Periodic end extension.
mode = 'H'mode='H'
Half-point symmetric end extension.
mode = 'W'mode='W'
Whole-point symmetric end extension.
mode = 'Z'mode='Z'
Zero end extension.
Constraint: mode = 'P'mode='P', 'H''H', 'W''W' or 'Z''Z'.
4:     n – int64int32nag_int scalar
The number of elements, nn, in the input data array, xx.
Constraint: n2n2.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     nwl – int64int32nag_int scalar
The maximum number of levels of resolution, lmaxlmax, that can be computed when a multi-level discrete wavelet transform is applied. It is such that 2lmaxn < 2lmax + 12lmaxn<2lmax+1, for lmaxlmax an integer.
2:     nf – int64int32nag_int scalar
The filter length, nfnf, for the supplied mother wavelet. This is used to determine the number of coefficients to be generated by the chosen transform.
3:     nwc – int64int32nag_int scalar
For a single-level transform (wtrans = 'S'wtrans='S'), the number of approximation coefficients that would be generated for the given problem size, mother wavelet, extension method and type of transform; this is also the corresponding number of detail coefficients. For a multi-level transform (wtrans = 'M'wtrans='M') the total number of coefficients that would be generated over lmaxlmax levels.
4:     icomm(100100) – int64int32nag_int array
Contains details of the wavelet transform and the problem dimension which is to be communicated to the one-dimensional discrete discrete transform functions in this chapter.
5:     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,wavnam = 'HAAR'wavnam='HAAR', 'DB2''DB2', 'DB3''DB3', 'DB4''DB4', 'DB5''DB5', 'DB6''DB6', 'DB7''DB7', 'DB8''DB8', 'DB9''DB9', 'DB10''DB10', 'BIOR1.1''BIOR1.1', 'BIOR1.3''BIOR1.3', 'BIOR1.5''BIOR1.5', 'BIOR2.2''BIOR2.2', 'BIOR2.4''BIOR2.4', 'BIOR2.6''BIOR2.6', 'BIOR2.8''BIOR2.8', 'BIOR3.1''BIOR3.1', 'BIOR3.3''BIOR3.3', 'BIOR3.5''BIOR3.5' or 'BIOR3.7''BIOR3.7'.
  ifail = 2ifail=2
On entry,wtrans = 'S'wtrans='S' or 'M''M'.
  ifail = 3ifail=3
On entry,mode = 'P'mode='P', 'H''H', 'W''W' or 'Z''Z'.
  ifail = 4ifail=4
On entry,n < 2n<2.

Accuracy

Not applicable.

Further Comments

None.

Example

function nag_wav_1d_init_example
n = int64(8);
wavnam = 'Haar';
mode = 'zero';
wtrans = 'Multilevel';
x = [2; 5; 8; 9; 7; 4; -1; 1];

fprintf('\n Input Data:\n');
fprintf('%8.3f', x);
fprintf('\n\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');
    fprintf(' %8.3f', c);
    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');
      fprintf(' %8.3f', y);
      fprintf('\n');
    end
  end
end
 

 Input Data:
   2.000   5.000   8.000   9.000   7.000   4.000  -1.000   1.000

 Length of wavelet filter :                      2
 Number of Levels :                              3

 Number of coefficients in each level :
                      1        1        2        4
 Total number of wavelet coefficients :          8

 Wavelet coefficients C : 
   12.374    4.596   -5.000    5.500   -2.121   -0.707    2.121   -1.414

 Reconstruction       Y : 
    2.000    5.000    8.000    9.000    7.000    4.000   -1.000    1.000

function c09aa_example
n = int64(8);
wavnam = 'Haar';
mode = 'zero';
wtrans = 'Multilevel';
x = [2; 5; 8; 9; 7; 4; -1; 1];

fprintf('\n Input Data:\n');
fprintf('%8.3f', x);
fprintf('\n\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');
    fprintf(' %8.3f', c);
    fprintf('\n');

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

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

 Input Data:
   2.000   5.000   8.000   9.000   7.000   4.000  -1.000   1.000

 Length of wavelet filter :                      2
 Number of Levels :                              3

 Number of coefficients in each level :
                      1        1        2        4
 Total number of wavelet coefficients :          8

 Wavelet coefficients C : 
   12.374    4.596   -5.000    5.500   -2.121   -0.707    2.121   -1.414

 Reconstruction       Y : 
    2.000    5.000    8.000    9.000    7.000    4.000   -1.000    1.000


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