Intel xvec
Experimental C++ simd class library
Loading...
Searching...
No Matches
SIMD saturating arithmetic

Saturating arithmetic and element conversion for integral vectors. More...

Functions

template<vec_integral _Vp>
constexpr _Vp xvec::simd::saturating_add (const _Vp &lhs, const _Vp &rhs) noexcept
 Compute the saturated addition of each respective pair of SIMD elements.
template<vec_integral _Vp>
constexpr _Vp xvec::simd::saturating_sub (const _Vp &lhs, const _Vp &rhs) noexcept
 Compute the saturated subtraction of each respective pair of SIMD elements.
template<vec_integral _Vp>
constexpr _Vp xvec::simd::saturating_mul (const _Vp &lhs, const _Vp &rhs) noexcept
 Compute the saturated multiplication of each respective pair of SIMD elements.
template<vec_integral _Vp>
constexpr _Vp xvec::simd::saturating_div (const _Vp &lhs, const _Vp &rhs) noexcept
 Compute the saturated division of each respective pair of SIMD elements.
template<std::integral _Up, vec_integral _Vp>
constexpr rebind_t< _Up, _Vp > xvec::simd::saturating_cast (const _Vp &v) noexcept
 Compute a basic_vec where every element is converted to the new type, or if the value can't be represented then the largest or smallest value of that type is used instead, whichever is closer to the original value.

Detailed Description

Saturating arithmetic and element conversion for integral vectors.

Proposed in P2956, "Add saturating library support to std::simd".

See also
https://wg21.link/P2956

Function Documentation

◆ saturating_add()

template<vec_integral _Vp>
_Vp xvec::simd::saturating_add ( const _Vp & lhs,
const _Vp & rhs )
constexprnoexcept

Compute the saturated addition of each respective pair of SIMD elements.

Template Parameters
_VpThe integral basic_vec type.
Parameters
lhsThe first basic_vec value.
rhsThe second basic_vec value.
Returns
A basic_vec containing the saturated element-wise sums.

◆ saturating_cast()

template<std::integral _Up, vec_integral _Vp>
rebind_t< _Up, _Vp > xvec::simd::saturating_cast ( const _Vp & v)
constexprnoexcept

Compute a basic_vec where every element is converted to the new type, or if the value can't be represented then the largest or smallest value of that type is used instead, whichever is closer to the original value.

Template Parameters
_UpThe target integral element type.
_VpThe integral basic_vec type.
Parameters
vThe basic_vec value to convert.
Returns
A basic_vec value in which each element is the saturating cast of the respective input value.

◆ saturating_div()

template<vec_integral _Vp>
_Vp xvec::simd::saturating_div ( const _Vp & lhs,
const _Vp & rhs )
constexprnoexcept

Compute the saturated division of each respective pair of SIMD elements.

Template Parameters
_VpThe integral basic_vec type.
Parameters
lhsThe dividend basic_vec value.
rhsThe divisor basic_vec value.
Returns
A basic_vec containing the saturated element-wise quotients.

◆ saturating_mul()

template<vec_integral _Vp>
_Vp xvec::simd::saturating_mul ( const _Vp & lhs,
const _Vp & rhs )
constexprnoexcept

Compute the saturated multiplication of each respective pair of SIMD elements.

Template Parameters
_VpThe integral basic_vec type.
Parameters
lhsThe first basic_vec value.
rhsThe second basic_vec value.
Returns
A basic_vec containing the saturated element-wise products.

◆ saturating_sub()

template<vec_integral _Vp>
_Vp xvec::simd::saturating_sub ( const _Vp & lhs,
const _Vp & rhs )
constexprnoexcept

Compute the saturated subtraction of each respective pair of SIMD elements.

Template Parameters
_VpThe integral basic_vec type.
Parameters
lhsThe first basic_vec value.
rhsThe second basic_vec value.
Returns
A basic_vec containing the saturated element-wise differences.