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

haar_classic.h

Go to the documentation of this file.
00001 
00002 #ifndef _HAAR_CLASSIC_H_
00003 #define _HAAR_CLASSIC_H_
00004 
00005 #include <math.h>
00006 
00007 #include "liftbase.h"
00008 
00040 
00110 template <class T>
00111 class haar_classic : public liftbase<T, double> {
00112 
00113 protected:
00114 
00119   void predict( T& vec, int N, transDirection direction )
00120   {
00121     int half = N >> 1;
00122     int cnt = 0;
00123 
00124     for (int i = 0; i < half; i++) {
00125       double predictVal = vec[i];
00126       int j = i + half;
00127 
00128       if (direction == forward) {
00129         vec[j] = (predictVal - vec[j] )/2;
00130       }
00131       else if (direction == inverse) {
00132         vec[j] =  predictVal - (2 * vec[j]);
00133       }
00134       else {
00135         printf("haar_classic::predict: bad direction value\n");
00136       }
00137     }
00138   } // predict
00139 
00140 
00145   void update( T& vec, int N, transDirection direction )
00146   {
00147     int half = N >> 1;
00148 
00149     for (int i = 0; i < half; i++) {
00150       int j = i + half;
00151       double updateVal = vec[j];
00152 
00153       if (direction == forward) {
00154         vec[i] = vec[i] - updateVal;
00155       }
00156       else if (direction == inverse) {
00157         vec[i] = vec[i] + updateVal;
00158       }
00159       else {
00160         printf("update: bad direction value\n");
00161       }
00162     }
00163   } // update
00164 
00165 }; // haar_classic
00166 
00167 #endif

Generated at Tue May 27 21:56:16 2003 for Wavelet compression, determinism and time series forecasting by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001