E.V.E
v2023.02.15
Loading...
Searching...
No Matches
IEEE operations

Detailed Description

Operations related to classical IEEE functions and the floating representation of real numbers

most of the standard function are present, but their names and calls can slightly change.

  • ifrexp and frexp are similar to std:frexp, but return a kumi::tuple of two values mantissa and exponent. For ifrexp the exponent is and integral value, but for frexp it is a floating value.
  • mantissa and exponent also exists individually but TAKE CARE they are not equal to the pair returned by ifrexp
  • nextafter comes along next and prev that can take a second scalar integral parameter say n which indicates one want the nth representable value that follows (resp. precedes) the first parameter.

Namespaces

namespace  eve::_

Variables

constexpr auto eve::bitofsign = functor<bitofsign_t>
 elementwise_callable object computing the bit of sign.
constexpr auto eve::exponent = functor<exponent_t>
 elementwise_callable object computing the integral IEEE exponent of the floating value.
constexpr auto eve::flush_denormal = functor<flush_denormal_t>
 elementwise_callable object computing flushing denormal values to 0.
constexpr auto eve::frexp = functor<frexp_t>
 elementwise_callable computing the ieee pair of mantissa and exponent of a floating value,
constexpr auto eve::ifrexp = functor<ifrexp_t>
 Computes the elementwise ieee pair of mantissa and exponent of the floating value,.
constexpr auto eve::ilogb = functor<ilogb_t>
 elementwise_callable object computing the integral IEEE ilogb of the floating value.
constexpr auto eve::ldexp = functor<ldexp_t>
 strict_elementwise callable computing \(\textstyle x 2^n\).
constexpr auto eve::mantissa = functor<mantissa_t>
 elementwise_callable object computing the IEEE mantissa of the floating value.
constexpr auto eve::nb_values = functor<nb_values_t>
 elementwise_callable object computing the number of values representable in the type between the arguments.
constexpr auto eve::next = functor<next_t>
 strict_elementwise_callable computing the nth next representable element
constexpr auto eve::nextafter = functor<nextafter_t>
 elementwise_callable object computing the next representable element in the second parameter direction.
constexpr auto eve::nextint = functor<nextint_t>
 Computes the next representable integer if it exists.
constexpr auto eve::of_class = functor<of_class_t>
 strict_elementwise_callable object computing classification of elements of the input.
constexpr auto eve::prev = functor<prev_t>
 Computes the nth previous representable element.
constexpr auto eve::prevint = functor<prevint_t>
 Computes the previous representable integer if it exists.
constexpr auto eve::ulpdist = functor<ulpdist_t>
 Computes the unit in the last place distance of its arguments. i.e. the number of representable values between these two divided by 2.

Variable Documentation

◆ bitofsign

auto eve::bitofsign = functor<bitofsign_t>
inlineconstexpr

elementwise_callable object computing the bit of sign.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bitofsign(value auto x) noexcept; // 1
// Lanes masking
constexpr auto bitofsign[conditional_expr auto c](value auto x) noexcept; // 2
constexpr auto bitofsign[logical_value auto m](value auto x) noexcept; // 2
}
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition value.hpp:134
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition value.hpp:34
constexpr auto bitofsign
elementwise_callable object computing the bit of sign.
Definition bitofsign.hpp:82
EVE Main Namespace.
Definition abi.hpp:19

Parameters

Return value

  1. The value of the bit of sign is returned.
  2. The operation is performed conditionally.
Note

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> bitofsign(wf0) = " << eve::bitofsign(wf0) << "\n";
std::cout << "-> bitofsign[ignore_last(2)](wf0) = " << eve::bitofsign[eve::ignore_last(2)](wf0) << "\n";
std::cout << "-> bitofsign[wf0 != 0](wf0) = " << eve::bitofsign[wf0 != 0](wf0) << "\n";
std::cout << "-> bitofsign(wu0) = " << eve::bitofsign(wu0) << "\n";
std::cout << "-> bitofsign[ignore_last(2)](wu0) = " << eve::bitofsign[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> bitofsign[wu0 != 0](wu0) = " << eve::bitofsign[wu0 != 0](wu0) << "\n";
std::cout << "-> bitofsign(wi0) = " << eve::bitofsign(wi0) << "\n";
std::cout << "-> bitofsign[ignore_last(2)](wi0) = " << eve::bitofsign[eve::ignore_last(2)](wi0) << "\n";
std::cout << "-> bitofsign[wi0 != 0](wi0) = " << eve::bitofsign[wi0 != 0](wi0) << "\n";
}
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition conditional.hpp:361
Wrapper for SIMD registers.
Definition wide.hpp:94

