E.V.E  0.1-beta

◆ frac

eve::frac = {}
inlineconstexpr

Callable object computing the fractional part of a value.

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

Members Functions

Member Effect
operator() the computation of the fractional part of a value
operator[] Construct a conditional version of current function object

auto operator()(value auto x) const noexcept;
Definition: value.hpp:31

Parameters

x: value.

Return value

Returns a value with the same type as x containing the elementwise fractional part of x with the same sign as x.

In particular:

  • If an element of x is \(\pm0\), \(\pm0\) is returned.
  • If an element of x is \(\pm\infty\) or Nan, a Nan is returned.

auto operator[]( conditional_expression auto cond ) const noexcept;

Higher-order function generating a masked version of eve::frac

Parameters

cond : conditional expression

Return value

A Callable object so that the expression frac[cond](x, ...) is equivalent to if_else(cond,frac(x, ...),x)


Supported decorators

Example

See it live on Compiler Explorer

#include <eve/function/frac.hpp>
#include <eve/constant/inf.hpp>
#include <eve/constant/nan.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
int main()
{
wide_ft pf = {-1.0f, -1.3f, -0.0f, 0.0f,
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> frac(pf) = " << eve::frac(pf) << '\n';
float xf = -327.68f;
std::cout << "---- scalar" << std::setprecision(10) << '\n'
<< "<- xf = " << xf << '\n'
<< "-> frac(xf) = " << eve::frac(xf) << '\n';
return 0;
}
constexpr callable_frac_ frac
Callable object computing the fractional part of a value.
Definition: frac.hpp:80
constexpr callable_nan_ nan
Callable object computing the nan value.
Definition: nan.hpp:52
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