mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-16 08:55:06 +03:00
ipa: libipa: vector: Add missing binary arithemtic operators
The Vector class defines multiple element-wise arithmetic operators between vectors or between a vector and a scalar. A few variants are missing. Add them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
This commit is contained in:
parent
49e961ca35
commit
f0d73c8758
2 changed files with 70 additions and 22 deletions
|
@ -64,32 +64,60 @@ namespace ipa {
|
||||||
* \return The negated vector
|
* \return The negated vector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn Vector::operator+(Vector const &other) const
|
||||||
|
* \brief Calculate the sum of this vector and \a other element-wise
|
||||||
|
* \param[in] other The other vector
|
||||||
|
* \return The element-wise sum of this vector and \a other
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn Vector::operator+(T scalar) const
|
||||||
|
* \brief Calculate the sum of this vector and \a scalar element-wise
|
||||||
|
* \param[in] scalar The scalar
|
||||||
|
* \return The element-wise sum of this vector and \a other
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn Vector::operator-(Vector const &other) const
|
* \fn Vector::operator-(Vector const &other) const
|
||||||
* \brief Subtract one vector from another
|
* \brief Calculate the difference of this vector and \a other element-wise
|
||||||
* \param[in] other The other vector
|
* \param[in] other The other vector
|
||||||
* \return The difference of \a other from this vector
|
* \return The element-wise subtraction of \a other from this vector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn Vector::operator+()
|
* \fn Vector::operator-(T scalar) const
|
||||||
* \brief Add two vectors together
|
* \brief Calculate the difference of this vector and \a scalar element-wise
|
||||||
|
* \param[in] scalar The scalar
|
||||||
|
* \return The element-wise subtraction of \a scalar from this vector
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn Vector::operator*(const Vector &other) const
|
||||||
|
* \brief Calculate the product of this vector and \a other element-wise
|
||||||
* \param[in] other The other vector
|
* \param[in] other The other vector
|
||||||
* \return The sum of the two vectors
|
* \return The element-wise product of this vector and \a other
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn Vector::operator*(T factor) const
|
* \fn Vector::operator*(T scalar) const
|
||||||
* \brief Multiply the vector by a scalar
|
* \brief Calculate the product of this vector and \a scalar element-wise
|
||||||
* \param[in] factor The factor
|
* \param[in] scalar The scalar
|
||||||
* \return The vector multiplied by \a factor
|
* \return The element-wise product of this vector and \a scalar
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn Vector::operator/()
|
* \fn Vector::operator/(const Vector &other) const
|
||||||
* \brief Divide the vector by a scalar
|
* \brief Calculate the quotient of this vector and \a other element-wise
|
||||||
* \param[in] factor The factor
|
* \param[in] other The other vector
|
||||||
* \return The vector divided by \a factor
|
* \return The element-wise division of this vector by \a other
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn Vector::operator/(T scalar) const
|
||||||
|
* \brief Calculate the quotient of this vector and \a scalar element-wise
|
||||||
|
* \param[in] scalar The scalar
|
||||||
|
* \return The element-wise division of this vector by \a scalar
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -68,24 +68,44 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Vector operator-(const Vector &other) const
|
|
||||||
{
|
|
||||||
return apply(*this, other, std::minus<>{});
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr Vector operator+(const Vector &other) const
|
constexpr Vector operator+(const Vector &other) const
|
||||||
{
|
{
|
||||||
return apply(*this, other, std::plus<>{});
|
return apply(*this, other, std::plus<>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Vector operator*(T factor) const
|
constexpr Vector operator+(T scalar) const
|
||||||
{
|
{
|
||||||
return apply(*this, factor, std::multiplies<>{});
|
return apply(*this, scalar, std::plus<>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Vector operator/(T factor) const
|
constexpr Vector operator-(const Vector &other) const
|
||||||
{
|
{
|
||||||
return apply(*this, factor, std::divides<>{});
|
return apply(*this, other, std::minus<>{});
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Vector operator-(T scalar) const
|
||||||
|
{
|
||||||
|
return apply(*this, scalar, std::minus<>{});
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Vector operator*(const Vector &other) const
|
||||||
|
{
|
||||||
|
return apply(*this, other, std::multiplies<>{});
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Vector operator*(T scalar) const
|
||||||
|
{
|
||||||
|
return apply(*this, scalar, std::multiplies<>{});
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Vector operator/(const Vector &other) const
|
||||||
|
{
|
||||||
|
return apply(*this, other, std::divides<>{});
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Vector operator/(T scalar) const
|
||||||
|
{
|
||||||
|
return apply(*this, scalar, std::divides<>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr T dot(const Vector<T, Rows> &other) const
|
constexpr T dot(const Vector<T, Rows> &other) const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue