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

◆ saturate

auto eve::saturate = functor<saturate_t>
inlineconstexpr

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
constexpr auto saturate(value auto x, as<value> t) noexcept;
}
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 saturate
strict_elementwise_callable computing the saturation of a value in a type.
Definition saturate.hpp:76
EVE Main Namespace.
Definition abi.hpp:18
Lightweight type-wrapper.
Definition as.hpp:29

Parameters

Return value

For an x type U, the call saturate(x, as_<Target>{}) returns elementwise a value of element type U which is x clamped between the smallest and largest values of the Target

Note
Saturation operated by eve::saturate may lead to Undefined Behaviors if it implies conversions that are themselves Undefined Behavior.

Example

// revision 1
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0 = {-1.0f, 2.3f, 45000.7f, -64768.6f};
eve::wide wi0 = {-1l, 2l, -3l, eve::valmax(eve::as<long>())};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "-> saturate(wf0, as(wu)) = " << eve::saturate(wf0, eve::as<std::int16_t>()) << "\n";
std::cout << "-> saturate(wi, as(wu0)) = " << eve::saturate(wi0, eve::as<std::int16_t>()) << "\n";
}
constexpr auto valmax
Computes the the greatest representable value.
Definition valmax.hpp:66
Wrapper for SIMD registers.
Definition wide.hpp:86