NAG CL Interface
c09bac (dim1_​cont)

Settings help

CL Name Style:


1 Purpose

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

2 Specification

#include <nag.h>
void  c09bac (Nag_Wavelet wavnam, Integer wparam, Integer n, const double x[], Integer nscal, const Integer scales[], double c[], NagError *fail)
The function may be called by the names: c09bac, nag_wav_dim1_cont or nag_cwt_1d_real.

3 Description

c09bac computes the real part of the one-dimensional, continuous wavelet transform
Cs,k = x(t) 1 s ψ* ( t-k s ) dt ,  
of a signal x(t) 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. 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. 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 ψ^(m)(0)>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 dx) 1/2  
    The resulting normalized derivatives can be written in terms of the Hermite polynomials, Hm(x), as
    ψ (m) (x) = α Hm(x) 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. 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 Arguments

1: wavnam Nag_Wavelet Input
On entry: the name of the mother wavelet. See the C09 Chapter Introduction for details.
wavnam=Nag_Morlet
Morlet wavelet.
wavnam=Nag_DGauss
Derivative of a Gaussian wavelet.
wavnam=Nag_MexHat
Mexican hat wavelet.
Constraint: wavnam=Nag_Morlet, Nag_DGauss or Nag_MexHat.
2: wparam Integer Input
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=Nag_MexHat.
Constraints:
  • if wavnam=Nag_Morlet, 5wparam20;
  • if wavnam=Nag_DGauss, 1wparam8.
3: n Integer Input
On entry: the size, n, of the input dataset x.
Constraint: n2.
4: x[n] const double Input
On entry: x contains the input dataset x[j-1]=xj, for j=1,2,,n.
5: nscal Integer Input
On entry: the number of scales to be computed.
Constraint: nscal1.
6: scales[nscal] const Integer Input
On entry: the scales at which the transform is to be computed.
Constraint: scales[i-1]1, for i=1,2,,nscal.
7: c[nscal×n] double Output
Note: the (i,j)th element of the matrix C is stored in c[(j-1)×nscal+i-1].
On exit: the transform coefficients at the requested scales, where c[(j-1)×nscal+i-1] is the transform coefficient Ci,j at scale i and position j.
8: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, n=value.
Constraint: n2.
On entry, nscal=value.
Constraint: nscal1.
On entry, wavnam=Nag_DGauss and wparam=value.
Constraint: if wavnam=Nag_DGauss, 1wparam8.
On entry, wavnam=Nag_Morlet and wparam=value.
Constraint: if wavnam=Nag_Morlet, 5wparam20.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

7 Accuracy

The accuracy of c09bac 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

Background information to multithreading can be found in the Multithreading documentation.
c09bac is not threaded in any implementation.

9 Further Comments

Workspace is internally allocated by c09bac. The total size of these arrays is 213 + (n+nk-1) double elements and nk Integer elements, where nk = k × max(scales[i-1]) and k=17 when wavnam=Nag_Morlet or Nag_DGauss and k=11 when wavnam=Nag_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 (c09bace.c)

10.2 Program Data

Program Data (c09bace.d)

10.3 Program Results

Program Results (c09bace.r)