E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ clamp

auto eve::clamp = functor<clamp_t>
inlineconstexpr

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto clamp(value auto x, value auto lo, value auto hi) noexcept; // 1
// Lanes masking
constexpr auto clamp[conditional_expr auto c](value auto x,
value auto lo, value auto hi) noexcept; // 2
constexpr auto clamp[logical_value auto m](value auto x,
value auto lo, value auto hi) noexcept; // 2
}
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition value.hpp:132
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition value.hpp:34
constexpr auto clamp
elementwise_callable clamping the value between two bounds.
Definition clamp.hpp:86
constexpr auto lo
Computes the least significant half of each lane.
Definition lo.hpp:73
constexpr auto hi
elementwise_callable computing the most significant half of each lane.
Definition hi.hpp:71
EVE Main Namespace.
Definition abi.hpp:18

Parameters

Return value

  1. Each element of the result contains:
    • lo, if x is less than lo.
    • hi, if hi is less than x.
    • otherwise x.
  2. The operation is performed conditionnaly.
Note
If some lo are not less or equal to the corresponding hi the routine asserts.

External references

Example

// revision 2 TODO investigate last result
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wi = {2, -3, 0, 4};
eve::wide mi = {3, -2, -10, 0};
eve::wide ma = {4, -1, 0, 5};
std::cout << "<- wi = " << wi << "\n";
std::cout << "<- mi = " << mi << "\n";
std::cout << "<- ma = " << ma << "\n";
std::cout << "-> clamp(wi, mi, ma) = " << eve::clamp(wi, mi, ma) << "\n";
std::cout << "-> clamp[ignore_last(2)](wi, mi, ma) = " << eve::clamp[eve::ignore_last(2)](wi, mi, ma) << "\n";
std::cout << "-> clamp[wi != -4.0f](wi, mi, ma) = " << eve::clamp[wi != -2.0f](wi, mi, ma) << "\n";
}
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition conditional.hpp:332
Wrapper for SIMD registers.
Definition wide.hpp:86