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

packfreq.cpp

Go to the documentation of this file.
00001 
00033 #include <assert.h>
00034 #include <stdio.h>
00035 #include <math.h>
00036 
00037 #include "packfreq.h"
00038 
00039 
00040 
00041 
00085 packfreq::packfreq( const double *vec, 
00086                     const size_t N, 
00087                     liftbase<packcontainer, double> *w )
00088 {
00089   waveObj = w;
00090 
00091   block_pool mem_pool;
00092   double *vecCopy = (double *)mem_pool.pool_alloc( N * sizeof( double ) );
00093 
00094   for (int i = 0; i < N; i++) {
00095     vecCopy[i] = vec[i];
00096   }
00097 
00098   root = new packnode<double>( vecCopy, N, packnode<double>::OriginalData );
00099   root->mark( true );
00100   //
00101   // The first level uses the standard wavelet calculation, so
00102   // reverse = false
00103   //              freqCalc, reverse
00104   newLevel( root, true,     false );
00105 } // packfreq
00106 
00107 
00108 
00115 void packfreq::findLevel( packnode<double>* top, 
00116                           size_t cur_level,
00117                           const size_t level )
00118 {
00119   if (top != 0) {
00120     if (cur_level == level) {
00121       mat.append(top);
00122     }
00123     else {
00124       findLevel( top->lhsChild(), cur_level+1, level );
00125       findLevel( top->rhsChild(), cur_level+1, level );
00126     }
00127   }
00128 } // findLevel
00129 
00130 
00131 
00158 void packfreq::getLevel( const size_t level )
00159 {
00160   findLevel( root, 0, level );
00161 } // getLevel
00162 
00163 
00164 
00228 void packfreq::plotMat(const size_t N)
00229 {
00230   size_t num_y = mat.length();
00231   const double incr = (double)N / (double)num_y;
00232   if (num_y > 0) {
00233     size_t num_x = mat[0]->length();
00234 
00235     double freq_start = 0.0;
00236     for (size_t y = 0; y < num_y; y++) {
00237       double time_start = 0.0;
00238       for (size_t x = 0; x < num_x; x++) {
00239         double val = (*mat[y])[ x ];
00240         // plot time on the x, frequency on y
00241         // printf(" %d  %d  %7.4f\n", x, y, log(1+(val*val)) );
00242 
00243         // plot frequency on x, time on y
00244         printf(" %d  %d  %7.4f\n", y, x, log(1+(val*val)) );
00245 
00246         // plot actual frequency and time values,
00247         // with frequency on x and time on y
00248         // printf(" %7.4f  %7.4f  %7.4f\n", 
00249         //        freq_start, time_start, log(1+(val*val)) );
00250 
00251         time_start = time_start + incr;
00252       }
00253       freq_start = freq_start + incr;
00254       printf("\n");
00255     }
00256   }
00257 } // plotMat
00258 
00259 
00260 
00264 void packfreq::prMat()
00265 {
00266   int num_y = mat.length();
00267   if (num_y > 0) {
00268     size_t num_x = mat[0]->length();
00269     for (int y = num_y-1; y >= 0; y--) {
00270       for (size_t x = 0; x < num_x; x++) {
00271         printf(" %7.4f ", (*mat[y])[ x ] );
00272       }
00273       printf("\n");
00274       fflush(stdout);
00275     }
00276   }
00277 } // prMat
00278 
00279 

Generated at Sat Aug 10 13:23:34 2002 for Wavelet Packet Transform and Lossless Compression by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001