E.V.E  0.1-beta

◆ two_add

eve::two_add = {}
inlineconstexpr

Callable object computing the two_add operation.

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

Members Functions

Member Effect
operator() the two_add operation

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

Parameters

x, y: values.

Return value

computes elementwise a pair of values [a,e] such that:

  • a is x+y
  • e is a value such that a \(\oplus\)e is equal to x \(\oplus\)y

where \(\oplus\) adds its two parameters with infinite precision.


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/two_add.hpp>
#include <eve/wide.hpp>
#include <eve/constant/eps.hpp>
#include <iostream>
#include <iomanip>
int main()
{
float ep = eve::eps(eve::as<float>());
wide_ft pf = {1.0f, 0.5f*(1.0f+ep*4), -1.3f, 1.0f+ep};
wide_ft qf = {ep/8, 0.5f, -1.3f, -ep/2};
auto [a, e] = eve::two_add(pf, qf);
std::cout << "---- simd" << std::setprecision(10) << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> two_add(pf, qf) = [" << '\n'
<< " " << a << ", \n"
<< " " << e << '\n'
<< " ]\n";
float xf = 120.3, yf = 130*ep;
auto [sa, se] = eve::two_add(xf, yf);
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> two_add(xf, yf) = [" << sa << ", " << se << "]\n";
return 0;
}
constexpr callable_eps_ eps
Callable object computing the machine epsilon.
Definition: eps.hpp:60
constexpr callable_two_add_ two_add
Callable object computing the two_add operation.
Definition: two_add.hpp:64
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65