{"id":21949,"url":"https://patchwork.libcamera.org/api/patches/21949/?format=json","web_url":"https://patchwork.libcamera.org/patch/21949/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20241118000738.18977-8-laurent.pinchart@ideasonboard.com>","date":"2024-11-18T00:07:33","name":"[RFC,v2,07/12] ipa: libipa: vector: Add compound assignment operators","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"a8de969b5efa6a05a229234a1e34a7af65816f03","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21949/mbox/","series":[{"id":4796,"url":"https://patchwork.libcamera.org/api/series/4796/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4796","date":"2024-11-18T00:07:26","name":"Improve linear algebra helpers in libipa","version":2,"mbox":"https://patchwork.libcamera.org/series/4796/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21949/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21949/checks/","tags":{},"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 1DFE6C32EF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 18 Nov 2024 00:08:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C0A09658CF;\n\tMon, 18 Nov 2024 01:08:06 +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 38795658C1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Nov 2024 01:07:57 +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 CDC5875A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Nov 2024 01:07:40 +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=\"j0hvTAcs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1731888461;\n\tbh=QAK/S9gwY82aAY8vm9NzdTqTdsAVd/YdIyvamp2bUBM=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=j0hvTAcsNeqYFQL8BYQPoO82KszA2fDzth1ffgSAdS0JJG2+ZRdoX2eCUYKFoALTc\n\tfkrz3vClAzrd8l2brc7lcQU3kRn+xOi5WDprZ0CuWneiC8TM8NVeNhgcFYoVyQ54G7\n\tSKH6OpOoVxZGAekDfv2GsKOvxqWOT2+KFgSUAUqY=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[RFC PATCH v2 07/12] ipa: libipa: vector: Add compound assignment\n\toperators","Date":"Mon, 18 Nov 2024 02:07:33 +0200","Message-ID":"<20241118000738.18977-8-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.45.2","In-Reply-To":"<20241118000738.18977-1-laurent.pinchart@ideasonboard.com>","References":"<20241118000738.18977-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"Extend the Vector class with compound assignment operators that match\nthe binary arithmetic operators.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/libipa/vector.cpp | 56 ++++++++++++++++++++++++++++++++++++++\n src/ipa/libipa/vector.h   | 57 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 113 insertions(+)","diff":"diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp\nindex d0e38f402220..a45f08fde493 100644\n--- a/src/ipa/libipa/vector.cpp\n+++ b/src/ipa/libipa/vector.cpp\n@@ -127,6 +127,62 @@ namespace ipa {\n  * \\return The element-wise division of this vector by \\a scalar\n  */\n \n+/**\n+ * \\fn Vector::operator+=(Vector const &other)\n+ * \\brief Add \\a other element-wise to this vector\n+ * \\param[in] other The other vector\n+ * \\return This vector\n+ */\n+\n+/**\n+ * \\fn Vector::operator+=(T scalar)\n+ * \\brief Add \\a scalar element-wise to this vector\n+ * \\param[in] scalar The scalar\n+ * \\return This vector\n+ */\n+\n+/**\n+ * \\fn Vector::operator-=(Vector const &other)\n+ * \\brief Subtract \\a other element-wise from this vector\n+ * \\param[in] other The other vector\n+ * \\return This vector\n+ */\n+\n+/**\n+ * \\fn Vector::operator-=(T scalar)\n+ * \\brief Subtract \\a scalar element-wise from this vector\n+ * \\param[in] scalar The scalar\n+ * \\return This vector\n+ */\n+\n+/**\n+ * \\fn Vector::operator*=(const Vector &other)\n+ * \\brief Multiply this vector by \\a other element-wise\n+ * \\param[in] other The other vector\n+ * \\return This vector\n+ */\n+\n+/**\n+ * \\fn Vector::operator*=(T scalar)\n+ * \\brief Multiply this vector by \\a scalar element-wise\n+ * \\param[in] scalar The scalar\n+ * \\return This vector\n+ */\n+\n+/**\n+ * \\fn Vector::operator/=(const Vector &other)\n+ * \\brief Divide this vector by \\a other element-wise\n+ * \\param[in] other The other vector\n+ * \\return This vector\n+ */\n+\n+/**\n+ * \\fn Vector::operator/=(T scalar)\n+ * \\brief Divide this vector by \\a scalar element-wise\n+ * \\param[in] scalar The scalar\n+ * \\return This vector\n+ */\n+\n /**\n  * \\fn Vector::dot(const Vector<T, Rows> &other) const\n  * \\brief Compute the dot product\ndiff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h\nindex dda49b1f468b..722ffc57ea45 100644\n--- a/src/ipa/libipa/vector.h\n+++ b/src/ipa/libipa/vector.h\n@@ -114,6 +114,46 @@ public:\n \t\treturn apply(*this, scalar, [](T a, T b) { return a / b; });\n \t}\n \n+\tVector &operator+=(const Vector &other)\n+\t{\n+\t\treturn apply(other, [](T a, T b) { return a + b; });\n+\t}\n+\n+\tVector &operator+=(T scalar)\n+\t{\n+\t\treturn apply(scalar, [](T a, T b) { return a + b; });\n+\t}\n+\n+\tVector &operator-=(const Vector &other)\n+\t{\n+\t\treturn apply(other, [](T a, T b) { return a - b; });\n+\t}\n+\n+\tVector &operator-=(T scalar)\n+\t{\n+\t\treturn apply(scalar, [](T a, T b) { return a - b; });\n+\t}\n+\n+\tVector &operator*=(const Vector &other)\n+\t{\n+\t\treturn apply(other, [](T a, T b) { return a * b; });\n+\t}\n+\n+\tVector &operator*=(T scalar)\n+\t{\n+\t\treturn apply(scalar, [](T a, T b) { return a * b; });\n+\t}\n+\n+\tVector &operator/=(const Vector &other)\n+\t{\n+\t\treturn apply(other, [](T a, T b) { return a / b; });\n+\t}\n+\n+\tVector &operator/=(T scalar)\n+\t{\n+\t\treturn apply(scalar, [](T a, T b) { return a / b; });\n+\t}\n+\n \tconstexpr T dot(const Vector<T, Rows> &other) const\n \t{\n \t\tT ret = 0;\n@@ -206,6 +246,23 @@ private:\n \t\treturn result;\n \t}\n \n+\tVector &apply(const Vector &other, std::function<T(T, T)> func)\n+\t{\n+\t\tauto itOther = other.data_.begin();\n+\t\tstd::for_each(data_.begin(), data_.end(),\n+\t\t\t      [&func, &itOther](T &v) { v = func(v, *itOther++); });\n+\n+\t\treturn *this;\n+\t}\n+\n+\tVector &apply(T scalar, std::function<T(T, T)> func)\n+\t{\n+\t\tstd::for_each(data_.begin(), data_.end(),\n+\t\t\t      [&func, scalar](T &v) { v = func(v, scalar); });\n+\n+\t\treturn *this;\n+\t}\n+\n \tstd::array<T, Rows> data_;\n };\n \n","prefixes":["RFC","v2","07/12"]}