From patchwork Mon Nov 18 15:05:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 21958 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 43185C32DD for ; Mon, 18 Nov 2024 15:05:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DF5D2658E1; Mon, 18 Nov 2024 16:05:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cp6ql5YZ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 98521658ED for ; Mon, 18 Nov 2024 16:05:50 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:4424:4869:bb88:5c61]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B3F2F316; Mon, 18 Nov 2024 16:05:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731942333; bh=Pg/3Wxik2kWfhP+jATT+k/lGs0CFqo+AsWeTwNj2o/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cp6ql5YZJgvcbmfTYmyAjyKhakBbvFdDuUNuQxpX8QOuTev3VtU5+64N+nIMULt3r Tv73kwxWIlHJxTAlZm3CMmlTY0LUgXMjF45LF1HNoxbFUqSDK2GuTaOOlzTTbvjx3s FeqRBkvU0M9HelG02sf6zkPECTQA5NOsFD1yiUHc= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 3/4] libcamera: matrix: Use Span instead of vector for construction Date: Mon, 18 Nov 2024 16:05:06 +0100 Message-ID: <20241118150528.1856797-4-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241118150528.1856797-1-stefan.klug@ideasonboard.com> References: <20241118150528.1856797-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use a Span for construction to be more flexible. Additionally add an assert for the correct size of the span. Signed-off-by: Stefan Klug --- include/libcamera/internal/matrix.h | 3 ++- src/libcamera/matrix.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/matrix.h b/include/libcamera/internal/matrix.h index b82d33f98658..28ea68a55af9 100644 --- a/include/libcamera/internal/matrix.h +++ b/include/libcamera/internal/matrix.h @@ -39,8 +39,9 @@ public: std::copy(data.begin(), data.end(), data_.begin()); } - Matrix(const std::vector &data) + Matrix(const Span &data) { + ASSERT(data.size() == Rows * Cols); std::copy(data.begin(), data.end(), data_.begin()); } diff --git a/src/libcamera/matrix.cpp b/src/libcamera/matrix.cpp index c3ed54895b22..bb9fd3003996 100644 --- a/src/libcamera/matrix.cpp +++ b/src/libcamera/matrix.cpp @@ -31,6 +31,16 @@ LOG_DEFINE_CATEGORY(Matrix) * \brief Construct a zero matrix */ +/** + * \fn Matrix::Matrix(std::initializer_list data) + * \brief Construct a matrix from supplied data + * \param[in] data Data from which to construct a matrix + * + * \a data is a one-dimensional vector and will be turned into a matrix in + * row-major order. The size of \a data must be equal to the product of the + * number of rows and columns of the matrix (Rows x Cols). + */ + /** * \fn Matrix::Matrix(const Span &data) * \brief Construct a matrix from supplied data