Element-wise minimum, maximum, clamping, and selection.
More...
|
template<vec_type _Vp>
requires std::totally_ordered<typename _Vp::value_type> |
| constexpr _Vp | xvec::simd::min (const _Vp &lhs, const _Vp &rhs) noexcept |
| | Compute the smaller of each respective vec element from the two input arguments.
|
template<vec_type _Vp>
requires std::totally_ordered<typename _Vp::value_type> |
| constexpr _Vp | xvec::simd::max (const _Vp &lhs, const _Vp &rhs) noexcept |
| | Compute the larger of each respective vec element from the two input arguments.
|
template<vec_totally_ordered _Vp>
requires std::totally_ordered<typename _Vp::value_type> |
| constexpr std::pair< _Vp, _Vp > | xvec::simd::minmax (const _Vp &lhs, const _Vp &rhs) noexcept |
| | Compute a pair of vec values giving the smaller and larger respective of each corresponding vec element from the two input arguments.
|
template<vec_totally_ordered _Vp>
requires std::totally_ordered<typename _Vp::value_type> |
| constexpr _Vp | xvec::simd::clamp (const _Vp &values, const _Vp &low, const _Vp &high) |
| | Clamp the input values to be contained within the range [low,high]. If a value is less than low it will return low. If a value is greater than high it will return high. Other values are unmodified.
|
| template<mask_type _M, class _T, class _U> |
| constexpr auto | xvec::simd::select (const _M &m, const _T &if_true, const _U &if_false) noexcept -> decltype(simd_select_impl(m, if_true, if_false)) |
| | Select between corresponding elements according to a mask.
|
| template<std::copyable _Tp, std::copyable _Up> |
| constexpr auto | xvec::simd::select (bool c, const _Tp &a, const _Up &b) -> std::remove_cvref_t< decltype(c ? a :b)> |
| | Select between two values based on a boolean condition (scalar version).
|
Element-wise minimum, maximum, clamping, and selection.
- See also
- https://eel.is/c++draft/simd.alg
◆ clamp()
template<vec_totally_ordered _Vp>
requires std::totally_ordered<typename _Vp::value_type>
| _Vp xvec::simd::clamp |
( |
const _Vp & | values, |
|
|
const _Vp & | low, |
|
|
const _Vp & | high ) |
|
constexpr |
Clamp the input values to be contained within the range [low,high]. If a value is less than low it will return low. If a value is greater than high it will return high. Other values are unmodified.
- Template Parameters
-
- Parameters
-
| values | The values to clamp. |
| low | The low value in the clamping range. |
| high | The high value in the clamping range. |
- Returns
- A vec where each element is clamped to the range [low, high].
◆ max()
template<vec_type _Vp>
requires std::totally_ordered<typename _Vp::value_type>
| _Vp xvec::simd::max |
( |
const _Vp & | lhs, |
|
|
const _Vp & | rhs ) |
|
constexprnoexcept |
Compute the larger of each respective vec element from the two input arguments.
- Template Parameters
-
- Parameters
-
| lhs | The left-hand value to compare |
| rhs | The right-hand value to compare |
- Returns
- A new vec where each element is the larger of the two respective elements from the input values.
◆ min()
template<vec_type _Vp>
requires std::totally_ordered<typename _Vp::value_type>
| _Vp xvec::simd::min |
( |
const _Vp & | lhs, |
|
|
const _Vp & | rhs ) |
|
constexprnoexcept |
Compute the smaller of each respective vec element from the two input arguments.
- Template Parameters
-
- Parameters
-
| lhs | The left-hand value to compare |
| rhs | The right-hand value to compare |
- Returns
- A new vec where each element is the smaller of the two respective elements from the input values.
◆ minmax()
template<vec_totally_ordered _Vp>
requires std::totally_ordered<typename _Vp::value_type>
| std::pair< _Vp, _Vp > xvec::simd::minmax |
( |
const _Vp & | lhs, |
|
|
const _Vp & | rhs ) |
|
constexprnoexcept |
Compute a pair of vec values giving the smaller and larger respective of each corresponding vec element from the two input arguments.
- Template Parameters
-
- Parameters
-
| lhs | The left-hand value to compare |
| rhs | The right-hand value to compare |
- Returns
- A pair of vec values representing the results of the min and max functions applied to the inputs.
◆ select() [1/2]
template<std::copyable _Tp, std::copyable _Up>
| auto xvec::simd::select |
( |
bool | c, |
|
|
const _Tp & | a, |
|
|
const _Up & | b )->std::remove_cvref_t< decltype(c?a:b)> |
|
constexpr |
Select between two values based on a boolean condition (scalar version).
- Template Parameters
-
| _Tp | The type of the first value |
| _Up | The type of the second value |
- Parameters
-
| c | The condition |
| a | The value to use if c is true |
| b | The value to use if c is false |
- Returns
- a if c is true, otherwise b
◆ select() [2/2]
template<mask_type _M, class _T, class _U>
| auto xvec::simd::select |
( |
const _M & | m, |
|
|
const _T & | if_true, |
|
|
const _U & | if_false )->decltype(simd_select_impl(m, if_true, if_false)) |
|
constexprnoexcept |
Select between corresponding elements according to a mask.
- Template Parameters
-
| _M | The mask type |
| _T | The type of the first value |
| _U | The type of the second value |
- Parameters
-
| m | The mask indicating which elements to select |
| if_true | The value to use if the mask element is true |
| if_false | The value to use if the mask element is false |
- Returns
- A value where each element is selected from if_true or if_false according to the mask.