Changeset 12304
- Timestamp:
- 10/27/11 21:35:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/factfir.C
r12166 r12304 1 1 #include <vector> 2 #include <deque> 3 2 4 3 5 #ifndef FAD_MAX_SAMPLES … … 10 12 void factfir(double b, vector<double> &a, int k, vector<float> &source, vector<float> &dest){ 11 13 //dest.clear(); 12 14 13 15 for (int slice =0; slice < FAD_MAX_SAMPLES; slice++) { 14 16 float currentval = 0; 15 17 16 18 for (int i=0; i < k ; i++){ 17 19 currentval += a[i] * source[ (slice - i + FAD_MAX_SAMPLES) % FAD_MAX_SAMPLES ]; 18 } 19 dest[slice] = currentval / b; 20 } 21 dest[slice] = currentval / b; 20 22 } 21 23 } 24 25 void sliding_avg(vector<float> &source, vector<float> &dest, unsigned int HalfWidth){ 26 // make local copy of source, in case source and dest are the same 27 28 deque<float> local; 29 local.insert(local.end(), source.begin(), source.end()); 30 // edge treatment. 31 local.insert(local.begin(), HalfWidth, source[0]); 32 local.insert(local.end(), HalfWidth, source[source.size()-1]); 33 34 deque<float>::iterator it; 35 36 dest.clear(); 37 38 float x; 39 for (it=local.begin()+HalfWidth; it<local.end()-HalfWidth; ++it) { 40 41 x=*it; 42 float FullWidth = 2*HalfWidth+1; 43 44 for ( unsigned int i=0; i < HalfWidth ; i++){ 45 x += *(it+i); // add the right neighbors 46 x += *(it-i); // and don't forget the left neighbors on the left 47 } 48 49 dest.push_back(x/FullWidth); 50 } 51 } 52
Note:
See TracChangeset
for help on using the changeset viewer.