E.V.E
v2022.03.00

◆ rat

eve::rat = {}
inlineconstexpr

Computes a rational approximation.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::real_value T>
kumi::tuple<T, T> rat(T x, T tol = T(1.0e-6)*eve::abs(x)) noexcept;
}
constexpr callable_rat_ rat
Computes a rational approximation.
Definition: rat.hpp:61
constexpr callable_abs_ abs
Computes the absolute value of the parameter.
Definition: abs.hpp:107
Definition: all_of.hpp:22

Parameters

Return value

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

Example

//==================================================================================================
#include <eve/module/core.hpp>
//==================================================================================================
#include <eve/module/core.hpp>
#include <eve/module/math.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_nan_ nan
Computes the IEEE NaN constant.
Definition: nan.hpp:53
constexpr callable_minf_ minf
Computes the -infinity ieee value.
Definition: minf.hpp:95
constexpr callable_inf_ inf
Computes the infinity ieee value.
Definition: inf.hpp:58
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65