libcamera: matrix: Add a Span based constructor
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 <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
5234e4936f
commit
aca9042abd
2 changed files with 15 additions and 0 deletions
|
@ -34,6 +34,11 @@ public:
|
||||||
std::copy(data.begin(), data.end(), data_.begin());
|
std::copy(data.begin(), data.end(), data_.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Matrix(const Span<const T, Rows * Cols> data)
|
||||||
|
{
|
||||||
|
std::copy(data.begin(), data.end(), data_.begin());
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr Matrix identity()
|
static constexpr Matrix identity()
|
||||||
{
|
{
|
||||||
Matrix ret;
|
Matrix ret;
|
||||||
|
|
|
@ -41,6 +41,16 @@ LOG_DEFINE_CATEGORY(Matrix)
|
||||||
* number of rows and columns of the matrix (Rows x Cols).
|
* number of rows and columns of the matrix (Rows x Cols).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn Matrix::Matrix(const Span<const T, Rows * Cols> 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()
|
* \fn Matrix::identity()
|
||||||
* \brief Construct an identity matrix
|
* \brief Construct an identity matrix
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue