Chapter I.4. Advanced interface

Table of Contents

I.4.1. Features
I.4.2. Usage
I.4.3. Choice of wavelet filter
I.4.3.1. Step 1: define the tag class
I.4.3.2. Step 2: specialize qmf_predefined
I.4.3.3. Step 3: provide the filter coefficients

I.4.1. Features

The advanced interface offers the following features which are not included in the basic interface:

  • arbitrary dimensionality of arrays
  • user-defined wavelet filters
  • user-defined data types

I.4.2. Usage

Like the basic interface, the advanced interface consists of two functions. The names of these functions are also identical, but their signatures are different:

			namespace wavelet_library {
			template<rank_t rank, class Filter, class TElem>
			error_code forward_wavelet_transform(const size_t* size, TElem* in, TElem* out, wt_flags f = WT_DEFAULT, int levels = -1);
		
			template<rank_t rank, class Filter, class TElem>
			error_code inverse_wavelet_transform(const size_t* size, TElem* in, TElem* out, wt_flags f = WT_DEFAULT,  int levels = -1);
			}
		

The first two template arguments have to be specified explicitly in the function call, and they control respectively the rank of the wavelet transform and the wavelet filter (see below).

The third template arguments corresponds to the numerical type of the data to be treated.

The meaning of the run-time arguments is the same as for the basic interface.

The example presented above can be translated to the advanced interface simply by including wavelet_library/advanced.hpp and by replacing the call to forward_wavelet_transform by:

				spectral::wavelet_library::forward_wavelet_transform<1,spectral::filters::coiflet_2>(&N, x, y);			
		

I.4.3. Choice of wavelet filter

In the advanced interface, the specification of the wavelet filter does not rely on a string descriptor, but rather on a tag-class mechanism. The available tag classes are listed in the include file transform/wavelets/filters/qmf_tags.hpp. They are defined in the namespace spectral::filters. Note that only the orthogonal filters may be employed with KIWIWALI.

Let us assume that we want to extend the functionality of KIWIWALI to handle another wavelet filter, whose coefficients we know from a textbook or a paper.

I.4.3.1. Step 1: define the tag class

By copy-paste starting from the tag-class filters::haar, we first define a new tag-class describing the properties of our filter. Note that the midpoint member variable is deprecated and actually not necessary.

			struct my_filter
			{
				static const size_t static_size = 4;
				static const unsigned int vanishing_moments = 1;
				typedef my_filter Dual_t;
				static const char* name;
			};
			const char* my_filter::name = "my_filter";
			

I.4.3.2. Step 2: specialize qmf_predefined

The filter coefficients have to be provided through a specialization of the class template spectral::qmf_predfined, which is defined in transform/wavelets/filters/qmf_predefined_runtime.hpp. Examples of this can be found in transform/wavelets/filters/qmf_predefined.hpp.

For our filter, the specialization goes like this:

			#include <boost/array.hpp>
			template<>
			struct qmf_predefined<my_filter>
			{
				typedef my_filter Tag_t;
				typedef double value_type;
				static const boost::array<value_type, Tag_t::static_size> value;
			};
			

I.4.3.3. Step 3: provide the filter coefficients

Now the filter coefficients can be provided by initializing the member variable value of the above structure:

			template<>
			const boost::array<double,4gt; qmf_predefined<my_filter>::value = {{0, 1, 2, 3}};