◆ exponent

auto eve::exponent = functor<exponent_t>
inlineconstexpr

elementwise_callable object computing the integral IEEE exponent of the floating value.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto exponent(floating_value auto x) noexcept; // 1
// Semantic options
constexpr auto exponent[raw](floating_value auto x) noexcept; // 2
}
The concept floating_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:116
constexpr auto raw
Performs the operation minimally, trading accuracy for speed.
Definition core.hpp:95
constexpr auto exponent
elementwise_callable object computing the integral IEEE exponent of the floating value.
Definition exponent.hpp:85

Parameters

Return value

  1. The value of the IEEE exponent is returned. In particular:
    • inf, minf and nan return maxexponent plus 1
    • zero returns zero 2 identical except that results for zero, nan and infinite inputs are unspecified
Note
The exponent \(e\) and mantissa \(m\) of a floating point entry \(x\) are related by \(x = m\times 2^e\), with \(|m| \in \{0\} \cup [1, 2[\).

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "-> exponent(wf0) = " << eve::exponent(wf0) << "\n";
std::cout << "-> exponent[raw](wf0) = " << eve::exponent[eve::raw](wf0) << "\n";
}

◆ flush_denormal

auto eve::flush_denormal = functor<flush_denormal_t>
inlineconstexpr

elementwise_callable object computing flushing denormal values to 0.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto flush_denormal(value auto x) noexcept; // 1
// Lanes masking
constexpr auto flush_denormal[conditional_expr auto c](value auto x) noexcept; // 2
constexpr auto flush_denormal[logical_value auto m](value auto x) noexcept; // 2
}
constexpr auto flush_denormal
elementwise_callable object computing flushing denormal values to 0.
Definition flush_denormal.hpp:68

Parameters

Return value

  1. denormal values are flushed to zero.
  2. The operation is performed conditionally.

External references

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
auto maxd = eve::prev(spv);
eve::wide wf0{0.0, 1.0, 2.0, 3.0, spv, mind, maxd, -0.0};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "-> flush_denormal(wf0) = " << eve::flush_denormal(wf0) << "\n";
std::cout << "-> flush_denormal[ignore_last(2)](wf0) = " << eve::flush_denormal[eve::ignore_last(2)](wf0) << "\n";
std::cout << "-> flush_denormal[wf0 != md](wf0) = " << eve::flush_denormal[wf0 != mind](wf0) << "\n";
}
constexpr auto mindenormal
Computes the smallest denormal positive value.
Definition mindenormal.hpp:71
constexpr auto smallestposval
Computes the smallest normal positive value.
Definition smallestposval.hpp:71
constexpr auto prev
Computes the nth previous representable element.
Definition prev.hpp:102
Lightweight type-wrapper.
Definition as.hpp:29

◆ frexp

auto eve::frexp = functor<frexp_t>
inlineconstexpr

