| 143 | } |
| 144 | |
| 145 | void |
| 146 | SNREstimator::feed(std::vector<unsigned int> const &history) |
| 147 | { |
| 148 | unsigned int max = 0; |
| 149 | |
| 150 | if (this->length != history.size()) { |
| 151 | this->length = static_cast<unsigned int>(history.size()); |
| 152 | this->gaussian.resize(this->length); |
| 153 | this->Hi.resize(this->length); |
| 154 | this->Htilde.resize(this->length); |
| 155 | this->hx = 1.f / this->length; |
| 156 | } |
| 157 | |
| 158 | for (unsigned int i = 0; i < history.size(); ++i) |
| 159 | if (max < history[i]) |
| 160 | max = history[i]; |
| 161 | |
| 162 | if (max == 0) |
| 163 | max = 1; |
| 164 | |
| 165 | for (unsigned int i = 0; i < history.size(); ++i) |
| 166 | this->Htilde[i] = static_cast<float>(history[i]) / max; |
| 167 | |
| 168 | this->iterate(); |
| 169 | } |
| 170 | |
| 171 | void |
| 172 | SNREstimator::setAlpha(float alpha) |