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

line.h

Go to the documentation of this file.
00001 
00002 
00003 #ifndef _LINE_H_
00004 #define _LINE_H_
00005 
00006 #include "liftbase.h"
00007 
00008 
00055 template <class T>
00056 class line : public liftbase<T, double> {
00057 
00058 private:
00059 
00127    double new_y( double y1, double y2)
00128    {
00129      double y = 2 * y2 - y1;
00130      return y;
00131    }
00132 
00133 
00134 protected:
00135 
00171   void predict( T& vec, int N, transDirection direction )
00172   {
00173     int half = N >> 1;
00174     double predictVal;
00175 
00176     for (int i = 0; i < half; i++) {
00177       int j = i + half;
00178       if (i < half-1) {
00179         predictVal = (vec[i] + vec[i+1])/2;
00180       }
00181       else if (N == 2) {
00182         predictVal = vec[0];
00183       }
00184       else {
00185         // calculate the last "odd" prediction
00186         double n_plus1 = new_y( vec[i-1], vec[i] );
00187         predictVal = (vec[i] + n_plus1)/2;
00188       }
00189 
00190       if (direction == forward) {
00191         vec[j] = vec[j] - predictVal;
00192       }
00193       else if (direction == inverse) {
00194         vec[j] = vec[j] + predictVal;
00195       }
00196       else {
00197         printf("predictline::predict: bad direction value\n");
00198       }
00199     }
00200   } // predict
00201 
00202   
00255   void update( T& vec, int N, transDirection direction )
00256   {
00257     int half = N >> 1;
00258 
00259     for (int i = 0; i < half; i++) {
00260       int j = i + half;
00261       double val;
00262 
00263       if (i == 0) {
00264         val = vec[j]/2.0;
00265       }
00266       else {
00267         val = (vec[j-1] + vec[j])/4.0;
00268       }
00269       if (direction == forward) {
00270         vec[i] = vec[i] + val;
00271       }
00272       else if (direction == inverse) {
00273         vec[i] = vec[i] - val;
00274       }
00275       else {
00276         printf("update: bad direction value\n");
00277       }
00278     } // for    
00279   }
00280 
00281 }; // line
00282 
00283 #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