elementwise_callable computing the ieee pair of mantissa and exponent of a floating value,

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto frexp(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto frexp[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto frexp[logical_value auto m](floating_value auto x) noexcept; // 2
// Semantic options
constexpr auto frexp[pedantic](floating_value x) noexcept; // 3
}
constexpr auto pedantic
Follows the corner cases of the corresponding standard function.
Definition core.hpp:91
constexpr auto frexp
elementwise_callable computing the ieee pair of mantissa and exponent of a floating value,
Definition frexp.hpp:77

Parameters

Return value

  1. returns a kumi::tuple {m,e} of values of the same type as x, which are related by \(x = m\times 2^e\), with \(|m| \in [0.5, 1.5[\). However, the cases \(x = \pm\infty\) or is a Nan or a denormal are undefined.
  2. The operation is performed conditionally.
  3. this option takes also properly care of the cases where \(x = \pm0, \pm\infty\) or is a Nan, where \(m=x\) and \(e=0\) and of the denormal cases.

External references

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "-> frexp(wf0) = " << eve::frexp(wf0) << "\n";
std::cout << "-> frexp[pedantic](wf0) = " << eve::frexp[eve::pedantic](wf0) << "\n";
}

◆ ifrexp

auto eve::ifrexp = functor<ifrexp_t>
inlineconstexpr

Computes the elementwise ieee pair of mantissa and exponent of the floating value,.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto ifrexp(floating_value auto x) noexcept; // 1
// Semantic options
constexpr auto ifrexp[pedantic](floating_value x) noexcept; // 2
}
constexpr auto ifrexp
Computes the elementwise ieee pair of mantissa and exponent of the floating value,...
Definition ifrexp.hpp:70

Parameters

Return value

  1. Computes the elementwise ieee ifrexp of the floating value, returning a pair {m,e} of values m being of the same type as x and e of the associated integral type, which are related by \(x = m\times 2^e\), with \(|m| \in [0.5, 1.5[\). However, the cases \(x = \pm\infty\) or is a Nan or a denormal are undefined.
  2. This call takes also properly care of the cases where \(x = \pm0, \pm\infty\) or is a Nan, where \(m=x\) and \(e=0\) and of the denormal cases.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "-> ifrexp(wf0) = " << eve::ifrexp(wf0) << "\n";
std::cout << "-> ifrexp[pedantic](wf0) = " << eve::ifrexp[eve::pedantic](wf0) << "\n";
}

◆ ilogb

auto eve::ilogb = functor<ilogb_t>
inlineconstexpr

elementwise_callable object computing the integral IEEE ilogb of the floating value.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
template < floating_value T> constexpr as_integer_t<T> ilogb(T x) noexcept;
constexpr auto ilogb
elementwise_callable object computing the integral IEEE ilogb of the floating value.
Definition ilogb.hpp:69

Parameters

Return value

The spirit of the value of the std::ilogb is returned. In particular:

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wd = {0.0, -1.0, 8.0, 1.5, 2.0, 16.0, 15.3, 17.2};
std::cout << "<- wd = " << wd << "\n";
std::cout << "-> ilogb(wd) = " << eve::ilogb(wd) << "\n";
std::cout << "-> ilogb[ignore_last(2)](wd)= " << eve::ilogb[eve::ignore_last(2)](wd) << "\n";
std::cout << "-> ilogb[wd != 2.0](wd) = " << eve::ilogb[wd != 2.0](wd) << "\n";
}

◆ ldexp

auto eve::ldexp = functor<ldexp_t>
inlineconstexpr

strict_elementwise callable computing \(\textstyle x 2^n\).

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto ldexp(floating_value auto x, integral_value N) noexcept; // 1
// Lanes masking
constexpr auto ldexp[conditional_expr auto c](floating_value auto x), integral_value N) noexcept; // 2
constexpr auto ldexp[logical_value auto m](floating_value auto x, integral_value N) noexcept; // 2
// Semantic options
constexpr auto abs[pedantic](floating_value auto x, integral_value N) noexcept; // 3
}
The concept integral_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:51
constexpr auto abs
elementwise_callable object computing the absolute value of the parameter.
Definition abs.hpp:86
constexpr auto ldexp
strict_elementwise callable computing .
Definition ldexp.hpp:83

Parameters

Return value

  1. The value of \(\textstyle x 2^n\) is returned.
  2. The operation is performed conditionally.
  3. Takes extra care to handling limit values.
    • If x is \(\pm0\), it is returned, unmodified.
    • If x is \(\pm\infty\), it is returned, unmodified.
    • If n is 0, then x is returned, unmodified.
    • If x is NaN, NaN is returned.

External references

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, 1, 2, 3, 4, 5, 6, 7};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "-> ldexp(wf0, wi0) = " << eve::ldexp(wf0, wi0) << "\n";
std::cout << "-> ldexp[ignore_last(2)](wf0, wi0) = " << eve::ldexp[eve::ignore_last(2)](wf0, 2*wi0) << "\n";
std::cout << "-> ldexp[wf0 != 0](wf0, wi0) = " << eve::ldexp[wf0 != 0](wf0, wi0) << "\n";
std::cout << "-> ldexp(wf0, wi1) = " << eve::ldexp(wf0, wi1) << "\n";
std::cout << "-> ldexp[ignore_last(2)](wf0, wi1 = " << eve::ldexp[eve::ignore_last(2)](wf0, wi1) << "\n";
std::cout << "-> ldexp[wi1 != 2](wf0, wi1) = " << eve::ldexp[wi1 != 2](wf0, wi1) << "\n";
}

◆ mantissa

auto eve::mantissa = functor<mantissa_t>
inlineconstexpr

