Main Page   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 
00053 template <class T>
00054 class line : public liftbase<T, double> {
00055 
00056 private:
00057 
00125    double new_y( double y1, double y2)
00126    {
00127      double y = 2 * y2 - y1;
00128      return y;
00129    }
00130 
00131 
00132 protected:
00133 
00169   void predict( T& vec, int N, transDirection direction )
00170   {
00171     int half = N >> 1;
00172     double predictVal;
00173 
00174     for (int i = 0; i < half; i++) {
00175       int j = i + half;
00176       if (i < half-1) {
00177         predictVal = (vec[i] + vec[i+1])/2;
00178       }
00179       else if (N == 2) {
00180         predictVal = vec[0];
00181       }
00182       else {
00183         // calculate the last "odd" prediction
00184         double n_plus1 = new_y( vec[i-1], vec[i] );
00185         predictVal = (vec[i] + n_plus1)/2;
00186       }
00187 
00188       if (direction == forward) {
00189         vec[j] = vec[j] - predictVal;
00190       }
00191       else if (direction == inverse) {
00192         vec[j] = vec[j] + predictVal;
00193       }
00194       else {
00195         printf("predictline::predict: bad direction value\n");
00196       }
00197     }
00198   } // predict
00199 
00200   
00253   void update( T& vec, int N, transDirection direction )
00254   {
00255     int half = N >> 1;
00256 
00257     for (int i = 0; i < half; i++) {
00258       int j = i + half;
00259       double val;
00260 
00261       if (i == 0) {
00262         val = vec[j]/2.0;
00263       }
00264       else {
00265         val = (vec[j-1] + vec[j])/4.0;
00266       }
00267       if (direction == forward) {
00268         vec[i] = vec[i] + val;
00269       }
00270       else if (direction == inverse) {
00271         vec[i] = vec[i] - val;
00272       }
00273       else {
00274         printf("update: bad direction value\n");
00275       }
00276     } // for    
00277   }
00278 
00279 }; // line
00280 
00281 #endif

Generated at Sun Aug 18 16:56:41 2002 for Wavelet Spectral Analysis by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001