E.V.E
v2022.09.01

◆ frac

eve::frac = {}
inlineconstexpr

Computes the fractional part of the input.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T >
T frac(T x) noexcept;
}
constexpr callable_frac_ frac
Computes the fractional part of the input.
Definition: frac.hpp:70
Definition: all_of.hpp:22

Parameters

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.

For complex inputs the frac operation is applied to both real and imaginary parts.

Example

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

Semantic Modifiers

  • Masked Call

    The call eve;frac[mask](x) provides a masked version of eve::frac which is equivalent to if_else (mask, frac(x), x).

    Example

    #include <eve/module/core.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 != 2.3f](pf) = " << eve::frac[pf != 2.3f](pf) << '\n';
    return 0;
    }