E.V.E
v2023.02.15
Loading...
Searching...
No Matches

◆ two_div_approx

auto eve::two_div_approx = functor<two_div_approx_t>
inlineconstexpr

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
constexpr auto two_div_approx(floating_value auto x, floating_value auto y) noexcept;
}
The concept floating_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:116
constexpr auto two_div_approx
Computes the elementwise pair of division and error,.
Definition two_div_approx.hpp:70
EVE Main Namespace.
Definition abi.hpp:19

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 an approximation in doubled precision to x \(\odiv\)y, where \(\oplus\) (resp. \(\odiv\)) adds (resp. divides) its two parameters with infinite precision.

Example

// revision 1
#include <eve/module/core.hpp>
#include <iostream>
#include <iomanip>
int main()
{
eve::wide wf0 = {3.0f, 2.5f, -32.7f, 1.0f};
eve::wide wf1 = {4.2f, 1.5f, -100.834f, eve::eps(eve::as<float>())/2};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wf1 = " << wf1 << "\n";
std::cout << "-> two_div_approx(wf0, wf1) = " << eve::two_div_approx(wf0, wf1) << "\n";
auto [d, e] = eve::two_div_approx(1.0f, 3.0f);
std::cout << std::setprecision(15);
std::cout << double(d) << " + " << double(e) << std::endl;
std::cout << double(e)+double(d) << std::endl;
std::cout << 1.0/3.0 << std::endl;
std::cout << 1.0f/3.0f << std::endl;
std::cout << 1.0/3.0 - (double(e)+double(d))<< std::endl;
}
constexpr auto eps
Computes a constant to the machine epsilon.
Definition eps.hpp:74
Lightweight type-wrapper.
Definition as.hpp:29
Wrapper for SIMD registers.
Definition wide.hpp:94