Main Page   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 
00016 void spectrum::spectralCalc( const double *a, 
00017                              const size_t N,
00018                              std::vector<double> &v )
00019 {
00020   size_t end = 1;
00021   size_t start = 0;
00022 
00023   while (end <= N) {
00024     double power = 0;
00025     for (size_t i = start; i < end; i++) {
00026       power = power + (a[i] * a[i]);
00027     }
00028     v.push_back( power );
00029     start = end;
00030     end = end << 1;
00031   }
00032 } // spectralCalc
00033 
00034 
00035 
00036 
00045 void spectrum::copyBands( double *dest,
00046                           const double *src,
00047                           const size_t N,
00048                           size_t startBand,
00049                           const size_t endBand )
00050 {
00051   size_t end = 1;
00052   size_t start = 0;
00053   size_t bandCnt = 0;
00054 
00055   while (end <= N) {
00056     double power = 0;
00057     for (size_t i = start; i < end; i++) {
00058       if (bandCnt >= startBand && bandCnt <= endBand)
00059         dest[i] = src[i];
00060       else
00061         dest[i] = 0;
00062     }
00063     start = end;
00064     end = end << 1;
00065     bandCnt++;
00066   }
00067 } // copyBands
00068 
00069 

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