E.V.E
v2022.03.00

◆ modf

eve::modf = {}
inlineconstexpr

Computes the elementwise pair of fractional and integral parts of the value,.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T >
kumi::tuple<T, T> modf(T x) noexcept;
}
constexpr callable_modf_ modf
Computes the elementwise pair of fractional and integral parts of the value,.
Definition: modf.hpp:76
Definition: all_of.hpp:22

Parameters

Return value

A pair of values containing respectively the elementwise fractional and integral parts of x, each having the type and sign of x.

In particular:

  • If x is infinite {Nan, x} is returned.
  • If x is a Nan {Nan, Nan} is returned.

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

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-0.0, 1.30f, -1.3f, eve::inf(eve::as<float>()), 0.0f,
eve::nan(eve::as<float>()), 0.678f, -0.678f};
auto [m, e] = eve::modf(pf);
auto [mp, ep] = eve::pedantic(eve::modf)(pf);
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> modf(pf) = [" << '\n'
<< " " << m << ", \n"
<< " " << e << '\n'
<< " ]\n"
<< "-> pedantic(modf)(pf) = [" << '\n'
<< " " << mp << ", \n"
<< " " << ep << '\n'
<< " ]\n";
float xf = 2.3;
auto [sm, se] = eve::modf(xf);
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> modf(xf) = [" << sm << ", " << se << "]\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
constexpr pedantic_type const pedantic
Higher-order Callable Object imbuing more standard semantic onto other Callable Objects.
Definition: pedantic.hpp:56
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • eve::pedantic

    The call pedantic(modf)(x) ensures standard conformity : if x is infinite, {0, x} is returned.

    Example