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

Detailed Description

Core semantic modifiers

Many core functions accept one or more of these options to change what they compute or how. Each is documented below; which functions accept which is stated on the page of every function that does.

Variables

constexpr auto eve::saturated = ::rbr::flag( saturated_mode{} )
 Keeps the result inside the range of its type instead of wrapping or overflowing.
constexpr auto eve::pedantic = ::rbr::flag( pedantic_mode{} )
 Follows the corner cases of the corresponding standard function.
constexpr auto eve::numeric = ::rbr::flag( numeric_mode{} )
 Makes NaN lose against any definite value.
constexpr auto eve::almost = {}
 Turns an equality or an ordering into its tolerant form.
constexpr auto eve::definitely = {}
 Requires a strict comparison to hold by a margin.
constexpr auto eve::raw = ::rbr::flag( raw_mode{} )
 Performs the operation minimally, trading accuracy for speed.
constexpr auto eve::fast = ::rbr::flag( fast_mode{} )
 Performs the operation faster than the regular call while keeping more accuracy than raw.
constexpr auto eve::lower = ::rbr::flag( lower_mode{} )
 Guarantees a result no greater than the exact mathematical one.
constexpr auto eve::upper = ::rbr::flag( upper_mode{} )
 Guarantees a result no smaller than the exact mathematical one.
constexpr auto eve::strict = ::rbr::flag( strict_mode{} )
 Turns the guarantee of lower or upper into a strict inequality.
constexpr auto eve::widen = ::rbr::flag( widen_mode{} )
 Computes the result in the upgraded element type.
constexpr auto eve::to_nearest = ::rbr::flag( to_nearest_mode{} )
 Rounds to the nearest integer, ties going to the even one.
constexpr auto eve::downward = ::rbr::flag( downward_mode{} )
 Rounds toward \(-\infty\).
constexpr auto eve::upward = ::rbr::flag( upward_mode{} )
 Rounds toward \(+\infty\).
constexpr auto eve::toward_zero = ::rbr::flag( toward_zero_mode{} )
 Rounds toward zero.
constexpr auto eve::to_nearest_odd = ::rbr::flag( to_nearest_odd_mode{} )
 Rounds to the nearest integer, ties going to the odd one.
constexpr auto eve::left = ::rbr::flag( left_mode{} )
 Swaps the two operands before applying the operation.
constexpr auto eve::right = ::rbr::flag( right_mode{} )
 Applies the operation in the order the operands are written.
constexpr auto eve::spherical = ::rbr::flag( spherical_mode{} )
 Selects the spherical form of a Bessel function.
constexpr auto eve::cylindrical = ::rbr::flag( cylindrical_mode{} )
 Selects the cylindrical form of a Bessel function.

Variable Documentation

◆ almost

auto eve::almost = {}
inlineconstexpr

Turns an equality or an ordering into its tolerant form.

Header file

#include <eve/module/core.hpp>

Written f[almost] the tolerance defaults to 3*eps(as(x)). Written f[almost = tol] it is whatever tol says, and the way it is read depends on its type:

  • a floating tol is a relative distance: \(|x - y| \le \mbox{tol}\cdot\max(|x|, |y|)\)
  • an integral tol is a number of representable values between the two operands
Note
Only defined for floating point values.
See also
definitely for the opposite bias.

◆ cylindrical

auto eve::cylindrical = ::rbr::flag( cylindrical_mode{} )
inlineconstexpr

Selects the cylindrical form of a Bessel function.

Header file

#include <eve/module/core.hpp>

The form the undecorated call already computes, \(J_n(z)\), named so that a call site can say which of the two it wants rather than leaving it to the default. Mirror of spherical.

◆ definitely

auto eve::definitely = {}
inlineconstexpr

Requires a strict comparison to hold by a margin.

Header file

#include <eve/module/core.hpp>

Mirror image of almost: where almost widens a test so that near misses pass, definitely narrows it so that near misses fail. is_greater[definitely = tol](x, y) holds when \(x > y + \mbox{tol}\cdot\max(|x|, |y|)\) for a floating tol, or when x exceeds the tol-th representable value after y for an integral one. Omitting tol uses 3*eps(as(x)).

Note
Only defined for floating point values.

◆ downward

auto eve::downward = ::rbr::flag( downward_mode{} )
inlineconstexpr

Rounds toward \(-\infty\).

Header file

#include <eve/module/core.hpp>

One of the four integer rounding modes.

◆ fast

auto eve::fast = ::rbr::flag( fast_mode{} )
inlineconstexpr

Performs the operation faster than the regular call while keeping more accuracy than raw.

Header file

#include <eve/module/core.hpp>

Same intent as raw, with a smaller loss of accuracy and, usually, a smaller gain.

◆ left

auto eve::left = ::rbr::flag( left_mode{} )
inlineconstexpr

Swaps the two operands before applying the operation.

Header file

#include <eve/module/core.hpp>

