E.V.E  0.1-beta

◆ binarize

eve::binarize = {}
inlineconstexpr

Callable object computing the binarize operation.

Required header: #include <eve/function/binarize.hpp>

Members Functions

Member Effect
operator() the computation of the binarize operation
operator[] Construct a conditional version of current function object

template< value T, scalar_value V > T operator()( Logical< T > c, V v = 1 ) const noexcept;

Parameters

c: logical value. v: scalar value defaulting to 1.

Return value

The call:

constexpr callable_binarize_ binarize
Callable object computing the binarize operation.
Definition: binarize.hpp:83
Wrapper for SIMD compatible logical types.
Definition: logical.hpp:36

is semantically equivalent to:

T r = if_else(c, T(v), T(0));
constexpr callable_if_else_ if_else
Callable object computing the if_else operation.
Definition: if_else.hpp:99

auto operator[]( conditional_expression auto cond ) const noexcept;

Higher-order function generating a masked version of eve::binarize

Parameters

cond : conditional expression

Return value

A Callable object so that the expression binarize[cond](x, ...) is equivalent to if_else(cond,binarize(x, ...),x)


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/binarize.hpp>
#include <eve/constant/false.hpp>
#include <eve/constant/true.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = { 0.0f, 1.0f, -1.0f, -0.5f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> binarize(pf > 0.0f) = " << eve::binarize(pf> 0.0f) << '\n'
<< "-> binarize(pf > 0.0f, 3) = " << eve::binarize(pf> 0.0f, 3) << '\n';
float xf = -1.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> binarize(true_(eve::as<float>()), xf) = " << eve::binarize(eve::true_(eve::as<float>()), xf) << '\n'
<< "-> binarize(false_(eve::as<float>()), xf) = " << eve::binarize(eve::false_(eve::as<float>()), xf) << '\n' ;
return 0;
}
constexpr callable_false__ false_
Callable object computing the logical false_ value.
Definition: false.hpp:52
constexpr callable_true__ true_
Callable object computing the logical true_ value.
Definition: true.hpp:52
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65