E.V.E  0.1-beta

◆ signnz

eve::signnz = {}
inlineconstexpr

Callable object computing the signnz function.

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

Members Functions

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

template< value T > auto operator()( T x ) const noexcept;

Parameters

x: value.

Return value

Computes elementwise the never zero sign of x.

For real value x is semantically equivalent to:

  • If x is positive, 1 is returned.
  • If x is negative -1 is returned.
  • If x is Nan, the result is Nan.

For floating real value the positivity is only here based on the bit of sign. In particular -0.0 is negative and +0.0 is positive.


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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

Example

See it live on Compiler Explorer

#include <eve/function/signnz.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-0.0f, 2.0f, -3.0f, -32768.0f,
0.0f, -2.0f, 3.0f, 32768.0f};
wide_it pi = { 0, 2, -3, -32768};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> signnz(pf) = " << eve::signnz(pf) << '\n'
<< "<- pi = " << pi << '\n'
<< "-> signnz(pi) = " << eve::signnz(pi) << '\n';
float xf = -327.68f;
std::int16_t xi = -328;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> signnz(xf) = " << eve::signnz(xf) << '\n'
<< "<- xi = " << xi << '\n'
<< "-> signnz(xi) = " << eve::signnz(xi) << '\n';
return 0;
}
constexpr callable_signnz_ signnz
Callable object computing the signnz function.
Definition: signnz.hpp:84
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
Wrapper for SIMD registers.
Definition: wide.hpp:65