E.V.E  0.1-beta

◆ fam

eve::fam = {}
inlineconstexpr

Callable object computing the fused add-multiply operation.

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

Members Functions

Member Effect
operator() the fused add-multiply operation
operator[] Construct a conditional version of current function object

template< value T, value U, value V > auto operator()( T x, U y, V z ) const noexcept
requires compatible< T,U> && compatible< T, V >;

Parameters

x, y, z: values

Return value

The call fam(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.

The result type is the common compatible type of the three parameters.

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

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

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

Parameters

cond : conditional expression

Return value

A Callable object so that the expression fam[cond](x, ...) is equivalent to if_else(cond,fam(x, ...),x)


Supported decorators

  • eve::pedantic

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

    The call pedantic(fam)(x,y,z) ensures the one rounding property. This can be very expensive if the system has no hardware capability.

  • eve::numeric

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

    The call numeric(fam)(x,y,z) ensures the full compliance to fam properties. This can be very expensive if the system has no hardware capability.

  • eve::diff, eve::diff_1st, eve::diff_2nd, eve::diff_3rd, eve::diff_nth

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

    The expression diff_1st(fam)(x,y,z), diff_2nd(fam)(x,y,z) and diff_3rd(fam)(x,y,z) compute the partial derivatives of \(f\), where \(f\) is the function \((x,y,z) \rightarrow \ x+y z\).

Example

See it live on Compiler Explorer

#include <eve/function/fma.hpp>
#include <eve/function/pedantic/fam.hpp>
#include <eve/function/numeric/fam.hpp>
#include <eve/constant/eps.hpp>
#include <eve/constant/valmax.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 qi = {2, -3, esp1, vm};
wide_t pi = {3, -2, esm1, 2 };
wide_t oi = {4, -1, 1.0f, -vm};
std::cout << "---- simd" << '\n'
<< " <- oi = " << oi << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> pedantic(fam)(oi, pi, qi) = " << eve::pedantic(eve::fam)(oi, pi, qi) << '\n'
<< " -> numeric(fam)(oi, pi, qi) = " << eve::numeric(eve::fam)(oi, pi, qi) << '\n'
<< " -> fam(oi, pi, qi) = " << eve::fam(oi, pi, qi) << '\n'
<< "\n if the last fam result ends by '0, inf}', it is because\n"
<< " the system has no simd fam family intrinsics\n"
<< " or is not configured to use them.\n\n";
std::cout << "---- scalar" << std::setprecision(10) << '\n'
<< " <- vm = " << vm << '\n'
<< " -> pedantic(fam)(vm, 2.0f, -vm) = " << eve::pedantic(eve::fam)(vm, 2.0f, -vm) << '\n'
<< " -> numeric(fam)(vm, 2.0f, -vm) = " << eve::numeric(eve::fam)(vm, 2.0f, -vm) << '\n'
<< " -> fam(vm, 2.0f, -vm) = " << eve::fam(vm, 2.0f, -vm) << '\n'
<< " <- esm1 = " << esm1 << '\n'
<< " <- esp1 = " << esp1 << '\n'
<< " -> pedantic(fam)(1.0f, esp1, esm1) = " << eve::pedantic(eve::fam)(1.0f, esp1, esm1) << '\n'
<< " -> numeric(fam)(1.0f, esp1, esm1) = " << eve::numeric(eve::fam)(1.0f, esp1, esm1) << '\n'
<< " -> fam(-1.0f, esp1, esm1) = " << eve::fam(-1.0f, esp1, esm1) << '\n';
return 0;
}
constexpr callable_fam_ fam
Callable object computing the fused add-multiply operation.
Definition: fam.hpp:99
constexpr callable_valmax_ valmax
Callable object computing the greatest representable value.
Definition: valmax.hpp:53
constexpr callable_eps_ eps
Callable object computing the machine epsilon.
Definition: eps.hpp:60
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
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:52
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65