Patch Detail
Show a patch.
GET /api/patches/21939/?format=api
{ "id": 21939, "url": "https://patchwork.libcamera.org/api/patches/21939/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21939/", "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-10-laurent.pinchart@ideasonboard.com>", "date": "2024-11-17T22:17:10", "name": "[RFC,09/11] ipa: libipa: vector: Add sum() and normalize() functions", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "6df62ae2c9a1cc3ffd52691c5cd4cf3bb332a8ab", "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/21939/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/21939/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21939/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 AC06FC32DD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 17 Nov 2024 22:17:50 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 410FF658C3;\n\tSun, 17 Nov 2024 23:17:50 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 679B7658B7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 17 Nov 2024 23:17:34 +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 16E2CA06\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 17 Nov 2024 23:17:18 +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=\"DVb2nMUc\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1731881838;\n\tbh=N4kymlvsO1kcNz1aPnJKStzldZ5qZz+nrHimPlV+m0s=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=DVb2nMUcdCScR0VPpWwSNBNoeLWIvPfBJN5qiGfhghOY2CBeSShVyUHqCnnYvZrFz\n\tYP9WCHNMhvEZrVC716HmJz0PYGB76zkzfpRCB5bUWx1KL4MGLhFHmz2IbJi3OEsr9E\n\tUfyLe3rSLtP7aOFcTKea30E7nyx+Elulhvsk+fCI=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[RFC PATCH 09/11] ipa: libipa: vector: Add sum() and normalize()\n\tfunctions", "Date": "Mon, 18 Nov 2024 00:17:10 +0200", "Message-ID": "<20241117221712.29616-10-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": "Add functions to calculate the sum of a vector, and to normalize it.\nThey are useful for algorithms.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/libipa/vector.cpp | 17 +++++++++++++++++\n src/ipa/libipa/vector.h | 12 ++++++++++++\n 2 files changed, 29 insertions(+)", "diff": "diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp\nindex 14816cdb5d09..0662e598c086 100644\n--- a/src/ipa/libipa/vector.cpp\n+++ b/src/ipa/libipa/vector.cpp\n@@ -296,6 +296,23 @@ namespace ipa {\n * \\return The length of the vector\n */\n \n+/**\n+ * \\fn Vector::normalize()\n+ * \\brief Normalize the vector\n+ */\n+\n+/**\n+ * \\fn Vector::sum() const\n+ * \\brief Calculate the sum of all the vector elements\n+ * \\tparam R The type of the sum\n+ *\n+ * The type R of the sum defaults to the type T of the elements, but can be set\n+ * explicitly to use a different type in case the type T would risk\n+ * overflowing.\n+ *\n+ * \\return The sum of all the vector elements\n+ */\n+\n /**\n * \\fn Vector<T, Rows> operator*(const Matrix<T, Rows, Cols> &m, const Vector<T, Cols> &v)\n * \\brief Multiply a matrix by a vector\ndiff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h\nindex 949dc4650aa4..b3a6412497c9 100644\n--- a/src/ipa/libipa/vector.h\n+++ b/src/ipa/libipa/vector.h\n@@ -9,6 +9,7 @@\n #include <algorithm>\n #include <array>\n #include <cmath>\n+#include <numeric>\n #include <optional>\n #include <ostream>\n \n@@ -245,6 +246,17 @@ public:\n \t\treturn std::sqrt(length2());\n \t}\n \n+\tvoid normalize()\n+\t{\n+\t\t*this /= sum();\n+\t}\n+\n+\ttemplate<typename R = T>\n+\tconstexpr R sum() const\n+\t{\n+\t\treturn std::accumulate(data_.begin(), data_.end(), R{});\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", "prefixes": [ "RFC", "09/11" ] }