[{"id":29957,"web_url":"https://patchwork.libcamera.org/comment/29957/","msgid":"<20240616164720.GA25491@pendragon.ideasonboard.com>","date":"2024-06-16T16:47:20","subject":"Re: [PATCH v3] ipa: libipa: vector: Add matrix-vector multiplication","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Fri, Jun 14, 2024 at 09:02:11PM +0900, Paul Elder wrote:\n> Add an operation for multiplying a matrix with a vector.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> ---\n> Changes in v3:\n> - make SFINAE more concise\n> \n> Changes in v2:\n> - s/D/Rows/ in Vector class\n> \n> Depends on v9 of \"ipa: libipa: Add Matrix class\"\n> ---\n>  src/ipa/libipa/vector.cpp | 11 +++++++++++\n>  src/ipa/libipa/vector.h   | 19 +++++++++++++++++++\n>  2 files changed, 30 insertions(+)\n> \n> diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp\n> index b071b261b9c4..bd00b01961d5 100644\n> --- a/src/ipa/libipa/vector.cpp\n> +++ b/src/ipa/libipa/vector.cpp\n> @@ -123,6 +123,17 @@ namespace ipa {\n>   * \\return The length of the vector\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\n> + * \\tparam T Numerical type of the contents of the matrix and vector\n> + * \\tparam Rows The number of rows in the matrix\n> + * \\tparam Cols The number of columns in the matrix (= rows in the vector)\n> + * \\param m The matrix\n> + * \\param v The vector\n> + * \\return Product of matrix \\a m and vector \\a v\n> + */\n> +\n>  /**\n>   * \\fn bool operator==(const Vector<T, Rows> &lhs, const Vector<T, Rows> &rhs)\n>   * \\brief Compare vectors for equality\n> diff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h\n> index 2a2906202ce4..bc7acc9d0a27 100644\n> --- a/src/ipa/libipa/vector.h\n> +++ b/src/ipa/libipa/vector.h\n> @@ -16,6 +16,8 @@\n>  \n>  #include \"libcamera/internal/yaml_parser.h\"\n>  \n> +#include \"matrix.h\"\n> +\n>  namespace libcamera {\n>  \n>  LOG_DECLARE_CATEGORY(Vector)\n> @@ -140,6 +142,23 @@ private:\n>  \tstd::array<T, Rows> data_;\n>  };\n>  \n> +#ifndef __DOXYGEN__\n> +template<typename T, unsigned int Rows, unsigned int Cols>\n> +#endif /* __DOXYGEN__ */\n\nYou can drop the __DOXYGEN__ guard, the template doesn't need to be\nhidden.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +Vector<T, Rows> operator*(const Matrix<T, Rows, Cols> &m, const Vector<T, Cols> &v)\n> +{\n> +\tVector<T, Rows> result;\n> +\n> +\tfor (unsigned int i = 0; i < Rows; i++) {\n> +\t\tT sum = 0;\n> +\t\tfor (unsigned int j = 0; j < Cols; j++)\n> +\t\t\tsum += m[i][j] * v[j];\n> +\t\tresult[i] = sum;\n> +\t}\n> +\n> +\treturn result;\n> +}\n> +\n>  template<typename T, unsigned int Rows>\n>  bool operator==(const Vector<T, Rows> &lhs, const Vector<T, Rows> &rhs)\n>  {","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 95E43BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 16 Jun 2024 16:47:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B0D586548D;\n\tSun, 16 Jun 2024 18:47:43 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 55CD965456\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 16 Jun 2024 18:47:42 +0200 (CEST)","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 A6F8E581;\n\tSun, 16 Jun 2024 18:47:25 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"lguUOvb0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1718556445;\n\tbh=uSnegXzk9Ufqb+FQM45ySdoMLZ0zPPsGc4LmQwm0IHw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=lguUOvb0qBEpVZY71TQ2n3kRbbBMGDKdpA7Lt2W8fy8wLYLhoyruCmF6pAbxKVUw5\n\tq/dlmftfKRkF40q4L5LoLJmhcgAcn5ak78vuzlxXVOLcnXk0NjQpDia0YXJWrIkYhR\n\tpOhJppHNFt/69hFa5yc1Qh969fvIMrS9vVCFOh84=","Date":"Sun, 16 Jun 2024 19:47:20 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH v3] ipa: libipa: vector: Add matrix-vector multiplication","Message-ID":"<20240616164720.GA25491@pendragon.ideasonboard.com>","References":"<20240614120211.184588-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240614120211.184588-1-paul.elder@ideasonboard.com>","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>"}}]