{"id":21999,"url":"https://patchwork.libcamera.org/api/patches/21999/?format=json","web_url":"https://patchwork.libcamera.org/patch/21999/","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":"<20241119121928.30939-2-laurent.pinchart@ideasonboard.com>","date":"2024-11-19T12:19:12","name":"[v4,01/17] ipa: libipa: vector: Add mutable x(), y() and z() accessors","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"ef1cd7d0dc772ec7b97bdaffa1f8e0b61e798f69","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/21999/mbox/","series":[{"id":4804,"url":"https://patchwork.libcamera.org/api/series/4804/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4804","date":"2024-11-19T12:19:11","name":"Improve linear algebra helpers in libipa","version":4,"mbox":"https://patchwork.libcamera.org/series/4804/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21999/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21999/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 3A5AAC32F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Nov 2024 12:19:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6661765F14;\n\tTue, 19 Nov 2024 13:19:47 +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 8918B658A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Nov 2024 13:19:44 +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 EE2D93A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Nov 2024 13:19:25 +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=\"O7NrmZJy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1732018766;\n\tbh=lJueRwBNzjpiJQlhtcpN480w+7bcg8ejQDd/rX8HRXY=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=O7NrmZJymW+3BVo8MO1ZRIvoK0qAoDRU/wNzkOl5bTb3Hi6d2Mk5GBIqQTqKHT/Tz\n\tbjdrB1bcy456v6Wvxzpduv9GvwRpZ1YqbBlUqoRXSSXJotLYr7yuWzHMaPfPbGadk+\n\tzzoLZTPjLx4ZdJKeLvr00xoa8w3mEu7XKxMgRTXo=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v4 01/17] ipa: libipa: vector: Add mutable x(),\n\ty() and z() accessors","Date":"Tue, 19 Nov 2024 14:19:12 +0200","Message-ID":"<20241119121928.30939-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.45.2","In-Reply-To":"<20241119121928.30939-1-laurent.pinchart@ideasonboard.com>","References":"<20241119121928.30939-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":"The x(), y() and z() functions of the Vector class are convenience\naccessors for the first, second and third element of the vector\nrespectively, meant to improve readability of class users when a vector\nrepresents coordinates in 1D, 2D or 3D space. Those accessors are\nlimited to immutable access to the vector elements, as they return a\ncopy. Extend the API with mutable accessors.\n\nThe immutable accessors are modified to return a reference to the vector\nelements instead of a copy for consistency. As they are inline\nfunctions, this should make no difference in terms of performance as the\ncompiler can perform the same optimizations in their case.\n\nWhile at it, reorder functions to declare operators before other member\nfunctions, to be consistent with the usual coding style.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\n---\nChanges since v3:\n\n- Make non-const accessors constexpr\n---\n src/ipa/libipa/vector.cpp | 51 +++++++++++++++++++++++++--------------\n src/ipa/libipa/vector.h   | 49 +++++++++++++++++++------------------\n 2 files changed, 58 insertions(+), 42 deletions(-)","diff":"diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp\nindex bd00b01961d5..b650fcc1fe35 100644\n--- a/src/ipa/libipa/vector.cpp\n+++ b/src/ipa/libipa/vector.cpp\n@@ -52,24 +52,6 @@ namespace ipa {\n  * \\copydoc Vector::operator[](size_t i) const\n  */\n \n-/**\n- * \\fn Vector::x()\n- * \\brief Convenience function to access the first element of the vector\n- * \\return The first element of the vector\n- */\n-\n-/**\n- * \\fn Vector::y()\n- * \\brief Convenience function to access the second element of the vector\n- * \\return The second element of the vector\n- */\n-\n-/**\n- * \\fn Vector::z()\n- * \\brief Convenience function to access the third element of the vector\n- * \\return The third element of the vector\n- */\n-\n /**\n  * \\fn Vector::operator-() const\n  * \\brief Negate a Vector by negating both all of its coordinates\n@@ -111,6 +93,39 @@ namespace ipa {\n  * \\return The vector divided by \\a factor\n  */\n \n+/**\n+ * \\fn constexpr T &Vector::x()\n+ * \\brief Convenience function to access the first element of the vector\n+ * \\return The first element of the vector\n+ */\n+\n+/**\n+ * \\fn constexpr T &Vector::y()\n+ * \\brief Convenience function to access the second element of the vector\n+ * \\return The second element of the vector\n+ */\n+\n+/**\n+ * \\fn constexpr T &Vector::z()\n+ * \\brief Convenience function to access the third element of the vector\n+ * \\return The third element of the vector\n+ */\n+\n+/**\n+ * \\fn constexpr const T &Vector::x() const\n+ * \\copydoc Vector::x()\n+ */\n+\n+/**\n+ * \\fn constexpr const T &Vector::y() const\n+ * \\copydoc Vector::y()\n+ */\n+\n+/**\n+ * \\fn constexpr const T &Vector::z() const\n+ * \\copydoc Vector::z()\n+ */\n+\n /**\n  * \\fn Vector::length2()\n  * \\brief Get the squared length of the vector\ndiff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h\nindex 8612a06a2ab2..b91e50b2e0ca 100644\n--- a/src/ipa/libipa/vector.h\n+++ b/src/ipa/libipa/vector.h\n@@ -53,30 +53,6 @@ public:\n \t\treturn data_[i];\n \t}\n \n-#ifndef __DOXYGEN__\n-\ttemplate<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 1>>\n-#endif /* __DOXYGEN__ */\n-\tconstexpr T x() const\n-\t{\n-\t\treturn data_[0];\n-\t}\n-\n-#ifndef __DOXYGEN__\n-\ttemplate<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 2>>\n-#endif /* __DOXYGEN__ */\n-\tconstexpr T y() const\n-\t{\n-\t\treturn data_[1];\n-\t}\n-\n-#ifndef __DOXYGEN__\n-\ttemplate<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 3>>\n-#endif /* __DOXYGEN__ */\n-\tconstexpr T z() const\n-\t{\n-\t\treturn data_[2];\n-\t}\n-\n \tconstexpr Vector<T, Rows> operator-() const\n \t{\n \t\tVector<T, Rows> ret;\n@@ -125,6 +101,31 @@ public:\n \t\treturn ret;\n \t}\n \n+#ifndef __DOXYGEN__\n+\ttemplate<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 1>>\n+#endif /* __DOXYGEN__ */\n+\tconstexpr const T &x() const { return data_[0]; }\n+#ifndef __DOXYGEN__\n+\ttemplate<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 2>>\n+#endif /* __DOXYGEN__ */\n+\tconstexpr const T &y() const { return data_[1]; }\n+#ifndef __DOXYGEN__\n+\ttemplate<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 3>>\n+#endif /* __DOXYGEN__ */\n+\tconstexpr const T &z() const { return data_[2]; }\n+#ifndef __DOXYGEN__\n+\ttemplate<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 1>>\n+#endif /* __DOXYGEN__ */\n+\tconstexpr T &x() { return data_[0]; }\n+#ifndef __DOXYGEN__\n+\ttemplate<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 2>>\n+#endif /* __DOXYGEN__ */\n+\tconstexpr T &y() { return data_[1]; }\n+#ifndef __DOXYGEN__\n+\ttemplate<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 3>>\n+#endif /* __DOXYGEN__ */\n+\tconstexpr T &z() { return data_[2]; }\n+\n \tconstexpr double length2() const\n \t{\n \t\tdouble ret = 0;\n","prefixes":["v4","01/17"]}