NAG Library Routine Document

c09eaf  (dim2_sngl_fwd)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

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

2
Specification

Fortran Interface
Subroutine c09eaf ( m, n, a, lda, ca, ldca, ch, ldch, cv, ldcv, cd, ldcd, icomm, ifail)
Integer, Intent (In):: m, n, lda, ldca, ldch, ldcv, ldcd
Integer, Intent (Inout):: icomm(180), ifail
Real (Kind=nag_wp), Intent (In):: a(lda,n)
Real (Kind=nag_wp), Intent (Inout):: ca(ldca,*), ch(ldch,*), cv(ldcv,*), cd(ldcd,*)
C Header Interface
#include nagmk26.h
void  c09eaf_ ( const Integer *m, const Integer *n, const double a[], const Integer *lda, double ca[], const Integer *ldca, double ch[], const Integer *ldch, double cv[], const Integer *ldcv, double cd[], const Integer *ldcd, Integer icomm[], Integer *ifail)

3
Description

c09eaf 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 routine c09abf. 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 – IntegerInput
On entry: number of rows, m, of data matrix A.
Constraint: this must be the same as the value m passed to the initialization routine c09abf.
2:     n – IntegerInput
On entry: number of columns, n, of data matrix A.
Constraint: this must be the same as the value n passed to the initialization routine c09abf.
3:     aldan – Real (Kind=nag_wp) arrayInput
On entry: the m by n data matrix A.
4:     lda – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which c09eaf is called.
Constraint: ldam.
5:     caldca* – Real (Kind=nag_wp) arrayOutput
Note: the second dimension of the array ca must be at least ncn where ncn is the argument nwcn returned by routine c09abf.
On exit: contains the ncm by ncn matrix of approximation coefficients, Ca.
6:     ldca – IntegerInput
On entry: the first dimension of the array ca as declared in the (sub)program from which c09eaf is called.
Constraint: ldcancm where ncm=nct/4ncn and ncn, nct are returned by the initialization routine c09abf.
7:     chldch* – Real (Kind=nag_wp) arrayOutput
Note: the second dimension of the array ch must be at least ncn where ncn is the argument nwcn returned by routine c09abf.
On exit: contains the ncm by ncn matrix of horizontal coefficients, Ch.
8:     ldch – IntegerInput
On entry: the first dimension of the array ch as declared in the (sub)program from which c09eaf is called.
Constraint: ldchncm where ncm=nct/4ncn and ncn, nct are returned by the initialization routine c09abf.
9:     cvldcv* – Real (Kind=nag_wp) arrayOutput
Note: the second dimension of the array cv must be at least ncn where ncn is the argument nwcn returned by routine c09abf.
On exit: contains the ncm by ncn matrix of vertical coefficients, Cv.
10:   ldcv – IntegerInput
On entry: the first dimension of the array cv as declared in the (sub)program from which c09eaf is called.
Constraint: ldcvncm where ncm=nct/4ncn and ncn, nct are returned by the initialization routine c09abf.
11:   cdldcd* – Real (Kind=nag_wp) arrayOutput
Note: the second dimension of the array cd must be at least ncn where ncn is the argument nwcn returned by routine c09abf.
On exit: contains the ncm by ncn matrix of diagonal coefficients, Cd.
12:   ldcd – IntegerInput
On entry: the first dimension of the array cd as declared in the (sub)program from which c09eaf is called.
Constraint: ldcdncm where ncm=nct/4ncn and ncn, nct are returned by the initialization routine c09abf.
13:   icomm180 – Integer arrayCommunication Array
On entry: contains details of the discrete wavelet transform and the problem dimension as setup in the call to the initialization routine c09abf.
14:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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, m=value.
Constraint: m=value, the value of m on initialization (see c09abf).
On entry, n=value.
Constraint: n=value, the value of n on initialization (see c09abf).
ifail=2
On entry, lda=value and m=value.
Constraint: ldam.
ifail=3
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.
ifail=6
Either the initialization routine has not been called first or icomm has been corrupted.
Either the initialization routine was called with wtrans='M' or icomm has been corrupted.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation 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

c09eaf 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 routine. 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='DB4', with half point symmetric end extension.

10.1
Program Text

Program Text (c09eafe.f90)

10.2
Program Data

Program Data (c09eafe.d)

10.3
Program Results

Program Results (c09eafe.r)

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