elementwise_callable object computing the IEEE mantissa of the floating value.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto mantissa(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto mantissa[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto mantissa[logical_value auto m](floating_value auto x) noexcept; // 2
// Semantic options
constexpr auto mantissa[raw](floating_value auto x) noexcept; // 3
}
constexpr auto mantissa
elementwise_callable object computing the IEEE mantissa of the floating value.
Definition mantissa.hpp:81

Parameters

Return value

  1. The value of the IEEE mantissa is returned. In particular:
    • nan returns nan
    • \(\pm\infty\) returns \(\pm\1\).
    • zero returns zero
  2. The operation is performed conditionally.
  3. The results for zero and nan are unspecified.
Note
The exponent \(e\) and mantissa \(m\) of a floating point entry \(x\) are related by \(x = m\times 2^e\), with \(|m| \in \{0, nan\} \cup [1, 2[\).

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "-> mantissa(wf0) = " << eve::mantissa(wf0) << "\n";
std::cout << "-> mantissa[ignore_last(2)](wf0) = " << eve::mantissa[eve::ignore_last(2)](wf0) << "\n";
std::cout << "-> mantissa[wf0 != 0](wf0) = " << eve::mantissa[wf0 != 0](wf0) << "\n";
std::cout << "-> mantissa[raw](wf0) = " << eve::mantissa[eve::raw](wf0) << "\n";
}

◆ nb_values

auto eve::nb_values = functor<nb_values_t>
inlineconstexpr

elementwise_callable object computing the number of values representable in the type between the arguments.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto nb_values(eve::value auto x, eve::value auto y) noexcept; // 1
// Lanes masking
constexpr auto nb_values[conditional_expr auto c](eve::value auto x, eve::value auto y) noexcept; // 2
constexpr auto nb_values[logical_value auto m](eve::value auto x, eve::value auto y) noexcept; // 2
}
constexpr auto nb_values
elementwise_callable object computing the number of values representable in the type between the argu...
Definition nb_values.hpp:72

Parameters

Return value

  1. Returns the number of values representable in the type in the interval [x, y[
  2. The operation is performed conditionally.

Example

◆ next

auto eve::next = functor<next_t>
inlineconstexpr

strict_elementwise_callable computing the nth next representable element

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto next(value auto x) noexcept; // 1
constexpr auto next(value auto x, integral_value auto n) noexcept; // 2
// Lanes masking
constexpr auto next[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3
constexpr auto next[logical_value auto m](/* any of the above overloads */) noexcept; // 3
// Exclusive Semantic options - Only one of those can be set at once
constexpr auto next[pedantic](/* any of the above overloads */) noexcept; // 4
constexpr auto next[saturated ](/* any of the above overloads */) noexcept; // 5
constexpr auto next[raw](value auto x) noexcept; // 6
}
constexpr auto saturated
Keeps the result inside the range of its type instead of wrapping or overflowing.
Definition core.hpp:104
constexpr auto next
strict_elementwise_callable computing the nth next representable element
Definition next.hpp:107

Parameters

Return value

  1. the least representable value greater than x is returned.
  2. the nth representable value greater than x is returned. If n is zero returns x.
  3. The operation is performed conditionally
  4. if x is floating the call with mzero returns zero
  5. ensures that the input is never greater than the result of the call.
  6. works only if inputs are normal numbers (this excludes floating zeroes, denormals or not finite) the option has no influence on the two parameters calls

If n is zero returns x.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
#include <iomanip>
int main()
{
eve::wide wf0 = {-0.0f, 2.0f, eve::eps(eve::as<float>()), 0.0f, 30.0f,eve::mindenormal(eve::as<float>()),
eve::wide wi0 = {-1, 2, -3, -4, 327654, 32765, 32766, 32767 };
eve::wide wu0 = {0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << std::hexfloat;
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> next(wf0) = " << eve::next(wf0) << "\n";
std::cout << "-> next(wf0, wi1) = " << eve::next(wf0, 2) << "\n";
std::cout << "-> next[ignore_last(2)](wf0) = " << eve::next[eve::ignore_last(2)](wf0) << "\n";
std::cout << "-> next[wf0 != 0](wf0) = " << eve::next[wf0 != 0](wf0) << "\n";
std::cout << "-> next[pedantic](wf0) = " << eve::next[eve::pedantic](wf0) << "\n";
std::cout << "-> next[saturated ](wi0) = " << eve::next[eve::saturated ](wi0) << "\n";
std::cout << "-> next(wu0) = " << eve::next(wu0) << "\n";
std::cout << "-> next(wi0) = " << eve::next(wi0) << "\n";
std::cout << "-> next(wi0, wu0) = " << eve::next(wi0, wu0) << "\n";
}
constexpr auto nan
Computes the IEEE quiet NaN constant.
Definition nan.hpp:67
constexpr auto eps
Computes a constant to the machine epsilon.
Definition eps.hpp:74
constexpr auto inf
Computes the infinity ieee value.
Definition inf.hpp:67

◆ nextafter

auto eve::nextafter = functor<nextafter_t>
inlineconstexpr

elementwise_callable object computing the next representable element in the second parameter direction.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto nextafter(eve::value auto x, eve::value auto ... xs) noexcept; // 1
// Lanes masking
constexpr auto nextafter[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3
constexpr auto nextafter[logical_value auto m](/* any of the above overloads */) noexcept; // 3
// Semantic options
constexpr auto nextafter[pedantic](/* any of the above overloads */) noexcept; // 4
}
constexpr auto nextafter
elementwise_callable object computing the next representable element in the second parameter directio...
Definition nextafter.hpp:76

Parameters

Return value

  1. the next representable value after x in the y direction is returned. If y == x returns x.
  2. The operation is performed conditionally
  3. Provides a version of nextafter for which floating plus zero and minus zero are distinct.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wf1{0.0, -4.0, 1.0, -1.0, 2.0, -2.0, 3.0, -3.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, -4, 1, -1, 2, -2, 3, -3};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
eve::wide wu1{7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wf1 = " << wf1 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "<- wu1 = " << wu1 << "\n";
std::cout << "-> nextafter(wf0, wf1) = " << eve::nextafter(wf0, wf1) << "\n";
std::cout << "-> nextafter[ignore_last(2)](wf0, wf1) = " << eve::nextafter[eve::ignore_last(2)](wf0, wf1) << "\n";
std::cout << "-> nextafter[wf0 != 0](wf0, wf1) = " << eve::nextafter[wf0 != 0](wf0, wf1) << "\n";
std::cout << "-> nextafter[pedantic](wf0, wf1) = " << eve::nextafter[eve::pedantic](wf0, wf1) << "\n";
std::cout << "-> nextafter(wu0, wu1) = " << eve::nextafter(wu0, wu1) << "\n";
std::cout << "-> nextafter(wi0, wi1) = " << eve::nextafter(wi0, wi1) << "\n";
}

◆ nextint

auto eve::nextint = functor<nextint_t>
inlineconstexpr

Computes the next representable integer if it exists.

This function is equivalent to inc for integral types. For floating point types, it will skip over the non-representable values between the input and the next representable integer.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto nextint(value auto x) noexcept; // 1
// Lanes masking
constexpr auto nextint[conditional_expr auto c](/* any of the above overloads */) noexcept; // 2
constexpr auto nextint[logical_value auto m](/* any of the above overloads */) noexcept; // 2
// Exclusive Semantic options - Only one of those can be set at once
constexpr auto nextint[raw](value auto x) noexcept; // 3
constexpr auto nextint[saturated](value auto x) noexcept; // 4
}
constexpr auto nextint
Computes the next representable integer if it exists.
Definition nextint.hpp:83

Parameters

Return value

  1. the smallest representable integer value greater than x is returned.
  2. The operation is performed conditionally
  3. same as 1. but -inf returns nan.
  4. ensures that the input is never greater than the result of the call. (It can be equal for maximal representable value)

Example

#include <eve/eve.hpp>
#include <iostream>
int main()
{
static_cast<eve::float16_t>(-0.0f),
static_cast<eve::float16_t>(0.0f),
static_cast<eve::float16_t>(32768.0f),
static_cast<eve::float16_t>(-32768.0f),
};
std::cout << "<- w = " << w << "\n";
std::cout << "-> nextint(w) = " << eve::nextint(w) << "\n";
std::cout << "-> nextint[saturated](w) = " << eve::nextint[eve::saturated](w) << "\n";
std::cout << "-> nextint[raw](w) = " << eve::nextint[eve::raw](w) << "\n";
eve::wide<std::int16_t, eve::fixed<4>> iw{0, 1, 32767, -32768};
std::cout << "<- iw = " << iw << "\n";
std::cout << "-> nextint(iw) = " << eve::nextint(iw) << "\n";
std::cout << "-> nextint[saturated](iw) = " << eve::nextint[eve::saturated](iw) << "\n";
std::cout << "-> nextint[raw](iw) = " << eve::nextint[eve::raw](iw) << "\n";
}
constexpr auto valmax
Computes the greatest representable value.
Definition valmax.hpp:67
constexpr auto minf
Computes the -infinity ieee value.
Definition minf.hpp:67
IEEE 754 binary16 floating-point type.
Definition float16.hpp:189

◆ of_class

auto eve::of_class = functor<of_class_t>
inlineconstexpr

strict_elementwise_callable object computing classification of elements of the input.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
template<std::uint8_t I, eve::floating_value T>
constexpr auto of_class(value auto x, fp_class<I> i) noexcept;
}
constexpr auto of_class
strict_elementwise_callable object computing classification of elements of the input.
Definition of_class.hpp:88

Parameters

  • x: value.
  • i: combination of floating point classes to check

Return value

the elementwise logical result of the classification.

Note
The iparameter can be constructed easily by using the values qnan, poszero, negzero, posinf,neginf, denorn,neg, snan defined in the namespace eve and the | operator (see the example below).
name meaning
qnan quiet NaN
poszero positive zero
negzero negative zero
posinf positive infinite
neginf negative infinite
denorm denormal number
neg negative finite
snan signaling NaN

Actually snan and qnan are not distinguished in simd wide.

External references

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, -2.0, nan, inf, mind, inf, -0.0};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "-> of_class(wf0, eve::qnan ) = " << eve::of_class(wf0, eve::qnan ) << "\n";
std::cout << "-> of_class(wf0, eve::poszero) = " << eve::of_class(wf0, eve::poszero) << "\n";
std::cout << "-> of_class(wf0, eve::negzero) = " << eve::of_class(wf0, eve::negzero) << "\n";
std::cout << "-> of_class(wf0, eve::posinf ) = " << eve::of_class(wf0, eve::posinf ) << "\n";
std::cout << "-> of_class(wf0, eve::neginf ) = " << eve::of_class(wf0, eve::neginf ) << "\n";
std::cout << "-> of_class(wf0, eve::denorm ) = " << eve::of_class(wf0, eve::denorm ) << "\n";
std::cout << "-> of_class(wf0, eve::neg ) = " << eve::of_class(wf0, eve::neg ) << "\n";
std::cout << "-> of_class(wf0, eve::snan ) = " << eve::of_class(wf0, eve::snan ) << "\n";
std::cout << "-> of_class(wf0, eve::poszero|eve::negzero|eve::posinf) = " << eve::of_class(wf0, eve::poszero|eve::negzero|eve::posinf) << "\n";
}

