Last change
on this file since 13151 was 12356, checked in by neise, 13 years ago |
adjusted fbsl for ISDC cluster .. I basically renamed a few variables and generally tidied up a bit ... not sure what actually helped... maybe its still not solved.
|
File size:
1.1 KB
|
Line | |
---|
1 | #include <vector>
|
---|
2 | #include <deque>
|
---|
3 |
|
---|
4 | // source vector is
|
---|
5 | void factfir(double b, vector<double> &a, int k, vector<float> &source, vector<float> &dest){
|
---|
6 | //dest.clear();
|
---|
7 |
|
---|
8 | for (int slice =0; slice < (int)source.size(); slice++) {
|
---|
9 | float currentval = 0;
|
---|
10 |
|
---|
11 | for (int i=0; i < k ; i++){
|
---|
12 | currentval += a[i] * source[ (slice - i + source.size()) % source.size() ];
|
---|
13 | }
|
---|
14 | dest[slice] = currentval / b;
|
---|
15 | }
|
---|
16 | }
|
---|
17 |
|
---|
18 | void sliding_avg(vector<float> &source, vector<float> &dest, unsigned int HalfWidth){
|
---|
19 | // make local copy of source, in case source and dest are the same
|
---|
20 |
|
---|
21 | deque<float> local;
|
---|
22 | local.insert(local.end(), source.begin(), source.end());
|
---|
23 | // edge treatment.
|
---|
24 | local.insert(local.begin(), HalfWidth, source[0]);
|
---|
25 | local.insert(local.end(), HalfWidth, source[source.size()-1]);
|
---|
26 |
|
---|
27 | deque<float>::iterator it;
|
---|
28 |
|
---|
29 | dest.clear();
|
---|
30 |
|
---|
31 | float x;
|
---|
32 | for (it=local.begin()+HalfWidth; it<local.end()-HalfWidth; ++it) {
|
---|
33 |
|
---|
34 | x=*it;
|
---|
35 | float FullWidth = 2*HalfWidth+1;
|
---|
36 |
|
---|
37 | for ( unsigned int i=0; i < HalfWidth ; i++){
|
---|
38 | x += *(it+i); // add the right neighbors
|
---|
39 | x += *(it-i); // and don't forget the left neighbors on the left
|
---|
40 | }
|
---|
41 |
|
---|
42 | dest.push_back(x/FullWidth);
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.