ConstantQFolder.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <iostream>
00023 #include <cmath>
00024 #include "ConstantQFolder.hxx"
00025
00026 namespace Simac
00027 {
00028
00032 static double complexModule(const double & real, const double & imag)
00033 {
00034 return std::sqrt(real*real + imag*imag);
00035 }
00036
00037 ConstantQFolder::ConstantQFolder(unsigned nConstantQBins, int binsPerOctave)
00038 : _binsPerOctave(binsPerOctave)
00039 , _nConstantQBins(nConstantQBins)
00040 {
00041 _chromadata.resize(_binsPerOctave);
00042 }
00043
00044 ConstantQFolder::~ConstantQFolder()
00045 {
00046 }
00047
00048 void ConstantQFolder::doIt(const std::vector<double> & constantQData)
00049 {
00050
00051 for (unsigned i=0; i<_binsPerOctave; i++) _chromadata[i]=0;
00052
00053
00054 const unsigned nOctaves = (int)floor(double(_nConstantQBins/_binsPerOctave))-1;
00055 unsigned constantQBin = 0;
00056 for (unsigned octave=0; octave<=nOctaves; octave++) {
00057 for (unsigned i=0; i<_binsPerOctave; i++) {
00058 const double & real = constantQData[constantQBin++];
00059 const double & imag = constantQData[constantQBin++];
00060 _chromadata[i] += complexModule(real, imag);
00061 }
00062 }
00063 }
00064
00065 }
00066