[{"id":32263,"web_url":"https://patchwork.libcamera.org/comment/32263/","msgid":"<87cyirh66u.fsf@redhat.com>","date":"2024-11-19T10:24:41","subject":"Re: [PATCH v3 07/17] ipa: libipa: vector: Add missing binary\n\tarithemtic operators","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 multiple element-wise arithmetic operators\n> between vectors or between a vector and a scalar. A few variants are\n> missing. Add them.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\n\n> ---\n> Changes since v2:\n>\n> - Use std::plus, std::minus, std::multiplies and std::divides\n> ---\n>  src/ipa/libipa/vector.cpp | 54 +++++++++++++++++++++++++++++----------\n>  src/ipa/libipa/vector.h   | 38 ++++++++++++++++++++-------\n>  2 files changed, 70 insertions(+), 22 deletions(-)\n>\n> diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp\n> index 143ee9262f05..d8f7ce951d60 100644\n> --- a/src/ipa/libipa/vector.cpp\n> +++ b/src/ipa/libipa/vector.cpp\n> @@ -77,32 +77,60 @@ namespace ipa {\n>   * \\return The negated vector\n>   */\n>  \n> +/**\n> + * \\fn Vector::operator+(Vector const &other) const\n> + * \\brief Calculate the sum of this vector and \\a other element-wise\n> + * \\param[in] other The other vector\n> + * \\return The element-wise sum of this vector and \\a other\n> + */\n> +\n> +/**\n> + * \\fn Vector::operator+(T scalar) const\n> + * \\brief Calculate the sum of this vector and \\a scalar element-wise\n> + * \\param[in] scalar The scalar\n> + * \\return The element-wise sum of this vector and \\a other\n> + */\n> +\n>  /**\n>   * \\fn Vector::operator-(Vector const &other) const\n> - * \\brief Subtract one vector from another\n> + * \\brief Calculate the difference of this vector and \\a other element-wise\n>   * \\param[in] other The other vector\n> - * \\return The difference of \\a other from this vector\n> + * \\return The element-wise subtraction of \\a other from this vector\n>   */\n>  \n>  /**\n> - * \\fn Vector::operator+()\n> - * \\brief Add two vectors together\n> + * \\fn Vector::operator-(T scalar) const\n> + * \\brief Calculate the difference of this vector and \\a scalar element-wise\n> + * \\param[in] scalar The scalar\n> + * \\return The element-wise subtraction of \\a scalar from this vector\n> + */\n> +\n> +/**\n> + * \\fn Vector::operator*(const Vector &other) const\n> + * \\brief Calculate the product of this vector and \\a other element-wise\n>   * \\param[in] other The other vector\n> - * \\return The sum of the two vectors\n> + * \\return The element-wise product of this vector and \\a other\n>   */\n>  \n>  /**\n> - * \\fn Vector::operator*(T factor) const\n> - * \\brief Multiply the vector by a scalar\n> - * \\param[in] factor The factor\n> - * \\return The vector multiplied by \\a factor\n> + * \\fn Vector::operator*(T scalar) const\n> + * \\brief Calculate the product of this vector and \\a scalar element-wise\n> + * \\param[in] scalar The scalar\n> + * \\return The element-wise product of this vector and \\a scalar\n>   */\n>  \n>  /**\n> - * \\fn Vector::operator/()\n> - * \\brief Divide the vector by a scalar\n> - * \\param[in] factor The factor\n> - * \\return The vector divided by \\a factor\n> + * \\fn Vector::operator/(const Vector &other) const\n> + * \\brief Calculate the quotient of this vector and \\a other element-wise\n> + * \\param[in] other The other vector\n> + * \\return The element-wise division of this vector by \\a other\n> + */\n> +\n> +/**\n> + * \\fn Vector::operator/(T scalar) const\n> + * \\brief Calculate the quotient of this vector and \\a scalar element-wise\n> + * \\param[in] scalar The scalar\n> + * \\return The element-wise division of this vector by \\a scalar\n>   */\n>  \n>  /**\n> diff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h\n> index 76fd2934b870..88f2a03fe579 100644\n> --- a/src/ipa/libipa/vector.h\n> +++ b/src/ipa/libipa/vector.h\n> @@ -80,24 +80,44 @@ public:\n>  \t\treturn ret;\n>  \t}\n>  \n> -\tconstexpr Vector operator-(const Vector &other) const\n> -\t{\n> -\t\treturn apply(*this, other, std::minus<>{});\n> -\t}\n> -\n>  \tconstexpr Vector operator+(const Vector &other) const\n>  \t{\n>  \t\treturn apply(*this, other, std::plus<>{});\n>  \t}\n>  \n> -\tconstexpr Vector operator*(T factor) const\n> +\tconstexpr Vector operator+(T scalar) const\n>  \t{\n> -\t\treturn apply(*this, factor, std::multiplies<>{});\n> +\t\treturn apply(*this, scalar, std::plus<>{});\n>  \t}\n>  \n> -\tconstexpr Vector operator/(T factor) const\n> +\tconstexpr Vector operator-(const Vector &other) const\n>  \t{\n> -\t\treturn apply(*this, factor, std::divides<>{});\n> +\t\treturn apply(*this, other, std::minus<>{});\n> +\t}\n> +\n> +\tconstexpr Vector operator-(T scalar) const\n> +\t{\n> +\t\treturn apply(*this, scalar, std::minus<>{});\n> +\t}\n> +\n> +\tconstexpr Vector operator*(const Vector &other) const\n> +\t{\n> +\t\treturn apply(*this, other, std::multiplies<>{});\n> +\t}\n> +\n> +\tconstexpr Vector operator*(T scalar) const\n> +\t{\n> +\t\treturn apply(*this, scalar, std::multiplies<>{});\n> +\t}\n> +\n> +\tconstexpr Vector operator/(const Vector &other) const\n> +\t{\n> +\t\treturn apply(*this, other, std::divides<>{});\n> +\t}\n> +\n> +\tconstexpr Vector operator/(T scalar) const\n> +\t{\n> +\t\treturn apply(*this, scalar, std::divides<>{});\n>  \t}\n>  \n>  \tconstexpr T dot(const Vector<T, Rows> &other) const","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 CC2F5C326B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Nov 2024 10:24:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BD42165EEE;\n\tTue, 19 Nov 2024 11:24:49 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F6C36589D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Nov 2024 11:24:48 +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-110-fwiHrRiHMOSinC4oc908ug-1; Tue, 19 Nov 2024 05:24:45 -0500","by mail-wm1-f69.google.com with SMTP id\n\t5b1f17b1804b1-432d04b3d40so33251725e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Nov 2024 02:24:45 -0800 (PST)","from nuthatch ([2a00:102a:400a:489a:34bf:5bf1:e776:7185])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-432f64e7e12sm11794415e9.2.2024.11.19.02.24.42\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 19 Nov 2024 02:24:43 -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=\"B1thFeHk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1732011887;\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=VcUk/lDplki5RoAAPLGeOcgsFW0akj9pfGUT7MUzfUg=;\n\tb=B1thFeHkBLf6MC9wfvzzBmbHoWFt/8zXzbzPvzcJaFfYvAmB/8hMwTcuUlRr8yVEDUQJN2\n\t4UZwooO5mw4uvkhJeynx+3fiENDYpfnqs7wNABAqSTmRt1/XQEqkmdubrwJ0ARMb5Gvav0\n\tl/Bdro68g2Ex/7LEnUJV5qkc/VpXdVI=","X-MC-Unique":"fwiHrRiHMOSinC4oc908ug-1","X-Mimecast-MFC-AGG-ID":"fwiHrRiHMOSinC4oc908ug","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1732011884; x=1732616684;\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=VcUk/lDplki5RoAAPLGeOcgsFW0akj9pfGUT7MUzfUg=;\n\tb=LscdCqWwFZ6jFUAB0Eh922viZEASYdukFVV/wvZkJaJaF0LAJJn/fbYJNkMM51s44W\n\thhxP6vU/yChSoPtsC9hLiDxvZNEF0JoZTIsBnt2Jcd9corLEgMPob+f8XwdHMYteUeyt\n\tOWkgOJ4voUU4Ib9DrgwcyQ3ectEaYwyw/cjxRNuBTLoxTYf214A8o3CkjM0NqmSkj4Bf\n\tgXf2vNDCPrSj5uCpK+ERqgFbwcmL8LjfZlwPDwxwOrHOC6TGBkLbYZMKo9mtQ8PhgAYU\n\tRFse3aF6Uisps2Vo41uVItRNWLvieeENUj58JwHxTN0+HxVCCmMBHDGLfgSrNUF9wRuD\n\t3cmw==","X-Gm-Message-State":"AOJu0YxWQ4rYHWM6FItiAl30+EB0CcRrCOskwD8JGY0suymkNlmXzEsz\n\t96GFF7CGDlynCU7p1o+HvJm8gWWK4kSZFGpC8tmpNFc5kVd/jnd1narZdSrbEwGcBqnfPFtN2uC\n\tV/HwQ+/nr+1SCOawFi3SP1O9ic1sirCs/DKaSKiPaVVZueEfdJq8WHoSV0dO8m5gQO9JYfx80He\n\tvu9Kzi3XRNUoK/2V2Ofr6Iz3Yld8ObMyInqZt9XKFpPr1yoE0FT5q+6ww=","X-Received":["by 2002:a05:600c:35c8:b0:430:57f2:bae2 with SMTP id\n\t5b1f17b1804b1-432df791f62mr112043625e9.23.1732011884034; \n\tTue, 19 Nov 2024 02:24:44 -0800 (PST)","by 2002:a05:600c:35c8:b0:430:57f2:bae2 with SMTP id\n\t5b1f17b1804b1-432df791f62mr112043485e9.23.1732011883640; \n\tTue, 19 Nov 2024 02:24:43 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IH8RUrteomuqlCw4Wn7uWn6D3YV1qD+nCVIglb3OvIomLit5OFTzu5KbZ3HUbL3YoLRVkNAKA==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v3 07/17] ipa: libipa: vector: Add missing binary\n\tarithemtic operators","In-Reply-To":"<20241118221618.13953-8-laurent.pinchart@ideasonboard.com>\n\t(Laurent Pinchart's message of \"Tue, 19 Nov 2024 00:16:08 +0200\")","References":"<20241118221618.13953-1-laurent.pinchart@ideasonboard.com>\n\t<20241118221618.13953-8-laurent.pinchart@ideasonboard.com>","Date":"Tue, 19 Nov 2024 11:24:41 +0100","Message-ID":"<87cyirh66u.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":"xoUGifWMcPFVZU2sRuhN_ye_-bQfrXZBFioFeqqHNeM_1732011884","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>"}}]