[PATCH v4 03/17] ipa: libipa: vector: Add scalar constructor
Milan Zamazal
mzamazal at redhat.com
Tue Nov 19 17:57:51 CET 2024
Laurent Pinchart <laurent.pinchart at ideasonboard.com> writes:
> The default constructor leaves the vector data uninitialized. Add a
> constructor to fill the vector with copies of a scalar value, and fix
> the documentation of the default constructor.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal at redhat.com>
> ---
> Changes since v3:
>
> - Make the constructor explicit
> ---
> src/ipa/libipa/vector.cpp | 8 +++++++-
> src/ipa/libipa/vector.h | 5 +++++
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp
> index 0f0511da151f..5851b9ae2ed3 100644
> --- a/src/ipa/libipa/vector.cpp
> +++ b/src/ipa/libipa/vector.cpp
> @@ -29,7 +29,13 @@ namespace ipa {
>
> /**
> * \fn Vector::Vector()
> - * \brief Construct a zero vector
> + * \brief Construct an uninitialized vector
> + */
> +
> +/**
> + * \fn Vector::Vector(T scalar)
> + * \brief Construct a vector filled with a \a scalar value
> + * \param[in] scalar The scalar value
> */
>
> /**
> diff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h
> index 3168835bc13d..5fb7ad7c95dd 100644
> --- a/src/ipa/libipa/vector.h
> +++ b/src/ipa/libipa/vector.h
> @@ -35,6 +35,11 @@ class Vector
> public:
> constexpr Vector() = default;
>
> + constexpr explicit Vector(T scalar)
> + {
> + data_.fill(scalar);
> + }
> +
> constexpr Vector(const std::array<T, Rows> &data)
> {
> for (unsigned int i = 0; i < Rows; i++)
More information about the libcamera-devel
mailing list