libipa: pwl: Fix single point Pwl
Fix the eval() function for Pwls that contain only a single point. Remove the should_fail from the corresponding test case. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
@@ -210,6 +210,10 @@ double Pwl::eval(double x, int *span, bool updateSpan) const
|
||||
: points_.size() / 2 - 1);
|
||||
if (span && updateSpan)
|
||||
*span = index;
|
||||
|
||||
if (points_.size() == 1)
|
||||
return points_[0].y();
|
||||
|
||||
return points_[index].y() +
|
||||
(x - points_[index].x()) * (points_[index + 1].y() - points_[index].y()) /
|
||||
(points_[index + 1].x() - points_[index].x());
|
||||
|
||||
@@ -4,7 +4,7 @@ libipa_test = [
|
||||
{'name': 'fixedpoint', 'sources': ['fixedpoint.cpp']},
|
||||
{'name': 'histogram', 'sources': ['histogram.cpp']},
|
||||
{'name': 'interpolator', 'sources': ['interpolator.cpp']},
|
||||
{'name': 'pwl', 'sources': ['pwl.cpp'], 'should_fail': true },
|
||||
{'name': 'pwl', 'sources': ['pwl.cpp'] },
|
||||
]
|
||||
|
||||
foreach test : libipa_test
|
||||
|
||||
Reference in New Issue
Block a user