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:
parent
de7bdc68a4
commit
ff49304137
@ -88,14 +88,14 @@ double TabFunction::operator()(const double *arg) const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InterpType::NEAREST: {
|
case InterpType::NEAREST: {
|
||||||
auto it = value_.upper_bound(x);
|
auto it = value_.equal_range(x);
|
||||||
auto upper_pair = *it;
|
auto lower = (x == it.first->first) ? it.first : prev(it.first);
|
||||||
auto lower_pair = *(--it);
|
auto upper = it.second;
|
||||||
if (fabs(upper_pair.first - x) < fabs(lower_pair.first - x)) {
|
if (fabs(upper->first - x) < fabs(lower->first - x)) {
|
||||||
result = upper_pair.second;
|
result = upper->second;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = lower_pair.second;
|
result = lower->second;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user