E.V.E  0.1-beta

◆ fanm

eve::fanm = {}
inlineconstexpr

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

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

Members Functions

Member Effect
operator() the fused add-negate-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 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.

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

Warning
Note This fanm 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::fanm

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • eve::pedantic

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

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

    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.

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

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

    The expression diff_1st(fanm)(x,y,z), diff_2nd(fanm)(x,y,z) and diff_3rd(fanm)(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/diff/fanm.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft rf = { 0.0f, 1.0f, -1.0f, -0.5f};
wide_ft qf = { 1.0f, -1.0f, -0.5f, 0.0f};
wide_ft pf = { 1.0f, 2.0f, -5.0f, 0.1f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "<- rf = " << rf << '\n'
<< "-> fanm(pf, qf, rf) = " << eve::fanm(pf, qf, rf) << '\n'
<< "-> diff_1st(fanm)(pf, qf, rf) = " << eve::diff_1st(eve::fanm)(pf, qf, rf) << '\n'
<< "-> diff_2nd(fanm)(pf, qf, rf) = " << eve::diff_2nd(eve::fanm)(pf, qf, rf) << '\n'
<< "-> diff_3rd(fanm)(pf, qf, rf) = " << eve::diff_3rd(eve::fanm)(pf, qf, rf) << '\n';
float xf = 1.0f;
float yf = 0.5f;
float zf = 0.5f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "<- zf = " << yf << '\n'
<< "-> fanm(xf, yf, zf) = " << eve::fanm(xf, yf, zf) << '\n'
<< "-> diff_1st(fanm)(xf, yf, zf) = " << eve::diff_1st(eve::fanm)(xf, yf, zf) << '\n'
<< "-> diff_2nd(fanm)(xf, yf, zf) = " << eve::diff_2nd(eve::fanm)(xf, yf, zf) << '\n'
<< "-> diff_3rd(fanm)(xf, yf, zf) = " << eve::diff_3rd(eve::fanm)(xf, yf, zf) << '\n';
return 0;
}
constexpr callable_fanm_ fanm
Callable object computing the fused add-negate-multiply operation.
Definition: fanm.hpp:99
constexpr diff_type< 2 > const diff_2nd
Higher-order Callable Object imbuing derivative semantics onto other Callable Objects.
Definition: derivative.hpp:125
constexpr diff_type< 1 > const diff_1st
Higher-order Callable Object imbuing derivative semantics onto other Callable Objects.
Definition: derivative.hpp:92
constexpr diff_type< 3 > const diff_3rd
Higher-order Callable Object imbuing derivative semantics onto other Callable Objects.
Definition: derivative.hpp:158
Wrapper for SIMD registers.
Definition: wide.hpp:65