Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

delta_trans Class Template Reference

The delta transform. More...

#include <delta.h>

List of all members.

Public Methods

void forward (T *vec, size_t len)
 Convert the value in the array into an initial reference value and a set of delta values. More...

void inverse (T *vec, size_t len)


Detailed Description

template<class T> class delta_trans

The delta transform.

A data set of N elements is replaced by the differences. In this simple algorithm

  si = si - si-1.
  

For an array indexed from 0, i = 1 to N-1. The element at s0 is the reference element, which is unchanged. The next element at s1 is replaced by the difference between that element and s0.

The algorithm implemented here is an in-place algorithm which replaces the original data in the forward transform and reconstructs the data from in-place in the inverse transform.

The class is implemented as a template class. Obviously the type used to instantiate the template must support signed arithmetic.

The class was written as a comparision baseline for the wavelet compresson algorithms. The "delta" algorithm is very simple and has a time complexity of N, where as the wavelet algorithm is Nlog2N. Obviously, if the wavelet algorithm does not do better than this simple algorithm for the data set in question, the wavelet is a poor choice (or, perhaps, the wavelet function in the predict step is poorly chosen for the data set).

Definition at line 35 of file delta.h.


Member Function Documentation

template<class T>
void delta_trans<T>::forward ( T * vec,
size_t len ) [inline]
 

Convert the value in the array into an initial reference value and a set of delta values.

Definition at line 42 of file delta.h.

Referenced by delta_calc().

00043   {
00044     if (vec != 0 && len > 0) {
00045       // reference value
00046       T next;
00047       T refVal = vec[0];
00048 
00049       for (size_t i = 1; i < len; i++) {
00050         next = vec[i];
00051         vec[i] = vec[i] - refVal;
00052         refVal = next;
00053       }
00054     }
00055   } // forward

template<class T>
void delta_trans<T>::inverse ( T * vec,
size_t len ) [inline]
 

Definition at line 57 of file delta.h.

Referenced by delta_calc().

00058   {
00059     if (vec != 0 && len > 0) {
00060       for (size_t i = 1; i < len; i++) {
00061         vec[i] = vec[i] + vec[i-1];
00062       }
00063     }
00064   } // inverse


The documentation for this class was generated from the following file:
Generated at Sat Aug 10 13:23:36 2002 for Wavelet Packet Transform and Lossless Compression by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001