◆ prev

auto eve::prev = functor<prev_t>
inlineconstexpr

Computes the nth previous representable element.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto prev(value auto x) noexcept; // 1
constexpr auto prev(value auto x, integral_value auto n) noexcept; // 2
// Lanes masking
constexpr auto prev[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3
constexpr auto prev[logical_value auto m](/* any of the above overloads */) noexcept; // 3
// Exclusive Semantic options - Only one of those can be set at once
constexpr auto prev[pedantic](/* any of the above overloads */) noexcept; // 4
constexpr auto prev[saturated ](/* any of the above overloads */) noexcept; // 5
constexpr auto prev[raw](value auto x) noexcept; // 6
}

Parameters

Return value

  1. the greatest representable value less than x is returned.
  2. the nth representable value less than x is returned. If n is zero returns x.
  3. The operation is performed conditionally
  4. if x is floating zero and mzero are considered distinct.
  5. ensures that the input is never less than the result of the call.
  6. works only if inputs are normal numbers (this excludes floating zeroes, denormals or not finite). the option has no influence on the two parameters calls

If n is zero returns x.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0 = {-0.0f, 2.0f, eve::eps(eve::as<float>()), 0.0f, 30.0f,eve::mindenormal(eve::as<float>()),
eve::wide wi0 = {-1, 2, -3, -4, -32765, -32766, -32767, -32768 };
eve::wide wu0 = {0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> prev(wf0) = " << eve::prev(wf0) << "\n";
std::cout << "-> prev(wf0, wi1) = " << eve::prev(wf0, wu0) << "\n";
std::cout << "-> prev[ignore_last(2)](wf0) = " << eve::prev[eve::ignore_last(2)](wf0) << "\n";
std::cout << "-> prev[wf0 != 0](wf0) = " << eve::prev[wf0 != 0](wf0) << "\n";
std::cout << "-> prev[pedantic](wf0) = " << eve::prev[eve::pedantic](wf0) << "\n";
std::cout << "-> prev[saturated ](wi0) = " << eve::prev[eve::saturated ](wi0) << "\n";
std::cout << "-> prev(wu0) = " << eve::prev(wu0) << "\n";
std::cout << "-> prev(wi0) = " << eve::prev(wi0) << "\n";
std::cout << "-> prev(wi0, wu0) = " << eve::prev(wi0, wu0) << "\n";
}

◆ prevint

auto eve::prevint = functor<prevint_t>
inlineconstexpr

Computes the previous representable integer if it exists.

This function is equivalent to dec for integral types. For floating point types, it will skip over the non-representable values between the input and the previous representable integer.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto prevint(value auto x) noexcept; // 1
// Lanes masking
constexpr auto prevint[conditional_expr auto c](/* any of the above overloads */) noexcept; // 2
constexpr auto prevint[logical_value auto m](/* any of the above overloads */) noexcept; // 2
// Exclusive Semantic options - Only one of those can be set at once
constexpr auto prevint[raw](value auto x) noexcept; // 3
constexpr auto prevint[saturated](value auto x) noexcept; // 4
}
constexpr auto prevint
Computes the previous representable integer if it exists.
Definition prevint.hpp:83

