E.V.E  0.1-beta

◆ bitofsign

eve::bitofsign = {}
inlineconstexpr

Callable object computing the bitofsign value.

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

Members Functions

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

auto operator()(value auto x) const noexcept;
Definition: value.hpp:31

Parameters

x: value.

Return value

The call bitofsign(x) is semantically equivalent to x & signmask(as(x)).

Warning
Take care that for floating real values bitofsign does NOT return a logical value that can be tested, but mzero(as(x)) if x is negative and zero(as(x)) if x is positive, which both satisfy the is_eqz predicate.

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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/bitofsign.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-1.0f, 0.0f, 3.0f, -0.0f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bitofsign(pf) = " << eve::bitofsign(pf) << '\n';
float xf = -32768.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bitofsign(xf) = " << eve::bitofsign(xf) << '\n';
return 0;
}
constexpr callable_bitofsign_ bitofsign
Callable object computing the bitofsign value.
Definition: bitofsign.hpp:77
Wrapper for SIMD registers.
Definition: wide.hpp:65