E.V.E  0.1-beta

◆ fsnm

eve::fsnm = {}
inlineconstexpr

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

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

Members Functions

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

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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • eve::pedantic

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

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

    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.

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

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

    The expression diff_1st(fsnm)(x,y,z), diff_2nd(fsnm)(x,y,z) and diff_3rd(fsnm)(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/fsnm.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'
<< "-> fsnm(pf, qf, rf) = " << eve::fsnm(pf, qf, rf) << '\n'
<< "-> diff_1st(fsnm)(pf, qf, rf) = " << eve::diff_1st(eve::fsnm)(pf, qf, rf) << '\n'
<< "-> diff_2nd(fsnm)(pf, qf, rf) = " << eve::diff_2nd(eve::fsnm)(pf, qf, rf) << '\n'
<< "-> diff_3rd(fsnm)(pf, qf, rf) = " << eve::diff_3rd(eve::fsnm)(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'
<< "-> fsnm(xf, yf, zf) = " << eve::fsnm(xf, yf, zf) << '\n'
<< "-> diff_1st(fsnm)(xf, yf, zf) = " << eve::diff_1st(eve::fsnm)(xf, yf, zf) << '\n'
<< "-> diff_2nd(fsnm)(xf, yf, zf) = " << eve::diff_2nd(eve::fsnm)(xf, yf, zf) << '\n'
<< "-> diff_3rd(fsnm)(xf, yf, zf) = " << eve::diff_3rd(eve::fsnm)(xf, yf, zf) << '\n';
return 0;
}
constexpr callable_fsnm_ fsnm
Callable object computing the fused sub-negate-multiply operation.
Definition: fsnm.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