#include <delta.h>
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) 
A data set of N elements is replaced by the differences. In this simple algorithm
s_{i} = s_{i}  s_{i1}.
For an array indexed from 0, i = 1 to N1. The element at s_{0} is the reference element, which is unchanged. The next element at s_{1} is replaced by the difference between that element and s_{0}.
The algorithm implemented here is an inplace algorithm which replaces the original data in the forward transform and reconstructs the data from inplace 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 Nlog_{2}N. 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.

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 

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[i1]; 00062 } 00063 } 00064 } // inverse 