From patchwork Mon Nov 18 00:07:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 21946 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 885E6C32E7 for ; Mon, 18 Nov 2024 00:07:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F3D32658C2; Mon, 18 Nov 2024 01:07:57 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="J0MlWB+7"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 27C62658B7 for ; Mon, 18 Nov 2024 01:07:53 +0100 (CET) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BB73E8DB for ; Mon, 18 Nov 2024 01:07:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731888456; bh=zj0U/HE1hEYjvElrAo1U+PSICzRsAqaxIBvUOT/Ccpk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=J0MlWB+7rmbqI/AxuNgpDg+1WkfyQhuqp8c5nM6C1+1p+cZohDmqLC+UrfDDHjV7c z6wb62x99e9CrrCAns1u3Ws0aiQiKvP6h4tIXLg5JWNWPIxV3dFRjjPNyWHO62TIBb hbiFQJsyoENw3LBiODzRR/kG+uB39eV3xARu+z3I= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v2 04/12] ipa: libipa: vector: Rename the dot product operator*() to dot() Date: Mon, 18 Nov 2024 02:07:30 +0200 Message-ID: <20241118000738.18977-5-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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The Vector class defines a set of arithmetic operators between two vectors or a vector and a scalar. All the operators perform element-wise operations, except for the operator*() that computes the dot product. This is inconsistent and confusing. Replace the operator with a dot() function. Signed-off-by: Laurent Pinchart Reviewed-by: Milan Zamazal --- src/ipa/libipa/vector.cpp | 14 +++++++------- src/ipa/libipa/vector.h | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp index df089f8aed9f..b2794c200b05 100644 --- a/src/ipa/libipa/vector.cpp +++ b/src/ipa/libipa/vector.cpp @@ -85,13 +85,6 @@ namespace ipa { * \return The sum of the two vectors */ -/** - * \fn Vector::operator*(const Vector &other) const - * \brief Compute the dot product - * \param[in] other The other vector - * \return The dot product of the two vectors - */ - /** * \fn Vector::operator*(T factor) const * \brief Multiply the vector by a scalar @@ -106,6 +99,13 @@ namespace ipa { * \return The vector divided by \a factor */ +/** + * \fn Vector::dot(const Vector &other) const + * \brief Compute the dot product + * \param[in] other The other vector + * \return The dot product of the two vectors + */ + /** * \fn T &Vector::x() * \brief Convenience function to access the first element of the vector diff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h index 50e16250acfd..9dabdc28a540 100644 --- a/src/ipa/libipa/vector.h +++ b/src/ipa/libipa/vector.h @@ -90,14 +90,6 @@ public: return ret; } - constexpr T operator*(const Vector &other) const - { - T ret = 0; - for (unsigned int i = 0; i < Rows; i++) - ret += data_[i] * other[i]; - return ret; - } - constexpr Vector operator*(T factor) const { Vector ret; @@ -114,6 +106,14 @@ public: return ret; } + constexpr T dot(const Vector &other) const + { + T ret = 0; + for (unsigned int i = 0; i < Rows; i++) + ret += data_[i] * other[i]; + return ret; + } + #ifndef __DOXYGEN__ template= 1>> #endif /* __DOXYGEN__ */