[{"id":32218,"web_url":"https://patchwork.libcamera.org/comment/32218/","msgid":"<87jzd0iusm.fsf@redhat.com>","date":"2024-11-18T12:35:37","subject":"Re: [RFC PATCH v2 04/12] ipa: libipa: vector: Rename the dot\n\tproduct operator*() to dot()","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Laurent Pinchart <laurent.pinchart@ideasonboard.com> writes:\n\n> The Vector class defines a set of arithmetic operators between two\n> vectors or a vector and a scalar. All the operators perform element-wise\n> operations, except for the operator*() that computes the dot product.\n> This is inconsistent and confusing. \n\nI would expect it to be a dot product.  But indeed, while Emacs Calc\ncomputes a dot product, Maxima computes a vector, so it's better to\navoid confusions.\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\n\n> Replace the operator with a dot() function.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/ipa/libipa/vector.cpp | 14 +++++++-------\n>  src/ipa/libipa/vector.h   | 16 ++++++++--------\n>  2 files changed, 15 insertions(+), 15 deletions(-)\n>\n> diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp\n> index df089f8aed9f..b2794c200b05 100644\n> --- a/src/ipa/libipa/vector.cpp\n> +++ b/src/ipa/libipa/vector.cpp\n> @@ -85,13 +85,6 @@ namespace ipa {\n>   * \\return The sum of the two vectors\n>   */\n>  \n> -/**\n> - * \\fn Vector::operator*(const Vector<T, Rows> &other) const\n> - * \\brief Compute the dot product\n> - * \\param[in] other The other vector\n> - * \\return The dot product of the two vectors\n> - */\n> -\n>  /**\n>   * \\fn Vector::operator*(T factor) const\n>   * \\brief Multiply the vector by a scalar\n> @@ -106,6 +99,13 @@ namespace ipa {\n>   * \\return The vector divided by \\a factor\n>   */\n>  \n> +/**\n> + * \\fn Vector::dot(const Vector<T, Rows> &other) const\n> + * \\brief Compute the dot product\n> + * \\param[in] other The other vector\n> + * \\return The dot product of the two vectors\n> + */\n> +\n>  /**\n>   * \\fn T &Vector::x()\n>   * \\brief Convenience function to access the first element of the vector\n> diff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h\n> index 50e16250acfd..9dabdc28a540 100644\n> --- a/src/ipa/libipa/vector.h\n> +++ b/src/ipa/libipa/vector.h\n> @@ -90,14 +90,6 @@ public:\n>  \t\treturn ret;\n>  \t}\n>  \n> -\tconstexpr T operator*(const Vector<T, Rows> &other) const\n> -\t{\n> -\t\tT ret = 0;\n> -\t\tfor (unsigned int i = 0; i < Rows; i++)\n> -\t\t\tret += data_[i] * other[i];\n> -\t\treturn ret;\n> -\t}\n> -\n>  \tconstexpr Vector<T, Rows> operator*(T factor) const\n>  \t{\n>  \t\tVector<T, Rows> ret;\n> @@ -114,6 +106,14 @@ public:\n>  \t\treturn ret;\n>  \t}\n>  \n> +\tconstexpr T dot(const Vector<T, Rows> &other) const\n> +\t{\n> +\t\tT ret = 0;\n> +\t\tfor (unsigned int i = 0; i < Rows; i++)\n> +\t\t\tret += data_[i] * other[i];\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__ */","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 A4DB4C32EA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 18 Nov 2024 12:35:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C926D658CF;\n\tMon, 18 Nov 2024 13:35:45 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E7A68658C1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Nov 2024 13:35:43 +0100 (CET)","from mail-wm1-f69.google.com (mail-wm1-f69.google.com\n\t[209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-681-J5sS4i7gPOi7cTjNeqlNOQ-1; Mon, 18 Nov 2024 07:35:41 -0500","by mail-wm1-f69.google.com with SMTP id\n\t5b1f17b1804b1-4314f1e0f2bso14578575e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Nov 2024 04:35:41 -0800 (PST)","from nuthatch ([2a00:102a:400a:489a:ffe9:aa41:63cd:fc2b])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-432da28b76fsm161192665e9.28.2024.11.18.04.35.38\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 18 Nov 2024 04:35:39 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"jBFoDgrx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1731933342;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=l8m4MtWuXonZg+R4yJVNfik87LM72ysE81fp8UX2CCQ=;\n\tb=jBFoDgrxKxf2PqnID7SLrCKwcDU4rfJsLeBFdFAONUZ6yC9cjJoD871G9Q9DKhTihOnEW9\n\tu8l9avd7tlQjXj2kARg/EugSiuUfeXoejRIHiN0+sFae+5CKj38mbKfEEo/Iux6NE1fJcE\n\tQU81e4kyp/P2Y6V9MWW3QFkeEvF8vHc=","X-MC-Unique":"J5sS4i7gPOi7cTjNeqlNOQ-1","X-Mimecast-MFC-AGG-ID":"J5sS4i7gPOi7cTjNeqlNOQ","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1731933340; x=1732538140;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=l8m4MtWuXonZg+R4yJVNfik87LM72ysE81fp8UX2CCQ=;\n\tb=TiQjY43jCohWrtXSBR1TiVUNiBwChU2xvO3lsWTWY/Q74tnKc9AsD0dMrz/OUhDfLo\n\t2GNPwnjH9BV7f1sghO30SxmCyvOyvXp0DZB3AO6y21afMyY6TuxVFiaJjrg0SAP9lwj2\n\txsdzt/xtcGiUXywihqiLWGp0fR0q4salpzix4mIWe9F9yg4iOrGRLcyRWLxNbshgkyO+\n\tCFiE/GBkJHJibl0xJKWUj+pQVXs4pCol4z5MHVzT0/hSt4B2prXDy0XJl1/nitziLw0q\n\tB3AQlu2TJbINXVKzKyhy021I/KqWCR+ZaIteAMGpu5H8lb21xte+6hTcAJZGcWkX6Ogo\n\tpeQw==","X-Gm-Message-State":"AOJu0YxzNtZwRbDo57Taj36i9gHy6JgbFgNEVz4ElPGkm6hHaqFJeTFN\n\tV0dzUojNl+J27k6NXypYxb+XNPUykJo5cQa8h6rOFhunO0hB5vMfvsP/ypHXJvqc7a4CRsP05Pa\n\tXP5eR+bHQR5To6fbjIJE1VQydxU5C4Od7GkEPtZMzxppnoXFHMOWCANmveaKzFzrNfPpBPMDDx8\n\t3IhDybSLSCdtiMSFIedmramsGDB+jLc/bTFFY8/GokrktR0+fDvly5Z0E=","X-Received":["by 2002:a05:600c:6987:b0:431:5aea:95f with SMTP id\n\t5b1f17b1804b1-432eafa1837mr56684495e9.16.1731933340108; \n\tMon, 18 Nov 2024 04:35:40 -0800 (PST)","by 2002:a05:600c:6987:b0:431:5aea:95f with SMTP id\n\t5b1f17b1804b1-432eafa1837mr56684255e9.16.1731933339705; \n\tMon, 18 Nov 2024 04:35:39 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IE7r9fXooov4utsTMx2p0GrNEOGIh52edkeHSOn6UPMrPd8Hd1BsQkeq+/Mo34SHUvZ/Qv9jg==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v2 04/12] ipa: libipa: vector: Rename the dot\n\tproduct operator*() to dot()","In-Reply-To":"<20241118000738.18977-5-laurent.pinchart@ideasonboard.com>\n\t(Laurent Pinchart's message of \"Mon, 18 Nov 2024 02:07:30 +0200\")","References":"<20241118000738.18977-1-laurent.pinchart@ideasonboard.com>\n\t<20241118000738.18977-5-laurent.pinchart@ideasonboard.com>","Date":"Mon, 18 Nov 2024 13:35:37 +0100","Message-ID":"<87jzd0iusm.fsf@redhat.com>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"ZIkzRyGnzi-EFRT3h_F46x5swk3nGIvna99MpmZgiKA_1731933340","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>"}}]