From patchwork Wed Mar 19 16:11: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: 22981 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 8B61FC32FE for ; Wed, 19 Mar 2025 16:12:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3839C68956; Wed, 19 Mar 2025 17:12:07 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="v+vnFvqP"; 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 BFD7968950 for ; Wed, 19 Mar 2025 17:12:05 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:760:e5ca:4814:99c7]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D00548FA; Wed, 19 Mar 2025 17:10:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742400622; bh=UwDt89XFx7PIoRfW4bceJOVjymlThJ3lPWKM60WujCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v+vnFvqPZTqH+eJIYmw1HKqOINy8QJy37uk9alOODZ2Pz0q+vQiYSwXxpIWA+B/dF m0e2Ffs7EWLjNWNU8eomQilNbR3pHXdFRaz+kP0lDuXTD2+qZXWRE8saCTI53VIY7i VoauD4OUGE0oHTXhdGdDcb4681CIsWK2xDLE+PR4= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 03/17] libcamera: matrix: Add a Span based constructor Date: Wed, 19 Mar 2025 17:11:08 +0100 Message-ID: <20250319161152.63625-4-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 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 --- Changes in v2: - Added this patch --- 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 2e7929e9060c..9b80521e3cb0 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..6dca7498cab3 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