Parameters

Return value

  1. The greatest representable integer value less than x is returned.
  2. The operation is performed conditionally
  3. same as 1. but inf returns nan.
  4. ensures that the input is never less than the result of the call. (It can be equal for minimal representable value)

Example

#include <eve/eve.hpp>
#include <iostream>
int main()
{
static_cast<eve::float16_t>(-0.0f),
static_cast<eve::float16_t>(0.0f),
static_cast<eve::float16_t>(32768.0f),
static_cast<eve::float16_t>(-32768.0f),
};
std::cout << "<- w = " << w << "\n";
std::cout << "-> prevint(w) = " << eve::prevint(w) << "\n";
std::cout << "-> prevint[saturated](w) = " << eve::prevint[eve::saturated](w) << "\n";
std::cout << "-> prevint[raw](w) = " << eve::prevint[eve::raw](w) << "\n";
eve::wide<std::int16_t, eve::fixed<4>> iw{0, 1, 32767, -32768};
std::cout << "<- iw = " << iw << "\n";
std::cout << "-> prevint(iw) = " << eve::prevint(iw) << "\n";
std::cout << "-> prevint[saturated](iw) = " << eve::prevint[eve::saturated](iw) << "\n";
std::cout << "-> prevint[raw](iw) = " << eve::prevint[eve::raw](iw) << "\n";
}
constexpr auto valmin
Computes the lowest representable value.
Definition valmin.hpp:67

