From 9155ed54a13f88de7f6df4ebaa62782311693d05 Mon Sep 17 00:00:00 2001 From: Stefan Klug Date: Fri, 13 Jun 2025 12:09:37 +0200 Subject: [PATCH] libipa: pwl: Improve documentation If a Pwl is evaluated outside of the domain, it gets extrapolated linearly. Fix the documentation as it states otherwise. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham --- src/ipa/libipa/pwl.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp index 3fa005ba..3d218817 100644 --- a/src/ipa/libipa/pwl.cpp +++ b/src/ipa/libipa/pwl.cpp @@ -35,14 +35,13 @@ namespace ipa { * * https://en.wikipedia.org/wiki/Piecewise_linear_function * - * A consequence of the Pwl class being defined by knots instead of linear - * functions is that the values of the piecewise linear function past the ends - * of the function are constants as opposed to linear functions. In a - * mathematical piecewise linear function that is defined by multiple linear - * functions, the ends of the function are also linear functions and hence grow - * to infinity (or negative infinity). However, since this Pwl class is defined - * by knots, the y-value of the leftmost and rightmost knots will hold for all - * x values to negative infinity and positive infinity, respectively. + * Outside the domain of the piecewise linear function the closest segment is + * extrapolated linearly. If one wants to ensure that the returned values stay + * within the range of the pwl, the input can be clamped: + * + * \code{.cpp} + * pwl.eval(pwl.domain().clip(x)) + * \endcode */ /**