E.V.E
v2022.09.01

◆ is_odd

eve::is_odd = {}
inlineconstexpr

Returns a logical true if and only if the element value is odd.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T >
eve::as_logical<T> is_odd(T x) noexcept;
}
constexpr callable_is_odd_ is_odd
Returns a logical true if and only if the element value is odd.
Definition: is_odd.hpp:64
Definition: all_of.hpp:22

Parameters

Return value

The call is_odd(x) is semantically equivalent to:

if constexpr(floating_value<T>) return (x != dec(x)) && eve::is_even(dec(x));
else constexpr(integral_value<T>) return eve::is_nez (x & one(as(x));
Definition: value.hpp:83
Definition: value.hpp:42
constexpr callable_dec_ dec
return the input decremented by 1.
Definition: dec.hpp:71
constexpr callable_one_ one
Computes the constant .
Definition: one.hpp:51
constexpr callable_is_nez_ is_nez
Returns a logical true if and only if the element value is not zero.
Definition: is_nez.hpp:66
constexpr callable_is_even_ is_even
Returns a logical true if and only if the element value is even.
Definition: is_even.hpp:64
Lightweight type-wrapper.
Definition: as.hpp:29

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {0.0f, 1.0f, -1.5f, -2.0f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> is_odd(pf) = " << eve::is_odd(pf) << '\n';
float xf = 1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> is_odd(xf) = " << eve::is_odd(xf) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

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

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft pf = {0.0f, 1.0f, -1.5f, -2.0f};
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "-> is_odd[pf > 0](pf) = " << eve::is_odd[pf > 0](pf) << '\n';
    return 0;
    }