E.V.E  0.1-beta

◆ is_negative

eve::is_negative = {}
inlineconstexpr

Callable object computing the is_negative logical value.

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

Members Functions

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

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

Parameters

x: value.

Return value

For signed types The call is_negative(x) elementwise returns true if and only if the bit of sign (most significant bit) is set.

Warning
this function coincides with is_ltz on integral real values, but for floating real values T, is_negative(mzero<T>) is true and if n is a Nan the result depends of the bit of sign of n which can be out of control although not undefined.

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

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

Parameters

cond : conditional expression

Return value

A Callable object so that the expression is_negative[cond](x) is equivalent to if_else(cond,is_negative(x),false(as(is_negative(x))))


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/is_negative.hpp>
#include <eve/wide.hpp>
#include <eve/constant/inf.hpp>
#include <eve/constant/minf.hpp>
#include <eve/constant/nan.hpp>
#include <iostream>
int main()
{
wide_ft pf = {0.0f, 1.0f, -1.5f, -2.0f, eve::nan(eve::as<float>()),
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> is_negative(pf) = " << eve::is_negative(pf) << '\n';
float xf = 1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> is_negative(xf) = " << eve::is_negative(xf) << '\n';
return 0;
}
constexpr callable_nan_ nan
Callable object computing the nan value.
Definition: nan.hpp:52
constexpr callable_minf_ minf
Callable object computing the negative infinity value.
Definition: minf.hpp:55
constexpr callable_inf_ inf
Callable object computing the infinity ieee value.
Definition: inf.hpp:54
constexpr callable_is_negative_ is_negative
Callable object computing the is_negative logical value.
Definition: is_negative.hpp:80
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65