Patch Detail
Show a patch.
GET /api/patches/21935/?format=api
{ "id": 21935, "url": "https://patchwork.libcamera.org/api/patches/21935/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21935/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20241117221712.29616-6-laurent.pinchart@ideasonboard.com>", "date": "2024-11-17T22:17:06", "name": "[RFC,05/11] ipa: libipa: vector: Generalize arithmetic operators", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "4cbad9b241a66f68bf35ec9af3a312c036d8c555", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/21935/mbox/", "series": [ { "id": 4795, "url": "https://patchwork.libcamera.org/api/series/4795/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4795", "date": "2024-11-17T22:17:01", "name": "Improve linear algebra helpers in libipa", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4795/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21935/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21935/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 E08FFC32DD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 17 Nov 2024 22:17:43 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 614FB658AE;\n\tSun, 17 Nov 2024 23:17:43 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0924C658AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 17 Nov 2024 23:17:29 +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 AA5D37FE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 17 Nov 2024 23:17:12 +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=\"ixw6/TtK\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1731881832;\n\tbh=gU/DViUqdbRwz7vQMTvWxLxbGsGYNHcOZNJfvv/FUr0=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=ixw6/TtK9KIcFGXhYTih32yeRRXLSP+NPqptZTDm6R8r06qQS2RbW8x16Q8wmai7T\n\t3rz/EXwVE1zsKpkq6QSsvnbqDThQQS6mdGtoZuQBp3gT6qrsymeIZOsWyL6Os9IbaD\n\t5ocizDIeHY8NKRaCTWSBB/gbbsYKdkiRG4v3LUXM=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[RFC PATCH 05/11] ipa: libipa: vector: Generalize arithmetic\n\toperators", "Date": "Mon, 18 Nov 2024 00:17:06 +0200", "Message-ID": "<20241117221712.29616-6-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.45.2", "In-Reply-To": "<20241117221712.29616-1-laurent.pinchart@ideasonboard.com>", "References": "<20241117221712.29616-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": "Instead of hand-coding all arithmetic operators, implement them based on\na generic apply() function that takes an operator-specific\nstd::function. This will simplify adding missing arithmetic operators.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/libipa/vector.h | 48 ++++++++++++++++++++++++-----------------\n 1 file changed, 28 insertions(+), 20 deletions(-)", "diff": "diff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h\nindex 9dabdc28a540..8c4edfbaf85f 100644\n--- a/src/ipa/libipa/vector.h\n+++ b/src/ipa/libipa/vector.h\n@@ -74,36 +74,24 @@ public:\n \t\treturn ret;\n \t}\n \n-\tconstexpr Vector<T, Rows> operator-(const Vector<T, Rows> &other) const\n+\tconstexpr Vector operator-(const Vector &other) const\n \t{\n-\t\tVector<T, Rows> ret;\n-\t\tfor (unsigned int i = 0; i < Rows; i++)\n-\t\t\tret[i] = data_[i] - other[i];\n-\t\treturn ret;\n+\t\treturn apply(*this, other, [](T a, T b) { return a - b; });\n \t}\n \n-\tconstexpr Vector<T, Rows> operator+(const Vector<T, Rows> &other) const\n+\tconstexpr Vector operator+(const Vector &other) const\n \t{\n-\t\tVector<T, Rows> ret;\n-\t\tfor (unsigned int i = 0; i < Rows; i++)\n-\t\t\tret[i] = data_[i] + other[i];\n-\t\treturn ret;\n+\t\treturn apply(*this, other, [](T a, T b) { return a + b; });\n \t}\n \n-\tconstexpr Vector<T, Rows> operator*(T factor) const\n+\tconstexpr Vector operator*(T factor) const\n \t{\n-\t\tVector<T, Rows> ret;\n-\t\tfor (unsigned int i = 0; i < Rows; i++)\n-\t\t\tret[i] = data_[i] * factor;\n-\t\treturn ret;\n+\t\treturn apply(*this, factor, [](T a, T b) { return a * b; });\n \t}\n \n-\tconstexpr Vector<T, Rows> operator/(T factor) const\n+\tconstexpr Vector operator/(T factor) const\n \t{\n-\t\tVector<T, Rows> ret;\n-\t\tfor (unsigned int i = 0; i < Rows; i++)\n-\t\t\tret[i] = data_[i] / factor;\n-\t\treturn ret;\n+\t\treturn apply(*this, factor, [](T a, T b) { return a / b; });\n \t}\n \n \tconstexpr T dot(const Vector<T, Rows> &other) const\n@@ -178,6 +166,26 @@ public:\n \t}\n \n private:\n+\tstatic constexpr Vector apply(const Vector &lhs, const Vector &rhs, std::function<T(T, T)> func)\n+\t{\n+\t\tVector result;\n+\t\tstd::transform(lhs.data_.begin(), lhs.data_.end(),\n+\t\t\t rhs.data_.begin(), result.data_.begin(),\n+\t\t\t func);\n+\n+\t\treturn result;\n+\t}\n+\n+\tstatic constexpr Vector apply(const Vector &lhs, T rhs, std::function<T(T, T)> func)\n+\t{\n+\t\tVector result;\n+\t\tstd::transform(lhs.data_.begin(), lhs.data_.end(),\n+\t\t\t result.data_.begin(),\n+\t\t\t [&func, rhs](T v) { return func(v, rhs); });\n+\n+\t\treturn result;\n+\t}\n+\n \tstd::array<T, Rows> data_;\n };\n \n", "prefixes": [ "RFC", "05/11" ] }