| 54 | } |
| 55 | |
| 56 | bool check_results(const std::vector<float>& values, const std::vector<float>& smoothValues, unsigned int wSize) |
| 57 | { |
| 58 | int size = values.size(); |
| 59 | if(size != (int)smoothValues.size()) return false; |
| 60 | |
| 61 | int semiWidth = wSize/2; |
| 62 | |
| 63 | bool ret = true; |
| 64 | for(int idx = 0 ; idx < size ; ++idx) |
| 65 | { |
| 66 | int start = (std::max)(idx - semiWidth,0); |
| 67 | int end = (std::min)(idx + semiWidth,size-1); |
| 68 | float res = 0; |
| 69 | for(int j = start ; j <= end ; ++j) |
| 70 | { |
| 71 | res+= values[j]; |
| 72 | } |
| 73 | |
| 74 | res /= float(end - start +1); |
| 75 | |
| 76 | if(std::abs(res-smoothValues[idx]) > 1e-3) |
| 77 | { |
| 78 | std::cout << "idx = " << idx << " -- expected = " << res << " -- result = " << smoothValues[idx] << std::endl; |
| 79 | ret = false; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | return ret; |
| 84 | } |
| 85 | |
| 86 | // generate a uniform law over [0,10] |
| 87 | float myRand() |