Message ID | 20250613100947.589875-3-stefan.klug@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Hi Paul, Quoting Stefan Klug (2025-06-13 11:09:37) > 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 <stefan.klug@ideasonboard.com> > --- > 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 3fa005ba92df..3d2188170d83 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: I remember working through some topics with you where I'm sure we were possibly relying on the fact that PWL would clip to the domain, and return the limits rather than continually extrapolating ... Or am I confusing something from the MatrixInterpolators perhaps? Any concerns or thoughts about this, or does it impact anything you might have worked on? -- Kieran > + * > + * \code{.cpp} > + * pwl.eval(pwl.domain().clip(x)) > + * \endcode > */ > > /** > -- > 2.48.1 >
diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp index 3fa005ba92df..3d2188170d83 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 */ /**
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 <stefan.klug@ideasonboard.com> --- src/ipa/libipa/pwl.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)