Show a patch.

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

{
    "id": 21971,
    "url": "https://patchwork.libcamera.org/api/patches/21971/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21971/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20241118221618.13953-12-laurent.pinchart@ideasonboard.com>",
    "date": "2024-11-18T22:16:12",
    "name": "[v3,11/17] test: libipa: Add Vector class test",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "7c7f31126c0f4e8456a478eda7d3ae7b3bb2eaf0",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21971/mbox/",
    "series": [
        {
            "id": 4798,
            "url": "https://patchwork.libcamera.org/api/series/4798/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4798",
            "date": "2024-11-18T22:16:01",
            "name": "Improve linear algebra helpers in libipa",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/4798/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21971/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21971/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 0E0F3C32EA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 18 Nov 2024 22:16:55 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BB3DB65ED6;\n\tMon, 18 Nov 2024 23:16:53 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 40C81658F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Nov 2024 23:16:43 +0100 (CET)",
            "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 328B66DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Nov 2024 23:16:26 +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=\"ZxmlRn3s\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1731968186;\n\tbh=AWwtAnZYgaczRoTVwL5Kd/UZfsIOE2iUa5X6/0Wnw3I=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=ZxmlRn3s2OtzO88Xh7crwpaF9fW6+2zRMtFf2FwKF5XvGEHw0S3jntTLYDvJsWNTb\n\t/6RygkEBLRzwAxEF7+mGFQ3IKI/ez5Yskq12F1+3y7aDojb5yVIVPpSB8uS/Sfmed5\n\t2Ihun9LejCqeyPldTmjpm6wJ6U9XH5Hx7idDpnd0=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v3 11/17] test: libipa: Add Vector class test",
        "Date": "Tue, 19 Nov 2024 00:16:12 +0200",
        "Message-ID": "<20241118221618.13953-12-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.45.2",
        "In-Reply-To": "<20241118221618.13953-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20241118221618.13953-1-laurent.pinchart@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": "Add a unit test to exercize the API of the ipa::Vector class.\n\nThe test binary being called 'vector', implicit includes cause the\nbinary to be picked by '#include <vector>', causing builds to fail. Set\nimplicit_include_directories to false to avoid this, as done in commit\n6cd849125888 (\"test: Don't add current build directory to include\npath\").\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v2:\n\n- Fix initialization of 'v1' variable\n---\n test/ipa/libipa/meson.build |   2 +\n test/ipa/libipa/vector.cpp  | 100 ++++++++++++++++++++++++++++++++++++\n 2 files changed, 102 insertions(+)\n create mode 100644 test/ipa/libipa/vector.cpp",
    "diff": "diff --git a/test/ipa/libipa/meson.build b/test/ipa/libipa/meson.build\nindex 4d2427dbd4e7..f9b3c46d000f 100644\n--- a/test/ipa/libipa/meson.build\n+++ b/test/ipa/libipa/meson.build\n@@ -2,11 +2,13 @@\n \n libipa_test = [\n     {'name': 'interpolator', 'sources': ['interpolator.cpp']},\n+    {'name': 'vector', 'sources': ['vector.cpp']},\n ]\n \n foreach test : libipa_test\n     exe = executable(test['name'], test['sources'],\n                      dependencies : [libcamera_private, libipa_dep],\n+                     implicit_include_directories : false,\n                      link_with : [test_libraries],\n                      include_directories : [test_includes_internal,\n                                             '../../../src/ipa/libipa/'])\ndiff --git a/test/ipa/libipa/vector.cpp b/test/ipa/libipa/vector.cpp\nnew file mode 100644\nindex 000000000000..8e4ec77d7820\n--- /dev/null\n+++ b/test/ipa/libipa/vector.cpp\n@@ -0,0 +1,100 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2024, Ideas on Board Oy\n+ *\n+ * Vector tests\n+ */\n+\n+#include \"../src/ipa/libipa/vector.h\"\n+\n+#include <cmath>\n+#include <iostream>\n+\n+#include \"test.h\"\n+\n+using namespace libcamera::ipa;\n+\n+#define ASSERT_EQ(a, b)\t\t\t\t\t\t\t\\\n+if ((a) != (b)) {\t\t\t\t\t\t\t\\\n+\tstd::cout << #a \" != \" #b << \" (line \" << __LINE__ << \")\"\t\\\n+\t\t  << std::endl;\t\t\t\t\t\t\\\n+\treturn TestFail;\t\t\t\t\t\t\\\n+}\n+\n+class VectorTest : public Test\n+{\n+protected:\n+\tint run()\n+\t{\n+\t\tVector<double, 3> v1{ 0.0 };\n+\n+\t\tASSERT_EQ(v1[0], 0.0);\n+\t\tASSERT_EQ(v1[1], 0.0);\n+\t\tASSERT_EQ(v1[2], 0.0);\n+\n+\t\tASSERT_EQ(v1.length(), 0.0);\n+\t\tASSERT_EQ(v1.length2(), 0.0);\n+\n+\t\tVector<double, 3> v2{{ 1.0, 4.0, 8.0 }};\n+\n+\t\tASSERT_EQ(v2[0], 1.0);\n+\t\tASSERT_EQ(v2[1], 4.0);\n+\t\tASSERT_EQ(v2[2], 8.0);\n+\n+\t\tASSERT_EQ(v2.x(), 1.0);\n+\t\tASSERT_EQ(v2.y(), 4.0);\n+\t\tASSERT_EQ(v2.z(), 8.0);\n+\n+\t\tASSERT_EQ(v2.r(), 1.0);\n+\t\tASSERT_EQ(v2.g(), 4.0);\n+\t\tASSERT_EQ(v2.b(), 8.0);\n+\n+\t\tASSERT_EQ(v2.length2(), 81.0);\n+\t\tASSERT_EQ(v2.length(), 9.0);\n+\t\tASSERT_EQ(v2.sum(), 13.0);\n+\n+\t\tVector<double, 3> v3{ v2 };\n+\n+\t\tASSERT_EQ(v2, v3);\n+\n+\t\tv3 = Vector<double, 3>{{ 4.0, 4.0, 4.0 }};\n+\n+\t\tASSERT_EQ(v2 + v3, (Vector<double, 3>{{ 5.0, 8.0, 12.0 }}));\n+\t\tASSERT_EQ(v2 + 4.0, (Vector<double, 3>{{ 5.0, 8.0, 12.0 }}));\n+\t\tASSERT_EQ(v2 - v3, (Vector<double, 3>{{ -3.0, 0.0, 4.0 }}));\n+\t\tASSERT_EQ(v2 - 4.0, (Vector<double, 3>{{ -3.0, 0.0, 4.0 }}));\n+\t\tASSERT_EQ(v2 * v3, (Vector<double, 3>{{ 4.0, 16.0, 32.0 }}));\n+\t\tASSERT_EQ(v2 * 4.0, (Vector<double, 3>{{ 4.0, 16.0, 32.0 }}));\n+\t\tASSERT_EQ(v2 / v3, (Vector<double, 3>{{ 0.25, 1.0, 2.0 }}));\n+\t\tASSERT_EQ(v2 / 4.0, (Vector<double, 3>{{ 0.25, 1.0, 2.0 }}));\n+\n+\t\tASSERT_EQ(v2.min(v3), (Vector<double, 3>{{ 1.0, 4.0, 4.0 }}));\n+\t\tASSERT_EQ(v2.min(4.0), (Vector<double, 3>{{ 1.0, 4.0, 4.0 }}));\n+\t\tASSERT_EQ(v2.max(v3), (Vector<double, 3>{{ 4.0, 4.0, 8.0 }}));\n+\t\tASSERT_EQ(v2.max(4.0), (Vector<double, 3>{{ 4.0, 4.0, 8.0 }}));\n+\n+\t\tASSERT_EQ(v2.dot(v3), 52.0);\n+\n+\t\tv2 += v3;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 5.0, 8.0, 12.0 }}));\n+\t\tv2 -= v3;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 1.0, 4.0, 8.0 }}));\n+\t\tv2 *= v3;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 4.0, 16.0, 32.0 }}));\n+\t\tv2 /= v3;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 1.0, 4.0, 8.0 }}));\n+\n+\t\tv2 += 4.0;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 5.0, 8.0, 12.0 }}));\n+\t\tv2 -= 4.0;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 1.0, 4.0, 8.0 }}));\n+\t\tv2 *= 4.0;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 4.0, 16.0, 32.0 }}));\n+\t\tv2 /= 4.0;\n+\t\tASSERT_EQ(v2, (Vector<double, 3>{{ 1.0, 4.0, 8.0 }}));\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(VectorTest)\n",
    "prefixes": [
        "v3",
        "11/17"
    ]
}