[{"id":34463,"web_url":"https://patchwork.libcamera.org/comment/34463/","msgid":"<174981078348.425770.9807175167600026739@ping.linuxembedded.co.uk>","date":"2025-06-13T10:33:03","subject":"Re: [PATCH v2 2/4] libipa: pwl: Improve documentation","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Paul,\n\nQuoting Stefan Klug (2025-06-13 11:09:37)\n> If a Pwl is evaluated outside of the domain, it gets extrapolated\n> linearly. Fix the documentation as it states otherwise.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/libipa/pwl.cpp | 15 +++++++--------\n>  1 file changed, 7 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp\n> index 3fa005ba92df..3d2188170d83 100644\n> --- a/src/ipa/libipa/pwl.cpp\n> +++ b/src/ipa/libipa/pwl.cpp\n> @@ -35,14 +35,13 @@ namespace ipa {\n>   *\n>   * https://en.wikipedia.org/wiki/Piecewise_linear_function\n>   *\n> - * A consequence of the Pwl class being defined by knots instead of linear\n> - * functions is that the values of the piecewise linear function past the ends\n> - * of the function are constants as opposed to linear functions. In a\n> - * mathematical piecewise linear function that is defined by multiple linear\n> - * functions, the ends of the function are also linear functions and hence grow\n> - * to infinity (or negative infinity). However, since this Pwl class is defined\n> - * by knots, the y-value of the leftmost and rightmost knots will hold for all\n> - * x values to negative infinity and positive infinity, respectively.\n> + * Outside the domain of the piecewise linear function the closest segment is\n> + * extrapolated linearly. If one wants to ensure that the returned values stay\n> + * within the range of the pwl, the input can be clamped:\n\nI remember working through some topics with you where I'm sure we were\npossibly relying on the fact that PWL would clip to the domain, and\nreturn the limits rather than continually extrapolating ...\n\nOr am I confusing something from the MatrixInterpolators perhaps?\n\nAny concerns or thoughts about this, or does it impact anything you\nmight have worked on?\n\n--\nKieran\n\n\n> + *\n> + * \\code{.cpp}\n> + * pwl.eval(pwl.domain().clip(x))\n> + * \\endcode\n>   */\n>  \n>  /**\n> -- \n> 2.48.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 459AABDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Jun 2025 10:33:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3805268DBE;\n\tFri, 13 Jun 2025 12:33:08 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 33F4568DB4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Jun 2025 12:33:06 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BDE5EED;\n\tFri, 13 Jun 2025 12:32:56 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"KxmCNPjm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1749810776;\n\tbh=8KKgyhLSQukPS6y9R6qA5zF+FhL0uAcb2jQPDyLjw4E=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=KxmCNPjmuUxu2MjdZI9LeOEVo+YUYjz9VepISlBEywpyxaFwFHO0co+ckZpQ2Ws7c\n\tVs705eB6VuxGekp0/hEEMdgYyLo/0qh4QmornHmGdpGbqa6h3NMNmOUyisZEn5h3F/\n\t3EvTNmRZ/woEtzUqRuS2TRmEBKZMOYo/SfcHwUZs=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250613100947.589875-3-stefan.klug@ideasonboard.com>","References":"<20250613100947.589875-1-stefan.klug@ideasonboard.com>\n\t<20250613100947.589875-3-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v2 2/4] libipa: pwl: Improve documentation","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org,\n\tPaul Elder <paul.elder@ideasonboard.com>, ","Date":"Fri, 13 Jun 2025 11:33:03 +0100","Message-ID":"<174981078348.425770.9807175167600026739@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":34600,"web_url":"https://patchwork.libcamera.org/comment/34600/","msgid":"<175068248378.159456.16837272120714426757@localhost>","date":"2025-06-23T12:41:23","subject":"Re: [PATCH v2 2/4] libipa: pwl: Improve documentation","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the review.\n\nQuoting Kieran Bingham (2025-06-13 12:33:03)\n> Hi Paul,\n> \n> Quoting Stefan Klug (2025-06-13 11:09:37)\n> > If a Pwl is evaluated outside of the domain, it gets extrapolated\n> > linearly. Fix the documentation as it states otherwise.\n> > \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> >  src/ipa/libipa/pwl.cpp | 15 +++++++--------\n> >  1 file changed, 7 insertions(+), 8 deletions(-)\n> > \n> > diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp\n> > index 3fa005ba92df..3d2188170d83 100644\n> > --- a/src/ipa/libipa/pwl.cpp\n> > +++ b/src/ipa/libipa/pwl.cpp\n> > @@ -35,14 +35,13 @@ namespace ipa {\n> >   *\n> >   * https://en.wikipedia.org/wiki/Piecewise_linear_function\n> >   *\n> > - * A consequence of the Pwl class being defined by knots instead of linear\n> > - * functions is that the values of the piecewise linear function past the ends\n> > - * of the function are constants as opposed to linear functions. In a\n> > - * mathematical piecewise linear function that is defined by multiple linear\n> > - * functions, the ends of the function are also linear functions and hence grow\n> > - * to infinity (or negative infinity). However, since this Pwl class is defined\n> > - * by knots, the y-value of the leftmost and rightmost knots will hold for all\n> > - * x values to negative infinity and positive infinity, respectively.\n> > + * Outside the domain of the piecewise linear function the closest segment is\n> > + * extrapolated linearly. If one wants to ensure that the returned values stay\n> > + * within the range of the pwl, the input can be clamped:\n> \n> I remember working through some topics with you where I'm sure we were\n> possibly relying on the fact that PWL would clip to the domain, and\n> return the limits rather than continually extrapolating ...\n> \n> Or am I confusing something from the MatrixInterpolators perhaps?\n> \n> Any concerns or thoughts about this, or does it impact anything you\n> might have worked on?\n\nAs we didn't hit an issue with the current (extrapolating) Pwls there\nmight be none. I remember talking about this but I can't remember\nspecifically where. And as there is an easy way to clamp, I think we\nshould go for this solution.\n\nBest regards,\nStefan\n\n> \n> --\n> Kieran\n> \n> \n> > + *\n> > + * \\code{.cpp}\n> > + * pwl.eval(pwl.domain().clip(x))\n> > + * \\endcode\n> >   */\n> >  \n> >  /**\n> > -- \n> > 2.48.1\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 21BA5BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jun 2025 12:41:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 32E6E68DE3;\n\tMon, 23 Jun 2025 14:41:28 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7749F68DC9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Jun 2025 14:41:26 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:8dc5:f4ae:2b23:86a3])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 98922D77;\n\tMon, 23 Jun 2025 14:41:09 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"C6KSY+KN\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750682469;\n\tbh=P4AU3AhbGOGhW/GEn67SF4uLHVuadccnANQfiQyxqlY=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=C6KSY+KN/Mg+42noaKukXk3U+IPKHqDPRoC3B6YACDUh9o5WbKx4q7W6Tt+cbDJP/\n\tuj83CE0Ata2QuTqjOqbRogqiw9J6xOCzMXzomXgpu0DaTPw+4us7KBk5Ya4Uv0dfdk\n\tBued7Ja1RmBtFJDQO47uvD4t4Ep+TcnKJk6MIfl4=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<174981078348.425770.9807175167600026739@ping.linuxembedded.co.uk>","References":"<20250613100947.589875-1-stefan.klug@ideasonboard.com>\n\t<20250613100947.589875-3-stefan.klug@ideasonboard.com>\n\t<174981078348.425770.9807175167600026739@ping.linuxembedded.co.uk>","Subject":"Re: [PATCH v2 2/4] libipa: pwl: Improve documentation","From":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 23 Jun 2025 14:41:23 +0200","Message-ID":"<175068248378.159456.16837272120714426757@localhost>","User-Agent":"alot/0.12.dev8+g2c003385c862.d20250602","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":34615,"web_url":"https://patchwork.libcamera.org/comment/34615/","msgid":"<175069040402.3871677.11319512060099107695@ping.linuxembedded.co.uk>","date":"2025-06-23T14:53:24","subject":"Re: [PATCH v2 2/4] libipa: pwl: Improve documentation","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-06-23 13:41:23)\n> Hi Kieran,\n> \n> Thank you for the review.\n> \n> Quoting Kieran Bingham (2025-06-13 12:33:03)\n> > Hi Paul,\n> > \n> > Quoting Stefan Klug (2025-06-13 11:09:37)\n> > > If a Pwl is evaluated outside of the domain, it gets extrapolated\n> > > linearly. Fix the documentation as it states otherwise.\n> > > \n> > > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > > ---\n> > >  src/ipa/libipa/pwl.cpp | 15 +++++++--------\n> > >  1 file changed, 7 insertions(+), 8 deletions(-)\n> > > \n> > > diff --git a/src/ipa/libipa/pwl.cpp b/src/ipa/libipa/pwl.cpp\n> > > index 3fa005ba92df..3d2188170d83 100644\n> > > --- a/src/ipa/libipa/pwl.cpp\n> > > +++ b/src/ipa/libipa/pwl.cpp\n> > > @@ -35,14 +35,13 @@ namespace ipa {\n> > >   *\n> > >   * https://en.wikipedia.org/wiki/Piecewise_linear_function\n> > >   *\n> > > - * A consequence of the Pwl class being defined by knots instead of linear\n> > > - * functions is that the values of the piecewise linear function past the ends\n> > > - * of the function are constants as opposed to linear functions. In a\n> > > - * mathematical piecewise linear function that is defined by multiple linear\n> > > - * functions, the ends of the function are also linear functions and hence grow\n> > > - * to infinity (or negative infinity). However, since this Pwl class is defined\n> > > - * by knots, the y-value of the leftmost and rightmost knots will hold for all\n> > > - * x values to negative infinity and positive infinity, respectively.\n> > > + * Outside the domain of the piecewise linear function the closest segment is\n> > > + * extrapolated linearly. If one wants to ensure that the returned values stay\n> > > + * within the range of the pwl, the input can be clamped:\n> > \n> > I remember working through some topics with you where I'm sure we were\n> > possibly relying on the fact that PWL would clip to the domain, and\n> > return the limits rather than continually extrapolating ...\n> > \n> > Or am I confusing something from the MatrixInterpolators perhaps?\n> > \n> > Any concerns or thoughts about this, or does it impact anything you\n> > might have worked on?\n> \n> As we didn't hit an issue with the current (extrapolating) Pwls there\n> might be none. I remember talking about this but I can't remember\n> specifically where. And as there is an easy way to clamp, I think we\n> should go for this solution.\n\nYes, now I see that we can clip/clamp I think this is fine - but I was\nasking Paul directly if this impacts anything he has worked on.\n\nI think I'm fine merging this though ...\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> Best regards,\n> Stefan\n> \n> > \n> > --\n> > Kieran\n> > \n> > \n> > > + *\n> > > + * \\code{.cpp}\n> > > + * pwl.eval(pwl.domain().clip(x))\n> > > + * \\endcode\n> > >   */\n> > >  \n> > >  /**\n> > > -- \n> > > 2.48.1\n> > >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 68F40C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jun 2025 14:53:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 991DF68DC9;\n\tMon, 23 Jun 2025 16:53:28 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BB2FD68DC9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Jun 2025 16:53:26 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E27DA6F3;\n\tMon, 23 Jun 2025 16:53:09 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"bZ6lLk8+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750690390;\n\tbh=kYlp1DlxukS9S/f1WYVpLebxngtcvaBsosJ0efTCmzk=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=bZ6lLk8+khf5hpC8MWK9ikJbuqOP9NUmeUFtZq5R1I+ypj9mW5a15PUCIV1G3hPV1\n\t8O4wOCl/WLun9WgQp05uAuKtW4oFrk6i7Vey5UfE2en+KytjvM/qSLc+TxM2FiEuvw\n\tvWTX1uX5M9W+bselISV0LKTh4+sqC2eQj2YydxnI=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<175068248378.159456.16837272120714426757@localhost>","References":"<20250613100947.589875-1-stefan.klug@ideasonboard.com>\n\t<20250613100947.589875-3-stefan.klug@ideasonboard.com>\n\t<174981078348.425770.9807175167600026739@ping.linuxembedded.co.uk>\n\t<175068248378.159456.16837272120714426757@localhost>","Subject":"Re: [PATCH v2 2/4] libipa: pwl: Improve documentation","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 23 Jun 2025 15:53:24 +0100","Message-ID":"<175069040402.3871677.11319512060099107695@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]