Show a patch.

GET /api/1.1/patches/22985/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 22985,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/22985/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22985/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20250319161152.63625-8-stefan.klug@ideasonboard.com>",
    "date": "2025-03-19T16:11:12",
    "name": "[v2,07/17] libcamera: matrix: Extend multiplication operator to heterogenous types",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "67232306dab516bf66be3662e2fd9c0a9f420695",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/1.1/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22985/mbox/",
    "series": [
        {
            "id": 5071,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5071/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5071",
            "date": "2025-03-19T16:11:05",
            "name": "Some rkisp1 awb improvements",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5071/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22985/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22985/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 5C756C32FE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 19 Mar 2025 16:12:19 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1D02F6895B;\n\tWed, 19 Mar 2025 17:12:19 +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 6B3026895E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Mar 2025 17:12:17 +0100 (CET)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:760:e5ca:4814:99c7])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7B21D55A;\n\tWed, 19 Mar 2025 17:10:34 +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=\"tm/mIn4/\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1742400634;\n\tbh=mhubXdXAgTxwsfjurIPZD4zCKZWHheK7trJwbcR4wEk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=tm/mIn4/a4gi8JiVHcLg+WfCp+k888vW+ILWhmc1SEc9sl2ffzoB+lsm0D/px7AqI\n\tIGtPNJ+PfSToQd85hjtL9Eo+dt4z3j11O1YnXQQPJod+tKdw7IMKIj3JxIAwU1jIK5\n\t2uQXoH8DpTUEL060w2wq+C9/V0TX5lYwDzPIvUmk=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Subject": "[PATCH v2 07/17] libcamera: matrix: Extend multiplication operator\n\tto heterogenous types",
        "Date": "Wed, 19 Mar 2025 17:11:12 +0100",
        "Message-ID": "<20250319161152.63625-8-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20250319161152.63625-1-stefan.klug@ideasonboard.com>",
        "References": "<20250319161152.63625-1-stefan.klug@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": "From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nIt is useful to multiply matrices of heterogneous types, for instance\nfloat and double. Extend the multiplication operator to support this,\navoiding the need to convert one of the matrices. The type of the\nreturned matrix is selected automatically to avoid loosing precision.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\n\nChanges in v2:\n- Added this patch\n---\n include/libcamera/internal/matrix.h | 10 ++++++----\n src/libcamera/matrix.cpp            |  5 +++--\n 2 files changed, 9 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/matrix.h b/include/libcamera/internal/matrix.h\nindex 6e3c190286fe..688c6fd498f3 100644\n--- a/include/libcamera/internal/matrix.h\n+++ b/include/libcamera/internal/matrix.h\n@@ -8,6 +8,7 @@\n \n #include <algorithm>\n #include <sstream>\n+#include <type_traits>\n #include <vector>\n \n #include <libcamera/base/log.h>\n@@ -129,15 +130,16 @@ constexpr Matrix<U, Rows, Cols> operator*(const Matrix<U, Rows, Cols> &m, T d)\n \treturn d * m;\n }\n \n-template<typename T, unsigned int R1, unsigned int C1, unsigned int R2, unsigned int C2>\n-constexpr Matrix<T, R1, C2> operator*(const Matrix<T, R1, C1> &m1, const Matrix<T, R2, C2> &m2)\n+template<typename T1, unsigned int R1, unsigned int C1, typename T2, unsigned int R2, unsigned int C2>\n+constexpr Matrix<std::common_type_t<T1, T2>, R1, C2> operator*(const Matrix<T1, R1, C1> &m1,\n+\t\t\t\t\t\t\t       const Matrix<T2, R2, C2> &m2)\n {\n \tstatic_assert(C1 == R2, \"Matrix dimensions must match for multiplication\");\n-\tMatrix<T, R1, C2> result;\n+\tMatrix<std::common_type_t<T1, T2>, R1, C2> result;\n \n \tfor (unsigned int i = 0; i < R1; i++) {\n \t\tfor (unsigned int j = 0; j < C2; j++) {\n-\t\t\tT sum = 0;\n+\t\t\tstd::common_type_t<T1, T2> sum = 0;\n \n \t\t\tfor (unsigned int k = 0; k < C1; k++)\n \t\t\t\tsum += m1[i][k] * m2[k][j];\ndiff --git a/src/libcamera/matrix.cpp b/src/libcamera/matrix.cpp\nindex 8590f8efeff3..f9117357dc7e 100644\n--- a/src/libcamera/matrix.cpp\n+++ b/src/libcamera/matrix.cpp\n@@ -138,11 +138,12 @@ LOG_DEFINE_CATEGORY(Matrix)\n  */\n \n /**\n- * \\fn Matrix<T, R1, C2> operator*(const Matrix<T, R1, C1> &m1, const Matrix<T, R2, C2> &m2)\n+ * \\fn operator*(const Matrix<T1, R1, C1> &m1, const Matrix<T2, R2, C2> &m2)\n  * \\brief Matrix multiplication\n- * \\tparam T Type of numerical values in the matrices\n+ * \\tparam T1 Type of numerical values in the first matrix\n  * \\tparam R1 Number of rows in the first matrix\n  * \\tparam C1 Number of columns in the first matrix\n+ * \\tparam T2 Type of numerical values in the secont matrix\n  * \\tparam R2 Number of rows in the second matrix\n  * \\tparam C2 Number of columns in the second matrix\n  * \\param m1 Multiplicand matrix\n",
    "prefixes": [
        "v2",
        "07/17"
    ]
}