|
Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
|
TrackedBounded wraps a scalar type with rigorous interval bounds. More...
#include <tracked_bounded.hpp>
Public Types | |
| using | value_type = T |
Public Member Functions | |
| constexpr | TrackedBounded () noexcept |
| Default constructor: zero interval [0, 0]. | |
| TrackedBounded (T v) noexcept | |
| Construct exact value [v, v]. | |
| TrackedBounded (T lo, T hi) noexcept | |
| Construct from explicit bounds [lo, hi]. | |
| TrackedBounded (T lo, T hi, size_t ops) noexcept | |
| Construct from bounds with operation count. | |
| T | value () const noexcept |
| Get the midpoint value (best estimate). | |
| T | lo () const noexcept |
| Get the lower bound. | |
| T | hi () const noexcept |
| Get the upper bound. | |
| T | width () const noexcept |
| Get the interval width (absolute error bound). | |
| T | radius () const noexcept |
| Get the radius (half-width). | |
| T | error () const noexcept |
| Get the absolute error bound. | |
| T | relative_error () const noexcept |
| Get the relative error bound. | |
| double | valid_bits () const noexcept |
| Estimate valid bits of precision, clamped to [0, the type's precision]. | |
| bool | is_exact () const noexcept |
| Check if the interval is exact (zero width). | |
| bool | is_positive () const noexcept |
| Check if value is definitely positive. | |
| bool | is_negative () const noexcept |
| Check if value is definitely negative. | |
| bool | contains_zero () const noexcept |
| Check if interval contains zero. | |
| size_t | operations () const noexcept |
| Get operation count. | |
| TrackedBounded | operator+ (const TrackedBounded &rhs) const |
| Addition with outward rounding. | |
| TrackedBounded | operator- (const TrackedBounded &rhs) const |
| Subtraction with outward rounding. | |
| TrackedBounded | operator- () const |
| Unary negation. | |
| TrackedBounded | operator* (const TrackedBounded &rhs) const |
| Multiplication with outward rounding Must consider all four products to handle signs correctly. | |
| TrackedBounded | operator/ (const TrackedBounded &rhs) const |
| Division with outward rounding Requires that rhs does not contain zero. | |
| TrackedBounded & | operator+= (const TrackedBounded &rhs) |
| Compound assignment operators. | |
| TrackedBounded & | operator-= (const TrackedBounded &rhs) |
| TrackedBounded & | operator*= (const TrackedBounded &rhs) |
| TrackedBounded & | operator/= (const TrackedBounded &rhs) |
| bool | operator< (const TrackedBounded &rhs) const |
| Every value in this interval is below every value in rhs. | |
| bool | operator> (const TrackedBounded &rhs) const |
| Every value in this interval is above every value in rhs. | |
| bool | operator<= (const TrackedBounded &rhs) const |
| bool | operator>= (const TrackedBounded &rhs) const |
| bool | operator== (const TrackedBounded &rhs) const |
| Same interval, not merely an overlapping one. | |
| bool | operator!= (const TrackedBounded &rhs) const |
| bool | definitely_less (const TrackedBounded &rhs) const |
| Check if this interval definitely less than rhs (no overlap). | |
| bool | definitely_greater (const TrackedBounded &rhs) const |
| Check if this interval definitely greater than rhs (no overlap). | |
| bool | overlaps (const TrackedBounded &rhs) const |
| Check if intervals overlap. | |
| bool | contains (const TrackedBounded &rhs) const |
| Check if this interval contains rhs entirely. | |
| void | report (std::ostream &os) const |
| Detailed report. | |
Static Public Member Functions | |
| static constexpr const char * | strategy_name () |
| Get strategy name. | |
Friends | |
| TrackedBounded | sqrt (const TrackedBounded &x) |
| Square root with outward rounding. | |
| TrackedBounded | abs (const TrackedBounded &x) |
| Absolute value. | |
| TrackedBounded | pow (const TrackedBounded &base, int exp) |
| Integer power. | |
| std::ostream & | operator<< (std::ostream &os, const TrackedBounded &x) |
| Stream output showing interval. | |
TrackedBounded wraps a scalar type with rigorous interval bounds.
| T | The underlying scalar type (float, double, long double) |
The value is represented as an interval [lo, hi] that is guaranteed to contain the true mathematical result. Arithmetic operations use directed rounding to maintain this guarantee.
| using sw::universal::TrackedBounded< T >::value_type = T |
|
inlineconstexprnoexcept |
Default constructor: zero interval [0, 0].
|
inlinenoexcept |
Construct exact value [v, v].
|
inlinenoexcept |
Construct from explicit bounds [lo, hi].
|
inlinenoexcept |
Construct from bounds with operation count.
|
inline |
Check if this interval contains rhs entirely.
|
inlinenoexcept |
Check if interval contains zero.
|
inline |
Check if this interval definitely greater than rhs (no overlap).
|
inline |
Check if this interval definitely less than rhs (no overlap).
|
inlinenoexcept |
Get the absolute error bound.
|
inlinenoexcept |
Get the upper bound.
|
inlinenoexcept |
Check if the interval is exact (zero width).
|
inlinenoexcept |
Check if value is definitely negative.
|
inlinenoexcept |
Check if value is definitely positive.
|
inlinenoexcept |
Get the lower bound.
|
inlinenoexcept |
Get operation count.
|
inline |
|
inline |
Multiplication with outward rounding Must consider all four products to handle signs correctly.
|
inline |
|
inline |
Addition with outward rounding.
|
inline |
Compound assignment operators.
|
inline |
Unary negation.
|
inline |
Subtraction with outward rounding.
|
inline |
|
inline |
Division with outward rounding Requires that rhs does not contain zero.
|
inline |
|
inline |
Every value in this interval is below every value in rhs.
|
inline |
|
inline |
Same interval, not merely an overlapping one.
|
inline |
Every value in this interval is above every value in rhs.
|
inline |
|
inline |
Check if intervals overlap.
|
inlinenoexcept |
Get the radius (half-width).
|
inlinenoexcept |
Get the relative error bound.
A zero-width interval is exact whatever it brackets, zero included: there is no relative error to report. Only a value that spans zero has a relative error with no meaning, and that is the case the infinity is for.
|
inline |
Detailed report.
|
inlinestaticconstexpr |
Get strategy name.
|
inlinenoexcept |
Estimate valid bits of precision, clamped to [0, the type's precision].
|
inlinenoexcept |
Get the midpoint value (best estimate).
|
inlinenoexcept |
Get the interval width (absolute error bound).
|
friend |
Absolute value.
|
friend |
Stream output showing interval.
|
friend |
Integer power.
|
friend |
Square root with outward rounding.