sub[left](a, b) is sub(b, a), and the same holds for the other operations that accept it. Useful when the order comes from the call site rather than from the intent.

◆ lower

auto eve::lower = ::rbr::flag( lower_mode{} )
inlineconstexpr

Guarantees a result no greater than the exact mathematical one.

Header file

#include <eve/module/core.hpp>

The computed value is less than or equal to the value an infinitely precise computation would give, NaN excepted. Combine with strict to make the inequality strict.

Note
Except for average on integral inputs, this has no effect on integer calls.

◆ numeric

auto eve::numeric = ::rbr::flag( numeric_mode{} )
inlineconstexpr

Makes NaN lose against any definite value.

Header file

#include <eve/module/core.hpp>

Comparisons and reductions normally propagate NaN, and which operand carries it decides the result: eve::max(nan, x) is a NaN while eve::max(x, nan) is x. Under this option a NaN never wins either way, so both spellings return x.

◆ pedantic

auto eve::pedantic = ::rbr::flag( pedantic_mode{} )
inlineconstexpr

Follows the corner cases of the corresponding standard function.

Header file

#include <eve/module/core.hpp>

The undecorated call is free to take the shortest route the hardware offers. This option asks instead for the behaviour the C++ standard prescribes on infinities, zeroes and NaNs, which is usually slower.

◆ raw

auto eve::raw = ::rbr::flag( raw_mode{} )
inlineconstexpr

Performs the operation minimally, trading accuracy for speed.

Header file

#include <eve/module/core.hpp>

Corner cases and the last bits of accuracy are given up in exchange for the shortest code path. fast makes the opposite trade, keeping more accuracy for less of a gain.

Note
Neither option guarantees a speed improvement, only that the call will not be slower than the regular one.

◆ right

auto eve::right = ::rbr::flag( right_mode{} )
inlineconstexpr

Applies the operation in the order the operands are written.

Header file

#include <eve/module/core.hpp>

The behaviour of an undecorated call, spelled out. It exists so that a call site pairing with left elsewhere can state which of the two it means instead of relying on the reader knowing the default.

◆ saturated

auto eve::saturated = ::rbr::flag( saturated_mode{} )
inlineconstexpr

Keeps the result inside the range of its type instead of wrapping or overflowing.

Header file

#include <eve/module/core.hpp>

An operation that would leave the representable range returns the nearest bound rather than the value C++ would produce, so eve::abs[saturated](valmin(as<T>())) gives valmax(as<T>()) instead of wrapping back to a negative number.

◆ spherical

auto eve::spherical = ::rbr::flag( spherical_mode{} )
inlineconstexpr

Selects the spherical form of a Bessel function.

Header file

#include <eve/module/core.hpp>

bessel_j[spherical](n, z) computes \(j_n(z)\) where the plain call computes \(J_n(z)\). Accepted by the four Bessel families.

◆ strict

auto eve::strict = ::rbr::flag( strict_mode{} )
inlineconstexpr

Turns the guarantee of lower or upper into a strict inequality.

Header file

#include <eve/module/core.hpp>

Only meaningful next to lower or upper. The bound is then strict, which usually costs one bit of accuracy and buys some speed.

Note
Unlike lower and upper, this is not accepted by the constants.

◆ to_nearest

auto eve::to_nearest = ::rbr::flag( to_nearest_mode{} )
inlineconstexpr

Rounds to the nearest integer, ties going to the even one.

Header file

#include <eve/module/core.hpp>

One of the four integer rounding modes.

◆ to_nearest_odd

auto eve::to_nearest_odd = ::rbr::flag( to_nearest_odd_mode{} )
inlineconstexpr

Rounds to the nearest integer, ties going to the odd one.

Header file

#include <eve/module/core.hpp>

Experimental, and accepted by add only.

◆ toward_zero

auto eve::toward_zero = ::rbr::flag( toward_zero_mode{} )
inlineconstexpr

Rounds toward zero.

Header file

#include <eve/module/core.hpp>

One of the four integer rounding modes.

◆ upper

auto eve::upper = ::rbr::flag( upper_mode{} )
inlineconstexpr

Guarantees a result no smaller than the exact mathematical one.

Header file

#include <eve/module/core.hpp>

Mirror image of lower: the computed value is greater than or equal to the exact one, NaN excepted.

◆ upward

auto eve::upward = ::rbr::flag( upward_mode{} )
inlineconstexpr

Rounds toward \(+\infty\).

Header file

#include <eve/module/core.hpp>

One of the four integer rounding modes.

◆ widen

auto eve::widen = ::rbr::flag( widen_mode{} )
inlineconstexpr

Computes the result in the upgraded element type.

Header file

#include <eve/module/core.hpp>

The computation and its result use the type twice as wide as the parameters' element type. Returning to the original width, when needed, is left to the caller through convert.

Note
64 bits types are their own upgrade, so the option does nothing for them.