E.V.E
v2022.03.00

◆ fsnm

eve::fsnm = {}
inlineconstexpr

Computes the fused negate substact multiply of its three parameters.

The call fsnm(x, y, z) is similar to -x-y*z as if calculated to infinite precision and rounded once to fit the result as much as supported by the hardware.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T >
eve::compatible_value_t fsnm(T x, U y, V z) noexcept;
}
constexpr callable_fsnm_ fsnm
Computes the fused negate substact multiply of its three parameters.
Definition: fsnm.hpp:83
Definition: all_of.hpp:22

Parameters

Return value

The value of -x-y*z as if calculated to infinite precision and rounded once is returned, but only if the hardware is in capacity to do it at reasonnable cost.

Note
This fsnm implementation provides those properties for all integral real value and when possible for floating real value.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
int main()
{
float es = eve::eps(eve::as<float>());
float esm1 = es-1.0f;
float esp1 = es+1.0f;
float vm = eve::valmax(eve::as<float>());
wide_t qf = {2, -3, esp1, vm};
wide_t pf = {3, -2, esm1, 2 };
wide_t of = {4, -1, 1.0f, -vm};
std::cout << "---- simd" << '\n'
<< " <- of = " << of << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<< " -> pedantic(fsnm)(of, pf, qf) = " << eve::pedantic(eve::fsnm)(of, pf, qf) << '\n'
<< " -> numeric(fsnm)(of, pf, qf) = " << eve::numeric(eve::fsnm)(of, pf, qf) << '\n'
<< " -> fsnm(of, pf, qf) = " << eve::fsnm(of, pf, qf) << '\n'
<< "\n if the last fsnm result ends by '0, inf}', it is because\n"
<< " the system has no simd fsnm fsnmily intrinsics\n"
<< " or is not configured to use them.\n\n";
std::cout << "---- scalar" << std::setprecision(10) << '\n'
<< " <- vm = " << vm << '\n'
<< " -> pedantic(fsnm)(vm, 2.0f, -vm) = " << eve::pedantic(eve::fsnm)(vm, 2.0f, -vm) << '\n'
<< " -> numeric(fsnm)(vm, 2.0f, -vm) = " << eve::numeric(eve::fsnm)(vm, 2.0f, -vm) << '\n'
<< " -> fsnm(vm, 2.0f, -vm) = " << eve::fsnm(vm, 2.0f, -vm) << '\n'
<< " <- esm1 = " << esm1 << '\n'
<< " <- esp1 = " << esp1 << '\n'
<< " -> pedantic(fsnm)(1.0f, esp1, esm1) = " << eve::pedantic(eve::fsnm)(1.0f, esp1, esm1) << '\n'
<< " -> numeric(fsnm)(1.0f, esp1, esm1) = " << eve::numeric(eve::fsnm)(1.0f, esp1, esm1) << '\n'
<< " -> fsnm(-1.0f, esp1, esm1) = " << eve::fsnm(-1.0f, esp1, esm1) << '\n';
return 0;
}
constexpr callable_valmax_ valmax
Computes the the greatest representable value.
Definition: valmax.hpp:55
constexpr pedantic_type const pedantic
Higher-order Callable Object imbuing more standard semantic onto other Callable Objects.
Definition: pedantic.hpp:56
constexpr numeric_type const numeric
Higher-order Callable Object imbuing non invalid return preference semantic onto other Callable Objec...
Definition: numeric.hpp:53
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

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

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    #include <iomanip>
    int main()
    {
    float es = eve::eps(eve::as<float>());
    float esm1 = es-1.0f;
    float esp1 = es+1.0f;
    float vm = eve::valmax(eve::as<float>());
    wide_t qf = {2, -3, esp1, vm};
    wide_t pf = {3, -2, esm1, 2 };
    wide_t of = {4, -1, 1.0f, -vm};
    std::cout << "---- simd" << '\n'
    << " <- of = " << of << '\n'
    << " <- pf = " << pf << '\n'
    << " <- qf = " << qf << '\n'
    << " -> fsnm[pf+of > 0](of, pf, qf) = " << eve::fsnm[pf+of > 0](of, pf, qf) << '\n';
    return 0;
    }
  • eve::pedantic, eve::numeric
    • The call pedantic(fsnm)(x,y,z) ensures the one rounding property. This can be very expensive if the system has no hardware capability.
    • The call numeric(fsnm)(x,y,z) ensures the full compliance to fsnm properties. This can be very expensive if the system has no hardware capability.
    • see the above regular example.