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

wavefreq.cpp

Go to the documentation of this file.
00001 
00042 
00043 #include <assert.h>
00044 #include <stdio.h>
00045 
00046 #include <vector>
00047 
00048 #include "signalUtil.h"
00049 #include "spectrum.h"
00050 
00051 #include "haar.h"
00052 #include "daub.h"
00053 #include "line.h"
00054 
00055 #include "poly.h"
00056 
00057 
00058 void genSawTooth( double *vec, size_t N)
00059 {
00060   double *A = new double[N];
00061   double *B = new double[N];
00062 
00063   signalUtil::sawToothWave( A, N, 8, 1.5 );  
00064   signalUtil::sawToothWave( B, N, 32, 0.25 );
00065   signalUtil::addSignal( vec, A, B, N );
00066   delete [] A;
00067   delete [] B;
00068 }
00069 
00070 
00093 int
00094 main()
00095 {
00096   const size_t N = 1024;
00097   // const size_t N = sizeof( data ) / sizeof( double );
00098   double vecX[N], vecY[N];
00099 
00100   // signalUtil::gen_freqMix( vecX, vecY, N );
00101   signalUtil::gen_sinCombo( vecX, vecY, N );
00102 
00103   // genSawTooth( vecY, N );
00104   // signalUtil::prVec( vecY, N );
00105 
00106   // signalUtil::prVec( vecY, N );
00107   // signalUtil::prCoords( vecX, vecY, N );
00108 
00109   // The "Haar" transform
00110   // haar<double * > w;
00111 
00112   // Daubechies D4 wavelet
00113   // Daubechies<double * > w;
00114 
00115   // linear interpolation wavelet
00116   // line<double *> w;
00117 
00118   //
00119   // Polynomial interpolation wavelet (not recommended)
00120   //
00121   poly<double *> w;
00122 
00123   double *ptr = vecY;  
00124   w.forwardTrans( ptr, N );
00125 
00126   std::vector<double> powerVec;
00127   spectrum::spectralCalc( vecY, N, powerVec );
00128 
00129   //
00130   // Print out the power spectrum
00131   //
00132   size_t len = powerVec.size();
00133   for (size_t i = 0; i < len; i++) {
00134     // printf("%2d, %7.4f\n", i, powerVec[i] );
00135   }
00136 
00137   double d1[N], d2[N];
00138 
00139   spectrum::copyBands( d1, vecY, N, 0, 6 );
00140   spectrum::copyBands( d2, vecY, N, 7, 10 );
00141 
00142   ptr = d1;
00143   w.inverseTrans( ptr, N );
00144 
00145   ptr = d2;
00146   w.inverseTrans( ptr, N );
00147 
00148   //
00149   // Print out the lower half of the spectrum
00150   //
00151   // signalUtil::prCoords( vecX, d1, N );
00152   // signalUtil::prVec( d1, N );
00153 
00154   //
00155   // Print out the upper half of the spectrum
00156   //
00157   signalUtil::prCoords( vecX, d2, N );
00158   // signalUtil::prVec( d2, N );
00159 
00160   return 0;
00161 }

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