Skip to content
Snippets Groups Projects
Commit 5e6c03a0 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

Merge branch 'fix/monotone-cubic-spline' into 'master'

[monotonecubicspline] Fix bug in lookup index

See merge request !2332
parents 2d865112 269ae2f7
No related branches found
No related tags found
1 merge request!2332[monotonecubicspline] Fix bug in lookup index
...@@ -200,14 +200,14 @@ private: ...@@ -200,14 +200,14 @@ private:
auto lookUpIndexIncreasing_(const std::vector<Scalar>& vec, const Scalar v) const auto lookUpIndexIncreasing_(const std::vector<Scalar>& vec, const Scalar v) const
{ {
const auto lookUpIndex = std::distance(vec.begin(), std::lower_bound(vec.begin(), vec.end(), v)); const auto lookUpIndex = std::distance(vec.begin(), std::lower_bound(vec.begin(), vec.end(), v));
assert(lookUpIndex != 0); assert(lookUpIndex != 0 && lookUpIndex < vec.size());
return lookUpIndex; return lookUpIndex;
} }
auto lookUpIndexDecreasing_(const std::vector<Scalar>& vec, const Scalar v) const auto lookUpIndexDecreasing_(const std::vector<Scalar>& vec, const Scalar v) const
{ {
const auto lookUpIndex = vec.size() - std::distance(vec.rbegin(), std::lower_bound(vec.rbegin(), vec.rend(), v)); const auto lookUpIndex = vec.size() - std::distance(vec.rbegin(), std::upper_bound(vec.rbegin(), vec.rend(), v));
assert(lookUpIndex != 0); assert(lookUpIndex != 0 && lookUpIndex < vec.size());
return lookUpIndex; return lookUpIndex;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment