[{"id":32247,"web_url":"https://patchwork.libcamera.org/comment/32247/","msgid":"<cq45uyG1hwODlDjPTlGO4frPYxVnnKg_B1tYcFw2-atKmHBK7Fu6DLMks3wKugkf6U9UjkpxWS4X4ltP39by_fPvSk8ic-n8jmt8Ylda_pE=@protonmail.com>","date":"2024-11-18T23:49:16","subject":"Re: [PATCH v3 03/17] ipa: libipa: vector: Add scalar constructor","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/people/133/","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"content":"Hi\n\n\n2024. november 18., hétfő 23:16 keltezéssel, Laurent Pinchart <laurent.pinchart@ideasonboard.com> írta:\n\n> The default constructor leaves the vector data uninitialized. Add a\n> constructor to fill the vector with copies of a scalar value, and fix\n> the documentation of the default constructor.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/ipa/libipa/vector.cpp | 8 +++++++-\n>  src/ipa/libipa/vector.h   | 5 +++++\n>  2 files changed, 12 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp\n> index f14f155216f3..d414ba97e41e 100644\n> --- a/src/ipa/libipa/vector.cpp\n> +++ b/src/ipa/libipa/vector.cpp\n> @@ -29,7 +29,13 @@ namespace ipa {\n> \n>  /**\n>   * \\fn Vector::Vector()\n> - * \\brief Construct a zero vector\n> + * \\brief Construct an uninitialized vector\n> + */\n> +\n> +/**\n> + * \\fn Vector::Vector(T scalar)\n> + * \\brief Construct a vector filled with a \\a scalar value\n> + * \\param[in] scalar The scalar value\n>   */\n> \n>  /**\n> diff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h\n> index b72ab9851aa3..be568eadfeac 100644\n> --- a/src/ipa/libipa/vector.h\n> +++ b/src/ipa/libipa/vector.h\n> @@ -35,6 +35,11 @@ class Vector\n>  public:\n>  \tconstexpr Vector() = default;\n> \n> +\tconstexpr Vector(T scalar)\n> +\t{\n> +\t\tdata_.fill(scalar);\n> +\t}\n> +\n\nIs there an expectation that e.g. `Vector<int, 3> x = 1` works? If not, then\nI think adding `explicit` would be something to consider to avoid erroneous\nconstruction from a scalar, especially in function calls.\n\n\nRegards,\nBarnabás Pőcze\n\n\n>  \tconstexpr Vector(const std::array<T, Rows> &data)\n>  \t{\n>  \t\tfor (unsigned int i = 0; i < Rows; i++)\n> --\n> Regards,\n> \n> Laurent Pinchart","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 B64EFC32EA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 18 Nov 2024 23:49:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6C6C8658FD;\n\tTue, 19 Nov 2024 00:49:23 +0100 (CET)","from mail-4316.protonmail.ch (mail-4316.protonmail.ch\n\t[185.70.43.16])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 46C586586D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Nov 2024 00:49:22 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"HRHMHVsm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1731973761; x=1732232961;\n\tbh=kbIpdjUXulHbcclu5xGj0WuR9FllX920xDwx5PBSKvE=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=HRHMHVsmJ/VVrthliji2BdxWWmfKW4BEa74TWBBh8wz9tmoUVkFw+6m5c/Dw8DSDE\n\tI895Ei2QYndQVVdcz8dcoXiWvDOtjwhL9+x4wHcMdgzciViKIuViWH5FuASRijzK2B\n\tITk2K29owXDRZW8YwLW6lcA/qmguvMSuVR9qKOkYPKRz6B9NhO5X0MyWrxzFhYcpCp\n\tOkOxMjM9U5lehx0jyPsO32vXJJNErH5r0HUYXfYBzMf7y4k6qFQw9uv4n7diHWRYv9\n\t93QXspT7tBxUbE/BjrPmcIzQTpYZoCUEIowjNGhbh7yF+y/BXZpmwK2ApVPzjItjgr\n\twZUG3QuLSQPoA==","Date":"Mon, 18 Nov 2024 23:49:16 +0000","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v3 03/17] ipa: libipa: vector: Add scalar constructor","Message-ID":"<cq45uyG1hwODlDjPTlGO4frPYxVnnKg_B1tYcFw2-atKmHBK7Fu6DLMks3wKugkf6U9UjkpxWS4X4ltP39by_fPvSk8ic-n8jmt8Ylda_pE=@protonmail.com>","In-Reply-To":"<20241118221618.13953-4-laurent.pinchart@ideasonboard.com>","References":"<20241118221618.13953-1-laurent.pinchart@ideasonboard.com>\n\t<20241118221618.13953-4-laurent.pinchart@ideasonboard.com>","Feedback-ID":"20568564:user:proton","X-Pm-Message-ID":"b0a0877a6428fd03ea23baf11752af8895fe535f","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","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":32253,"web_url":"https://patchwork.libcamera.org/comment/32253/","msgid":"<20241119083621.GC31681@pendragon.ideasonboard.com>","date":"2024-11-19T08:36:21","subject":"Re: [PATCH v3 03/17] ipa: libipa: vector: Add scalar constructor","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Mon, Nov 18, 2024 at 11:49:16PM +0000, Barnabás Pőcze wrote:\n> Hi\n> \n> \n> 2024. november 18., hétfő 23:16 keltezéssel, Laurent Pinchart <laurent.pinchart@ideasonboard.com> írta:\n> \n> > The default constructor leaves the vector data uninitialized. Add a\n> > constructor to fill the vector with copies of a scalar value, and fix\n> > the documentation of the default constructor.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/ipa/libipa/vector.cpp | 8 +++++++-\n> >  src/ipa/libipa/vector.h   | 5 +++++\n> >  2 files changed, 12 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp\n> > index f14f155216f3..d414ba97e41e 100644\n> > --- a/src/ipa/libipa/vector.cpp\n> > +++ b/src/ipa/libipa/vector.cpp\n> > @@ -29,7 +29,13 @@ namespace ipa {\n> > \n> >  /**\n> >   * \\fn Vector::Vector()\n> > - * \\brief Construct a zero vector\n> > + * \\brief Construct an uninitialized vector\n> > + */\n> > +\n> > +/**\n> > + * \\fn Vector::Vector(T scalar)\n> > + * \\brief Construct a vector filled with a \\a scalar value\n> > + * \\param[in] scalar The scalar value\n> >   */\n> > \n> >  /**\n> > diff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h\n> > index b72ab9851aa3..be568eadfeac 100644\n> > --- a/src/ipa/libipa/vector.h\n> > +++ b/src/ipa/libipa/vector.h\n> > @@ -35,6 +35,11 @@ class Vector\n> >  public:\n> >  \tconstexpr Vector() = default;\n> > \n> > +\tconstexpr Vector(T scalar)\n> > +\t{\n> > +\t\tdata_.fill(scalar);\n> > +\t}\n> > +\n> \n> Is there an expectation that e.g. `Vector<int, 3> x = 1` works? If not, then\n> I think adding `explicit` would be something to consider to avoid erroneous\n> construction from a scalar, especially in function calls.\n\nGood point. Will fix in v4.\n\n> >  \tconstexpr Vector(const std::array<T, Rows> &data)\n> >  \t{\n> >  \t\tfor (unsigned int i = 0; i < Rows; i++)","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 31DC0C326B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Nov 2024 08:36:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5753665ED8;\n\tTue, 19 Nov 2024 09:36:35 +0100 (CET)","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 CC9F365898\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Nov 2024 09:36:33 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DBE96D52;\n\tTue, 19 Nov 2024 09:36:14 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"MmTbTyNg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1732005375;\n\tbh=QuZxqhaUMTKFPuqKR8jBTZYkpBVt7YNdOBAhXxjRpMU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=MmTbTyNgze0P2VXMDpfagzeB21Ps2eVkUUM2/LZQJfU7vqMOfF8NvTja7LpTRuzmc\n\tFmGbYPR0Rmwr0RpTq5201FMUkUvkaXiIjH4o74o5NqqQWTpnlRuziFgMaxWatcPd/Y\n\taLbRntBiFGzKzZldqG80WDCnWtFwPEOSoGggrkmA=","Date":"Tue, 19 Nov 2024 10:36:21 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v3 03/17] ipa: libipa: vector: Add scalar constructor","Message-ID":"<20241119083621.GC31681@pendragon.ideasonboard.com>","References":"<20241118221618.13953-1-laurent.pinchart@ideasonboard.com>\n\t<20241118221618.13953-4-laurent.pinchart@ideasonboard.com>\n\t<cq45uyG1hwODlDjPTlGO4frPYxVnnKg_B1tYcFw2-atKmHBK7Fu6DLMks3wKugkf6U9UjkpxWS4X4ltP39by_fPvSk8ic-n8jmt8Ylda_pE=@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<cq45uyG1hwODlDjPTlGO4frPYxVnnKg_B1tYcFw2-atKmHBK7Fu6DLMks3wKugkf6U9UjkpxWS4X4ltP39by_fPvSk8ic-n8jmt8Ylda_pE=@protonmail.com>","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>"}}]