C09BAF (PDF version)
C09 Chapter Contents
C09 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

C09BAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

C09BAF computes the real, continuous wavelet transform in one dimension.

2  Specification

SUBROUTINE C09BAF ( WAVNAM, WPARAM, N, X, NSCAL, SCALES, C, IFAIL)
INTEGER  WPARAM, N, NSCAL, SCALES(NSCAL), IFAIL
REAL (KIND=nag_wp)  X(N), C(NSCAL,N)
CHARACTER(*)  WAVNAM

3  Description

C09BAF 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 routine 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 ,  
where
α = 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 .

4  References

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

5  Parameters

1:     WAVNAM – CHARACTER(*)Input
On entry: the name of the mother wavelet. See the C09 Chapter Introduction for details.
WAVNAM='MORLET'
Morlet wavelet.
WAVNAM='DGAUSS'
Derivative of a Gaussian wavelet.
WAVNAM='MEXHAT'
Mexican hat wavelet.
Constraint: WAVNAM='MORLET', 'DGAUSS' or 'MEXHAT'.
2:     WPARAM – INTEGERInput
On entry: 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'.
Constraints:
  • if WAVNAM='MORLET', 5WPARAM20;
  • if WAVNAM='DGAUSS', 1WPARAM8.
3:     N – INTEGERInput
On entry: the size, n, of the input dataset x.
Constraint: N2.
4:     XN – REAL (KIND=nag_wp) arrayInput
On entry: X contains the input dataset Xj=xj, for j=1,2,,n.
5:     NSCAL – INTEGERInput
On entry: the dimension of the array SCALES and the first dimension of the array C as declared in the (sub)program from which C09BAF is called. The number of scales to be computed.
Constraint: NSCAL1.
6:     SCALESNSCAL – INTEGER arrayInput
On entry: the scales at which the transform is to be computed.
Constraint: SCALESi1, for i=1,2,,NSCAL.
7:     CNSCALN – REAL (KIND=nag_wp) arrayOutput
On exit: the transform coefficients at the requested scales, where Cij is the transform coefficient Ci,j at scale i and position j.
8:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry, WAVNAM=value was an illegal value.
IFAIL=2
On entry, WAVNAM='MORLET' and WPARAM=value.
Constraint: if WAVNAM='MORLET', 5WPARAM20.
On entry, WAVNAM='DGAUSS' and WPARAM=value.
Constraint: if WAVNAM='DGAUSS', 1WPARAM8.
IFAIL=3
On entry, N=value.
Constraint: N2.
IFAIL=5
On entry, NSCAL=value.
Constraint: NSCAL1.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

The accuracy of C09BAF 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.

8  Parallelism and Performance

Not applicable.

9  Further Comments

Workspace is internally allocated by C09BAF. The total size of these arrays is 213 + N + nk - 1  real elements and nk integer elements, where nk = k × maxSCALESi  and k=17 when WAVNAM='MORLET' or 'DGAUSS' and k=11 when WAVNAM='MEXHAT'.

10  Example

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.

10.1  Program Text

Program Text (c09bafe.f90)

10.2  Program Data

Program Data (c09bafe.d)

10.3  Program Results

Program Results (c09bafe.r)


C09BAF (PDF version)
C09 Chapter Contents
C09 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015