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_cont (c09ba)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


nag_wav_1d_cont (c09ba) computes the real, continuous wavelet transform in one dimension.


[c, ifail] = c09ba(wavnam, wparam, x, scales, 'n', n, 'nscal', nscal)
[c, ifail] = nag_wav_1d_cont(wavnam, wparam, x, scales, 'n', n, 'nscal', nscal)


nag_wav_1d_cont (c09ba) computes the real part of the one-dimensional, continuous wavelet transform
Cs,k = xt 1 s ψ* t-k s dt ,  
of a signal xt at scale s and position k, where the signal is sampled discretely at n equidistant points xi, for i=1,2,,n. ψ is the wavelet function, which can be chosen to be the Morlet wavelet, the derivatives of a Gaussian or the Mexican hat wavelet (* denotes the complex conjugate). The integrals of the scaled, shifted wavelet function are approximated and the convolution is then computed.
The mother wavelets supplied for use with this function are defined as follows.
1. The Morlet wavelet (real part) with nondimensional wave number κ is
ψx = 1 π 1/4 cosκx - e -κ2/2 e -x2/2 ,  
where the correction term, e-κ2/2 (required to satisfy the admissibility condition) is included.
2. The derivatives of a Gaussian are obtained from
ψ^m x = dm e -x2 d xm ,  
taking m=1,,8. These are the Hermite polynomials multiplied by the Gaussian. The sign is then adjusted to give ψ^m0>0 when m is even while the sign of the succeeding odd derivative, ψ^m+1, is made consistent with the preceding even numbered derivative. They are normalized by the L2-norm,
pm = - ψ^ m x 2 d x 1/2  
The resulting normalized derivatives can be written in terms of the Hermite polynomials, Hmx, as
ψ m x = α Hmx e -x2 pm ,  
α = 1, when ​m=0,3 mod 4; -1, when ​m=1,2 mod 4.  
Thus, the derivatives of a Gaussian provided here are,
ψ1 x = - 2π 1/4 2 x e -x2 ,  
ψ2 x = - 2π 1/4 1 3 4x2 - 2 e -x2 ,  
ψ3 x = 2π 1/4 115 8x3 - 12x e -x2 ,  
ψ4 x = 2π 1/4 1105 16x4 - 48x2 + 12 e -x2 ,  
ψ5 x = - 2π 1/4 1 3105 32x5 - 160x3 + 120x e -x2 ,  
ψ6 x = - 2π 1/4 1 31155 64x6 - 480x4 + 720x2 - 120 e -x2 ,  
ψ7 x = 2π 1/4 1 315015 128x7 - 1344x5 + 3360x3 - 1680x e -x2 ,  
ψ8 x = 2π 1/4 1 451001 256x8 - 3584x6 + 13440x4 - 13440x2 + 1680 e -x2 .  
3. The second derivative of a Gaussian is known as the Mexican hat wavelet and is supplied as an additional function in the form
ψx = 2 3 π1/4 1-x2 e -x2/2 .  
The remaining normalized derivatives of a Gaussian can be expressed as multiples of the exponential e - t2 / 2  by applying the substitution x = t / 2  followed by multiplication with the scaling factor, 1 / 24 .


Daubechies I (1992) Ten Lectures on Wavelets SIAM, Philadelphia


Compulsory Input Parameters

1:     wavnam – string
The name of the mother wavelet. See the C09 Chapter Introduction for details.
Morlet wavelet.
Derivative of a Gaussian wavelet.
Mexican hat wavelet.
Constraint: wavnam='MORLET', 'DGAUSS' or 'MEXHAT'.
2:     wparam int64int32nag_int scalar
The nondimensional wave number for the Morlet wavelet or the order of the derivative for the Gaussian wavelet. It is not referenced when wavnam='MEXHAT'.
  • if wavnam='MORLET', 5wparam20;
  • if wavnam='DGAUSS', 1wparam8.
3:     xn – double array
x contains the input dataset xj=xj, for j=1,2,,n.
4:     scalesnscal int64int32nag_int array
The scales at which the transform is to be computed.
Constraint: scalesi1, for i=1,2,,nscal.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the dimension of the array x.
The size, n, of the input dataset x.
Constraint: n2.
2:     nscal int64int32nag_int scalar
Default: the dimension of the array scales.
The dimension of the array scales and the first dimension of the array c. the number of scales to be computed.
Constraint: nscal1.

Output Parameters

1:     cnscaln – double array
The transform coefficients at the requested scales, where cij is the transform coefficient Ci,j at scale i and position j.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
On entry, wavnam=_ was an illegal value.
Constraint: if wavnam='DGAUSS', 1wparam8.
Constraint: if wavnam='MORLET', 5wparam20.
Constraint: n2.
Constraint: nscal1.
An unexpected error has been triggered by this routine. Please contact NAG.
Your licence key may have expired or may not have been installed correctly.
Dynamic memory allocation failed.


The accuracy of nag_wav_1d_cont (c09ba) is determined by the fact that the convolution must be computed as a discrete approximation to the continuous form. The input signal, x, is taken to be piecewise constant using the supplied discrete values.

Further Comments

Workspace is internally allocated by nag_wav_1d_cont (c09ba). The total size of these arrays is 213 + n + nk - 1  double elements and nk integer elements, where nk = k × maxscalesi  and k=17 when wavnam='MORLET' or 'DGAUSS' and k=11 when wavnam='MEXHAT'.


This example computes the continuous wavelet transform of a dataset containing a single nonzero value representing an impulse. The Morlet wavelet is used with wave number κ=5 and scales 1, 2, 3, 4.
function c09ba_example

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

wavnam = 'Morlet';
wparam = int64(5);
scales = [int64(1), 2, 3, 4];
x = zeros(10,1);
x(5) = 1;

[c, ifail] = c09ba(wavnam, wparam, x, scales);
fprintf('\nNumber of Scales : 4\n');
fprintf('Wavelet coefficients c :\n');
fprintf('Scale:    %d           %d            %d            %d\n', scales);
for j = 1:10
  fprintf('    %11.4e  %11.4e  %11.4e  %11.4e\n', c(:,j));

c09ba example results

Number of Scales : 4
Wavelet coefficients c :
Scale:    1           2            3            4
    -1.7651e-05   1.5012e-04   5.2331e-02   1.4454e-01
    -1.3643e-03  -5.8141e-02   1.7057e-01  -8.4364e-02
     4.6511e-03   1.8442e-01  -1.4891e-01  -2.8870e-01
     8.9294e-02  -2.6380e-01  -2.6822e-01  -9.4993e-02
    -9.2563e-02   1.3289e-01   2.5680e-01   2.8293e-01
    -9.2563e-02   1.3289e-01   2.5680e-01   2.8293e-01
     8.9294e-02  -2.6380e-01  -2.6822e-01  -9.4993e-02
     4.6511e-03   1.8442e-01  -1.4891e-01  -2.8870e-01
    -1.3643e-03  -5.8141e-02   1.7057e-01  -8.4364e-02
    -1.7651e-05   1.5012e-04   5.2331e-02   1.4454e-01

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–2015