1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 08:55:37 +00:00

Updated nearest interpolation to use equal_range function.

This commit is contained in:
Matt Spraggs 2015-11-09 23:04:09 +00:00
parent de7bdc68a4
commit ff49304137

View File

@ -88,14 +88,14 @@ double TabFunction::operator()(const double *arg) const
break;
}
case InterpType::NEAREST: {
auto it = value_.upper_bound(x);
auto upper_pair = *it;
auto lower_pair = *(--it);
if (fabs(upper_pair.first - x) < fabs(lower_pair.first - x)) {
result = upper_pair.second;
auto it = value_.equal_range(x);
auto lower = (x == it.first->first) ? it.first : prev(it.first);
auto upper = it.second;
if (fabs(upper->first - x) < fabs(lower->first - x)) {
result = upper->second;
}
else {
result = lower_pair.second;
result = lower->second;
}
break;
}