E.V.E
v2022.03.00

◆ fanm

eve::fanm = {}
inlineconstexpr

Computes the fused add negate multiply of its three parameters.

The call fanm(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 fanm(T x, U y, V z) noexcept;
}
constexpr callable_fanm_ fanm
Computes the fused add negate multiply of its three parameters.
Definition: fanm.hpp:82
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 reasonable cost.

Note
This fanm 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>
int main()
{
wide_ft pf = { 0.0f, 1.0f, -1.0f, -0.5f};
wide_ft qf = { 1.0f, -1.0f, -0.5f, 0.0f};
wide_ft rf = { 1.0f, 2.0f, -5.0f, 0.1f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "<- rf = " << rf << '\n'
<< " -> pedantic(fanm)(pf, qf, rf) = " << eve::pedantic(eve::fanm)(pf, qf, rf) << '\n'
<< " -> numeric(fanm)(pf, qf, rf) = " << eve::numeric(eve::fanm)(pf, qf, rf) << '\n'
<< " -> fanm(pf, qf, rf) = " << eve::fanm(pf, qf, rf) << '\n'
<< "\n if the last fanm result ends by '0, inf}', it is because\n"
<< " the system has no simd fanm fanmily intrinsics\n"
<< " or is not configured to use them.\n\n";
float xf = 0.5f;
float yf = 0.5f;
float zf = 0.1f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "<- zf = " << yf << '\n'
<< "-> fanm(xf, yf, zf) = " << eve::fanm(xf, yf, zf) << '\n';
return 0;
}
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
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::fanm[mask](x, ...) provides a masked version of fanm which is equivalent to if_else(mask, fanm(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'
    << " -> fanm[pf+of > 0](of, pf, qf) = " << eve::fanm[pf+of > 0](of, pf, qf) << '\n';
    return 0;
    }
    constexpr callable_valmax_ valmax
    Computes the the greatest representable value.
    Definition: valmax.hpp:55
    Lightweight type-wrapper.
    Definition: as.hpp:29
  • eve::pedantic, eve::numeric
    • The call pedantic(fanm)(x,y,z) ensures the one rounding property. This can be very expensive if the system has no hardware capability.
    • The call numeric(fanm)(x,y,z) ensures the full compliance to fanm properties. This can be very expensive if the system has no hardware capability.
    • see the above regular example.