E.V.E
v2023.02.15

◆ minus

eve::minus = {}
inlineconstexpr

Computes the opposite of the parameter that must be signed.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T >
T minus(T x) noexcept;
}
constexpr callable_minus_ minus
Computes the opposite of the parameter that must be signed.
Definition: minus.hpp:79
Definition: abi.hpp:18

Parameters

Return value

  • The result is the opposite of x if this value is representable in the type of x.
  • More specifically, for signed integers the opposite value of their lowest finite value is not representable and the result is undefined behaviour.
Note
  • Although the operator notation with - is supported, the - operator on standard scalar type is the original one and so can lead to automatic promotion.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-1.0f, 2.0f, -3.0f, -32768.0f};
wide_it pi = {-1, 2, -3, -32768};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> minus(pf) = " << eve::minus(pf) << '\n'
<< "<- pi = " << pi << '\n'
<< "-> minus(pi) = " << eve::minus(pi) << '\n'
<< "-> saturated(minus)(pi) = " << eve::saturated(eve::minus)(pf) << '\n';
float xf = -32768.0f;
std::int16_t xi = -32768;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> minus(xf) = " << eve::minus(xf) << '\n'
<< "<- xi = " << xi << '\n'
<< "-> minus(xi) = " << eve::minus(xi) << '\n';
return 0;
}
constexpr saturated_type const saturated
Higher-order Callable Object imbuing saturation semantic onto other Callable Objects.
Definition: saturated.hpp:68
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::minus[mask](x) provides a masked version of eve::minus which is equivalent to if_else (mask, eve::minus(x), x).

    Example

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

    The call eve::saturated(eve::minus)(x) computes a saturated version of eve::minus.

    More specifically, for any signed integer value x, the expression eve::saturated(eve::minus)(eve::valmin(as(x))) evaluates to eve::valmax(as(x)).

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft pf = {0, 1, -127, -128};
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "-> saturated(minus)(pf) = " << eve::saturated(eve::minus)(pf) << '\n';
    return 0;
    }