NAG CL Interface
c09eac (dim2_​sngl_​fwd)

Settings help

CL Name Style:


1 Purpose

c09eac computes the two-dimensional discrete wavelet transform (DWT) at a single level. The initialization function c09abc must be called first to set up the DWT options.

2 Specification

#include <nag.h>
void  c09eac (Integer m, Integer n, const double a[], Integer lda, double ca[], Integer ldca, double ch[], Integer ldch, double cv[], Integer ldcv, double cd[], Integer ldcd, Integer icomm[], NagError *fail)
The function may be called by the names: c09eac, nag_wav_dim2_sngl_fwd or nag_dwt_2d.

3 Description

c09eac computes the two-dimensional DWT of a given input data array, considered as a matrix A, at a single level. For a chosen wavelet filter pair, the output coefficients are obtained by applying convolution and downsampling by two to the input, A, first over columns and then to the result over rows. The matrix of approximation (or smooth) coefficients, Ca, is produced by the low pass filter over columns and rows; the matrix of horizontal coefficients, Ch, is produced by the high pass filter over columns and the low pass filter over rows; the matrix of vertical coefficients, Cv, is produced by the low pass filter over columns and the high pass filter over rows; and the matrix of diagonal coefficients, Cd, is produced by the high pass filter over columns and rows. To reduce distortion effects at the ends of the data array, several end extension methods are commonly used. Those provided are: periodic or circular convolution end extension, half-point symmetric end extension, whole-point symmetric end extension and zero end extension. The total number, nct, of coefficients computed for Ca, Ch, Cv, and Cd together and the number of columns of each coefficients matrix, ncn, are returned by the initialization function c09abc. These values can be used to calculate the number of rows of each coefficients matrix, ncm, using the formula ncm=nct/(4ncn).

4 References

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

5 Arguments

1: m Integer Input
On entry: number of rows, m, of data matrix A.
Constraint: this must be the same as the value m passed to the initialization function c09abc.
2: n Integer Input
On entry: number of columns, n, of data matrix A.
Constraint: this must be the same as the value n passed to the initialization function c09abc.
3: a[lda×n] const double Input
Note: the (i,j)th element of the matrix A is stored in a[(j-1)×lda+i-1].
On entry: the m×n data matrix A.
4: lda Integer Input
On entry: the stride separating matrix row elements in the array a.
Constraint: ldam.
5: ca[dim] double Output
Note: the dimension, dim, of the array ca must be at least ldca×ncn where ncn is the argument nwcn returned by function c09abc.
The (i,j)th element of the matrix is stored in ca[(j-1)×ldca+i-1].
On exit: contains the ncm×ncn matrix of approximation coefficients, Ca.
6: ldca Integer Input
On entry: the stride separating matrix row elements in the array ca.
Constraint: ldcancm where ncm=nct/(4ncn) and ncn, nct are returned by the initialization function c09abc.
7: ch[dim] double Output
Note: the dimension, dim, of the array ch must be at least ldch×ncn where ncn is the argument nwcn returned by function c09abc.
The (i,j)th element of the matrix is stored in ch[(j-1)×ldch+i-1].
On exit: contains the ncm×ncn matrix of horizontal coefficients, Ch.
8: ldch Integer Input
On entry: the stride separating matrix row elements in the array ch.
Constraint: ldchncm where ncm=nct/(4ncn) and ncn, nct are returned by the initialization function c09abc.
9: cv[dim] double Output
Note: the dimension, dim, of the array cv must be at least ldcv×ncn where ncn is the argument nwcn returned by function c09abc.
The (i,j)th element of the matrix is stored in cv[(j-1)×ldcv+i-1].
On exit: contains the ncm×ncn matrix of vertical coefficients, Cv.
10: ldcv Integer Input
On entry: the stride separating matrix row elements in the array cv.
Constraint: ldcvncm where ncm=nct/(4ncn) and ncn, nct are returned by the initialization function c09abc.
11: cd[dim] double Output
Note: the dimension, dim, of the array cd must be at least ldcd×ncn where ncn is the argument nwcn returned by function c09abc.
The (i,j)th element of the matrix is stored in cd[(j-1)×ldcd+i-1].
On exit: contains the ncm×ncn matrix of diagonal coefficients, Cd.
12: ldcd Integer Input
On entry: the stride separating matrix row elements in the array cd.
Constraint: ldcdncm where ncm=nct/(4ncn) and ncn, nct are returned by the initialization function c09abc.
13: icomm[180] Integer Communication Array
On entry: contains details of the discrete wavelet transform and the problem dimension as setup in the call to the initialization function c09abc.
14: 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_INITIALIZATION
Either the initialization function has not been called first or icomm has been corrupted.
Either the initialization function was called with wtrans=Nag_MultiLevel or icomm has been corrupted.
NE_INT
On entry, ldca=value.
Constraint: ldcavalue, the number of wavelet coefficients in the first dimension.
On entry, ldcd=value.
Constraint: ldcdvalue, the number of wavelet coefficients in the first dimension.
On entry, ldch=value.
Constraint: ldchvalue, the number of wavelet coefficients in the first dimension.
On entry, ldcv=value.
Constraint: ldcvvalue, the number of wavelet coefficients in the first dimension.
On entry, m=value.
Constraint: m=value, the value of m on initialization (see c09abc).
On entry, n=value.
Constraint: n=value, the value of n on initialization (see c09abc).
NE_INT_2
On entry, lda=value and m=value.
Constraint: ldam.
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 the wavelet transform depends only on the floating-point operations used in the convolution and downsampling and should thus be close to machine precision.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
c09eac is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

None.

10 Example

This example computes the two-dimensional discrete wavelet decomposition for a 6×6 input matrix using the Daubechies wavelet, wavnam=Nag_Daubechies4, with half point symmetric end extension.

10.1 Program Text

Program Text (c09eace.c)

10.2 Program Data

Program Data (c09eace.d)

10.3 Program Results

Program Results (c09eace.r)