◆ ulpdist

auto eve::ulpdist = functor<ulpdist_t>
inlineconstexpr

Computes the unit in the last place distance of its arguments. i.e. the number of representable values between these two divided by 2.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto ulpdist(floating_value auto x, floating_value auto y) noexcept; // 1
// Lanes masking
constexpr auto ulpdist[conditional_expr auto c][floating_value auto x, floating_value auto y) noexcept; // 3
constexpr auto ulpdist[logical_value auto m](floating_value auto x, floating_value auto y) noexcept; // 3
}
constexpr auto ulpdist
Computes the unit in the last place distance of its arguments. i.e. the number of representable value...
Definition ulpdist.hpp:78

Parameters

Return value

  1. Computes elementwise the 'units in the last place' distance between x and y.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wf1{0.0, -4.0, 1.0, -1.0, 2.0, -2.0, 3.0, -3.0};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wf1 = " << wf1 << "\n";
std::cout << "-> ulpdist(wf0, wf1) = " << eve::ulpdist(wf0, wf1) << "\n";
std::cout << "-> ulpdist[ignore_last(2)](wf0, wf1) = " << eve::ulpdist[eve::ignore_last(2)](wf0, wf1) << "\n";
std::cout << "-> ulpdist[wf0 != -2.0f](wf0, wf1) = " << eve::ulpdist[wf0 != -2.0f](wf0, wf1) << "\n";
}