E.V.E  0.1-beta

◆ fnms

eve::fnms = {}
inlineconstexpr

Callable object computing the fused negate-multiply-substract operation.

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

Members Functions

Member Effect
operator() the fused negate-multiply-substract 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 fnms(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 fnms 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::fnms

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • eve::pedantic

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

    The call pedantic(fnms)(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/fnms.hpp>

    The call numeric(fnms)(x,y,z) ensures the full compliance to fnms 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/fnms.hpp>

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

Example

See it live on Compiler Explorer

#include <eve/function/fnms.hpp>
#include <eve/function/pedantic/fnms.hpp>
#include <eve/function/numeric/fnms.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 oi = {2, -3, esp1, vm};
wide_t pi = {3, -2, esm1, 2 };
wide_t qi = {4, -1, 1.0f, -vm};
std::cout << "---- simd" << '\n'
<< " <- oi = " << oi << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> pedantic(fnms)(oi, pi, qi) = " << eve::pedantic(eve::fnms)(oi, pi, qi) << '\n'
<< " -> numeric(fnms)(oi, pi, qi) = " << eve::numeric(eve::fnms)(oi, pi, qi) << '\n'
<< " -> fnms(oi, pi, qi) = " << eve::fnms(oi, pi, qi) << '\n'
<< "\n if the last fnms result ends by '0, -inf}', it means that\n"
<< " the system has no simd fnms family intrinsics\n"
<< " or is not configured to use them.\n\n";
std::cout << "---- scalar" << std::setprecision(10) << '\n'
<< " <- vm = " << vm << '\n'
<< " -> pedantic(fnms)(vm, 2.0f, vm) = " << eve::pedantic(eve::fnms)(vm, 2.0f, -vm) << '\n'
<< " -> numeric(fnms)(vm, 2.0f, vm) = " << eve::numeric(eve::fnms)(vm, 2.0f, -vm) << '\n'
<< " -> fnms(vm, 2.0f, vm) = " << eve::fnms(vm, 2.0f, -vm) << '\n'
<< " <- esm1 = " << esm1 << '\n'
<< " <- esp1 = " << esp1 << '\n'
<< " -> pedantic(fnms)(esp1, esm1, 1.0f) = " << eve::pedantic(eve::fnms)(esp1, esm1,1.0f) << '\n'
<< " -> numeric(fnms)(esp1, esm1, 1.0f) = " << eve::numeric(eve::fnms)(esp1, esm1, 1.0f) << '\n'
<< " -> fnms(esp1, esm1, 1.0f) = " << eve::fnms(esp1, esm1, 1.0f) << '\n';
return 0;
}
constexpr callable_fnms_ fnms
Callable object computing the fused negate-multiply-substract operation.
Definition: fnms.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