mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-14 16:09:51 +03:00
ipa: libipa: vector: Add element-wise min() and max() functions
Add functions to calculate the element-wise minimum and maximum of two vectors or of a vector and a scalar. This will be used in algorithm implementations. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
This commit is contained in:
parent
69544f5b7b
commit
2a29a2a6a1
2 changed files with 48 additions and 0 deletions
|
@ -176,6 +176,34 @@ namespace ipa {
|
||||||
* \return This vector
|
* \return This vector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn Vector::min(const Vector &other) const
|
||||||
|
* \brief Calculate the minimum of this vector and \a other element-wise
|
||||||
|
* \param[in] other The other vector
|
||||||
|
* \return The element-wise minimum of this vector and \a other
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn Vector::min(T scalar) const
|
||||||
|
* \brief Calculate the minimum of this vector and \a scalar element-wise
|
||||||
|
* \param[in] scalar The scalar
|
||||||
|
* \return The element-wise minimum of this vector and \a scalar
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn Vector::max(const Vector &other) const
|
||||||
|
* \brief Calculate the maximum of this vector and \a other element-wise
|
||||||
|
* \param[in] other The other vector
|
||||||
|
* \return The element-wise maximum of this vector and \a other
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn Vector::max(T scalar) const
|
||||||
|
* \brief Calculate the maximum of this vector and \a scalar element-wise
|
||||||
|
* \param[in] scalar The scalar
|
||||||
|
* \return The element-wise maximum of this vector and \a scalar
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn Vector::dot(const Vector<T, Rows> &other) const
|
* \fn Vector::dot(const Vector<T, Rows> &other) const
|
||||||
* \brief Compute the dot product
|
* \brief Compute the dot product
|
||||||
|
|
|
@ -148,6 +148,26 @@ public:
|
||||||
return apply(scalar, [](T a, T b) { return a / b; });
|
return apply(scalar, [](T a, T b) { return a / b; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr Vector min(const Vector &other) const
|
||||||
|
{
|
||||||
|
return apply(*this, other, [](T a, T b) { return std::min(a, b); });
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Vector min(T scalar) const
|
||||||
|
{
|
||||||
|
return apply(*this, scalar, [](T a, T b) { return std::min(a, b); });
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Vector max(const Vector &other) const
|
||||||
|
{
|
||||||
|
return apply(*this, other, [](T a, T b) { return std::max(a, b); });
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Vector max(T scalar) const
|
||||||
|
{
|
||||||
|
return apply(*this, scalar, [](T a, T b) -> T { return std::max(a, b); });
|
||||||
|
}
|
||||||
|
|
||||||
constexpr T dot(const Vector<T, Rows> &other) const
|
constexpr T dot(const Vector<T, Rows> &other) const
|
||||||
{
|
{
|
||||||
T ret = 0;
|
T ret = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue