E.V.E
v2023.02.15

◆ two_prod

eve::two_prod = {}
inlineconstexpr

Computes the elementwise pair of product and error,.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::floating_value T, eve::floating_value U >
auto two_prod(T x, U y) noexcept;
}
constexpr callable_two_prod_ two_prod
Computes the elementwise pair of product and error,.
Definition: two_prod.hpp:65
Definition: abi.hpp:18

Parameters

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 \(\otimes\)y

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

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
int main()
{
float ep = eve::eps(eve::as<float>());
wide_ft pf = {1.0f+ep, 0.5f*(1.0f+ep*4), -1.3f, 1.0f+4*ep};
wide_ft qf = {1.0f-ep, 0.5f, -1.3f, 1.0f-ep/2};
auto [a, e] = eve::two_prod(pf, qf);
std::cout << "---- simd" << std::setprecision(10) << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> two_prod(pf, qf) = [" << '\n'
<< " " << a << ", \n"
<< " " << e << '\n'
<< " ]\n";
float xf = 1+ep, yf = 1-ep;
auto [sa, se] = eve::two_prod(xf, yf);
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> two_prod(xf, yf) = [" << sa << ", " << se << "]\n";
return 0;
}
constexpr callable_eps_ eps
Computes the the machine epsilon.
Definition: eps.hpp:63
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65