From patchwork Thu Apr 3 15:49:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23119 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 98046C327D for ; Thu, 3 Apr 2025 15:49:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 50537689AA; Thu, 3 Apr 2025 17:49:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DX2kuY85"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CDD41689A4 for ; Thu, 3 Apr 2025 17:49:43 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:6d9d:9854:3fc1:4bb2]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2845B11E9; Thu, 3 Apr 2025 17:47:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1743695270; bh=BVgpPik1tU5qZTphpyFI3gMMCarUSWs3223pG75Rli8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DX2kuY85j/htvaGR9SfWLXyabHS5phnGtLRtnRyD/SgpYppZyannq7zJddbjm2shl yKHXy3IuTwAk/hKjoQ9TEHWzQuQ3u2r6XKu+L/0PTGYsB57OzH9HCMRuDNJ+VGeLBy +aVev0V9m9+FOgPEhJU6aebS6l/CXgCFiE/Yn884= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Laurent Pinchart Subject: [PATCH v3 03/16] libcamera: matrix: Add a Span based constructor Date: Thu, 3 Apr 2025 17:49:08 +0200 Message-ID: <20250403154925.382973-4-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250403154925.382973-1-stefan.klug@ideasonboard.com> References: <20250403154925.382973-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" When one wants to create a Matrix from existing data, currently the only way is via std::array. Add a Span based constructor to allow creation from vectors and alike. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Changes in v2: - Added this patch Changes in v3: - Pass the Span by value --- include/libcamera/internal/matrix.h | 5 +++++ src/libcamera/matrix.cpp | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/libcamera/internal/matrix.h b/include/libcamera/internal/matrix.h index 512c1162c3bc..6d40567af0a0 100644 --- a/include/libcamera/internal/matrix.h +++ b/include/libcamera/internal/matrix.h @@ -34,6 +34,11 @@ public: std::copy(data.begin(), data.end(), data_.begin()); } + Matrix(const Span data) + { + std::copy(data.begin(), data.end(), data_.begin()); + } + static constexpr Matrix identity() { Matrix ret; diff --git a/src/libcamera/matrix.cpp b/src/libcamera/matrix.cpp index e7e027225666..49e2aa3b4f2c 100644 --- a/src/libcamera/matrix.cpp +++ b/src/libcamera/matrix.cpp @@ -41,6 +41,16 @@ LOG_DEFINE_CATEGORY(Matrix) * number of rows and columns of the matrix (Rows x Cols). */ +/** + * \fn Matrix::Matrix(const Span data) + * \brief Construct a matrix from supplied data + * \param[in] data Data from which to construct a matrix + * + * \a data is a one-dimensional Span 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::identity() * \brief Construct an identity matrix