E.V.E
v2022.03.00

◆ signnz

eve::signnz = {}
inlineconstexpr

Computes the never zero sign of the parameter.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T >
T signnz(T x) noexcept;
}
constexpr callable_signnz_ signnz
Computes the never zero sign of the parameter.
Definition: signnz.hpp:71
Definition: all_of.hpp:22

Parameters

Return value

  • Computes elementwise the never zero sign of x.
  • For real x, the call is semantically equivalent to:
    • If x is positive, 1 is returned.
    • If x is negative, -1 is returned.
  • Moreover for floating real value if x is Nan, the result is Nan

value containing the elementwise never zero sign of x

Example

#include <eve/module/core.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_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve;signnz[mask](x) provides a masked version of eve::signnz which is equivalent to if_else (mask, signnz(x), x).

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft pf = {-0.0f, 1.0f, -3.0f, -32768.0f,
    0.0f, -1.0f, 3.0f, 32768.0f};
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "-> signnz[abs(pf) < 2](pf) = " << eve::signnz[eve::abs(pf) < 2](pf) << '\n';
    return 0;
    }
    constexpr callable_abs_ abs
    Computes the absolute value of the parameter.
    Definition: abs.hpp:107