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

ts_trans_int.h

Go to the documentation of this file.
00001 
00002 #ifndef _TS_TRANS_INT_H_
00003 #define _TS_TRANS_INT_H_
00004 
00005 
00006 
00039 
00040 #include "stdio.h"
00041 #include "haar_int.h"
00042 
00043 
00112 // class ts_trans_int : public liftbase<int *, int>
00113 class ts_trans_int : public haar_int
00114 {
00115 public:
00117   ts_trans_int() {}
00119   ~ts_trans_int() {}
00121   ts_trans_int( const ts_trans_int &rhs );
00122 
00123 private:
00177   int new_n_plus1( int y1, int y2)
00178   {
00179     int y = 2 * y2 - y1;
00180     return y;
00181   }
00182 
00204   int new_n_minus1( int y1, int y2)
00205   {
00206     int y = 2 * y1 - y2;
00207     return y;
00208   }
00209 
00210 protected:
00211 
00221   void predict2( int *& vec, int N, transDirection direction )
00222   {
00223     int half = N >> 1;
00224     int predictVal;
00225 
00226     for (int i = 0; i < half; i++) {
00227       int j = i + half;
00228       int y_n_plus1;
00229       int y_n_minus1;
00230 
00231       if (N == 2) {
00232         y_n_minus1 = vec[0];
00233         y_n_plus1 = vec[0];
00234       }
00235       else if (i == 0) {
00236         y_n_minus1 = new_n_minus1( vec[0], vec[1] );
00237         y_n_plus1 = vec[1];
00238       }
00239       else if (i < half-1) {
00240         y_n_minus1 = vec[i-1];
00241         y_n_plus1  = vec[i+1];
00242       }
00243       else { // i == half-1
00244         y_n_minus1 = vec[i-1];
00245         y_n_plus1  = new_n_plus1( vec[i-1], vec[i] );
00246       }
00247 
00248       predictVal = (int)( (((float)y_n_minus1 - (float)y_n_plus1)/4.0) + 0.5 );
00249 
00250       if (direction == forward) {
00251         vec[j] = vec[j] + predictVal;
00252       }
00253       else if (direction == inverse) {
00254         vec[j] = vec[j] - predictVal;
00255       }
00256       else {
00257         printf("haar_int::predict: bad direction value\n");
00258       }
00259     }      
00260   } // predict2
00261 
00262 public:
00267   void forwardStep( int *& vec, const int n )
00268   {
00269     split( vec, n );
00270     predict( vec, n, forward );
00271     update( vec, n, forward );
00272     predict2( vec, n, forward );
00273   } // forwardStep
00274 
00279   void inverseStep( int *& vec, const int n )
00280   {
00281     predict2( vec, n, inverse );
00282     update( vec, n, inverse );
00283     predict( vec, n, inverse );
00284     merge( vec, n );
00285   } // inverseStep
00286 
00287 }; // ts_trans_int
00288 
00289 
00290 #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