E.V.E  0.1-beta

◆ rat

eve::rat = {}
inlineconstexpr

Callable object computing the rational approximation.

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

Members Functions

Member Effect
operator() the computation of the rational approximation

auto operator()(floating_value auto x) const noexcept;
auto operator()( floating_value auto x, floating_value auto tol) const noexcept;
Definition: value.hpp:83

Parameters

x: floating_real_value. tol: floating_real_value. By default tol is equal to T(1.0e-6)*eve::abs(x).

Return values

Two values with the same type as x containing the elementwise numerator and denominator of the rational number approximating x.

Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

//==================================================================================================
//==================================================================================================
#include <eve/function/rat.hpp>
#include <eve/constant/pi.hpp>
#include <eve/constant/inf.hpp>
#include <eve/constant/minf.hpp>
#include <eve/constant/nan.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
using eve::as;
wide_ft pf = {1.25, 1.5, -3.123, 456.0
, eve::pi(as(0.0)), eve::inf(as(0.0)), eve::minf(as(0.0)), eve::nan(as(0.0))};
auto [n, d] = eve::rat(pf);
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> n = " << n << '\n'
<< "-> d = " << d << '\n' ;
double xf = -3.0/5.0;
auto [xn, xd] = eve::rat(xf);
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> xn = " << xn << '\n'
<< "-> xd = " << xd << '\n' ;
;
return 0;
}
constexpr callable_rat_ rat
Callable object computing the rational approximation.
Definition: rat.hpp:63
constexpr callable_nan_ nan
Callable object computing the nan value.
Definition: nan.hpp:52
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
constexpr callable_minf_ minf
Callable object computing the negative infinity value.
Definition: minf.hpp:55
constexpr callable_inf_ inf
Callable object computing the infinity ieee value.
Definition: inf.hpp:54
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65