E.V.E
v2023.02.15
Loading...
Searching...
No Matches
◆
clamp
auto eve::clamp =
functor
<clamp_t>
inline
constexpr
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
}
eve::conditional_expr
Specifies that a type is a Conditional Expression.
Definition
conditional.hpp:28
eve::logical_value
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition
value.hpp:134
eve::value
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition
value.hpp:34
eve::clamp
constexpr auto clamp
elementwise_callable clamping the value between two bounds.
Definition
clamp.hpp:86
eve::lo
constexpr auto lo
Computes the least significant half of each lane.
Definition
lo.hpp:73
eve::hi
constexpr auto hi
elementwise_callable computing the most significant half of each lane.
Definition
hi.hpp:71
eve
EVE Main Namespace.
Definition
abi.hpp:19
Parameters
x
: value to clamp.
lo
,
hi
:
the boundary values
to clamp
x
to.
c
:
Conditional expression
masking the operation.
m
:
Logical value
masking the operation.
Return value
Each
element
of the result contains:
lo
, if
x
is less than
lo
.
hi
, if
hi
is less than
x
.
otherwise
x
.
The operation is performed conditionnaly
.
Note
If some lo are not less or equal to the corresponding hi the routine asserts.
External references
C++ standard reference
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"
;
}
eve::ignore_last
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition
conditional.hpp:353
eve::wide
Wrapper for SIMD registers.
Definition
wide.hpp:94
eve