Message ID | 20240613013944.23344-8-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
On Thu, Jun 13, 2024 at 04:39:40AM +0300, Laurent Pinchart wrote: > Add a size() function to the Pwl class to return the number of points in > the piecewise linear function. This is useful, for instance, to validate > that all points added with append() or prepend() have been taken into > account. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > --- > src/ipa/libipa/pwl.cpp | 6 ++++++ > src/ipa/libipa/pwl.h | 2 ++ > 2 files changed, 8 insertions(+) > > diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp > index d8ea92be0a86..8b437dd1a650 100644 > --- a/src/ipa/libipa/pwl.cpp > +++ b/src/ipa/libipa/pwl.cpp > @@ -188,6 +188,12 @@ void Pwl::prepend(double x, double y, const double eps) > * \return True if there are no points in the function, false otherwise > */ > > +/** > + * \fn Pwl::size() const > + * \brief Retrieve the number of points in the piecewise linear function > + * \return The number of points in the piecewise linear function > + */ > + > /** > * \brief Get the domain of the piecewise linear function > * \return An interval representing the domain > diff --git a/src/ipa/libipa/pwl.h b/src/ipa/libipa/pwl.h > index b4de00cf88f0..028342314fca 100644 > --- a/src/ipa/libipa/pwl.h > +++ b/src/ipa/libipa/pwl.h > @@ -52,6 +52,8 @@ public: > void append(double x, double y, double eps = 1e-6); > > bool empty() const { return points_.empty(); } > + size_t size() const { return points_.size(); } > + > Interval domain() const; > Interval range() const; >
Quoting Laurent Pinchart (2024-06-13 02:39:40) > Add a size() function to the Pwl class to return the number of points in > the piecewise linear function. This is useful, for instance, to validate > that all points added with append() or prepend() have been taken into > account. > Sounds fine to me. I expect there are some anticipated use of this in the future, but even still it's a reasonable and straightforward accessor. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/ipa/libipa/pwl.cpp | 6 ++++++ > src/ipa/libipa/pwl.h | 2 ++ > 2 files changed, 8 insertions(+) > > diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp > index d8ea92be0a86..8b437dd1a650 100644 > --- a/src/ipa/libipa/pwl.cpp > +++ b/src/ipa/libipa/pwl.cpp > @@ -188,6 +188,12 @@ void Pwl::prepend(double x, double y, const double eps) > * \return True if there are no points in the function, false otherwise > */ > > +/** > + * \fn Pwl::size() const > + * \brief Retrieve the number of points in the piecewise linear function > + * \return The number of points in the piecewise linear function > + */ > + > /** > * \brief Get the domain of the piecewise linear function > * \return An interval representing the domain > diff --git a/src/ipa/libipa/pwl.h b/src/ipa/libipa/pwl.h > index b4de00cf88f0..028342314fca 100644 > --- a/src/ipa/libipa/pwl.h > +++ b/src/ipa/libipa/pwl.h > @@ -52,6 +52,8 @@ public: > void append(double x, double y, double eps = 1e-6); > > bool empty() const { return points_.empty(); } > + size_t size() const { return points_.size(); } > + > Interval domain() const; > Interval range() const; > > -- > Regards, > > Laurent Pinchart >
diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp index d8ea92be0a86..8b437dd1a650 100644 --- a/src/ipa/libipa/pwl.cpp +++ b/src/ipa/libipa/pwl.cpp @@ -188,6 +188,12 @@ void Pwl::prepend(double x, double y, const double eps) * \return True if there are no points in the function, false otherwise */ +/** + * \fn Pwl::size() const + * \brief Retrieve the number of points in the piecewise linear function + * \return The number of points in the piecewise linear function + */ + /** * \brief Get the domain of the piecewise linear function * \return An interval representing the domain diff --git a/src/ipa/libipa/pwl.h b/src/ipa/libipa/pwl.h index b4de00cf88f0..028342314fca 100644 --- a/src/ipa/libipa/pwl.h +++ b/src/ipa/libipa/pwl.h @@ -52,6 +52,8 @@ public: void append(double x, double y, double eps = 1e-6); bool empty() const { return points_.empty(); } + size_t size() const { return points_.size(); } + Interval domain() const; Interval range() const;
Add a size() function to the Pwl class to return the number of points in the piecewise linear function. This is useful, for instance, to validate that all points added with append() or prepend() have been taken into account. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/ipa/libipa/pwl.cpp | 6 ++++++ src/ipa/libipa/pwl.h | 2 ++ 2 files changed, 8 insertions(+)