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

spectrum.cpp

Go to the documentation of this file.
00001 
00002 #include <vector>
00003 
00004 #include "spectrum.h"
00005 
00020 void spectrum::spectralCalc( const double *a, 
00021                              const size_t N,
00022                              std::vector<double> &v )
00023 {
00024   size_t end = 2;
00025   size_t start = 1;
00026 
00027   while (end <= N) {
00028     double power = 0;
00029     for (size_t i = start; i < end; i++) {
00030       power = power + (a[i] * a[i]);
00031     }
00032     v.push_back( power );
00033     start = end;
00034     end = end << 1;
00035   }
00036 } // spectralCalc
00037 
00038 
00039 
00040 
00049 void spectrum::copyBands( double *dest,
00050                           const double *src,
00051                           const size_t N,
00052                           size_t startBand,
00053                           const size_t endBand )
00054 {
00055   size_t end = 1;
00056   size_t start = 0;
00057   size_t bandCnt = 0;
00058 
00059   while (end <= N) {
00060     double power = 0;
00061     for (size_t i = start; i < end; i++) {
00062       if (bandCnt >= startBand && bandCnt <= endBand)
00063         dest[i] = src[i];
00064       else
00065         dest[i] = 0;
00066     }
00067     start = end;
00068     end = end << 1;
00069     bandCnt++;
00070   }
00071 } // copyBands
00072 
00073 

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