|
Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
|
A parameterized interval number type [lo, hi] representing a closed interval. More...
#include <interval_impl.hpp>
Public Types | |
| using | value_type = Scalar |
Public Member Functions | |
| constexpr | interval () noexcept |
| constexpr | interval (const interval &) noexcept=default |
| constexpr | interval (interval &&) noexcept=default |
| constexpr interval & | operator= (const interval &) noexcept=default |
| constexpr interval & | operator= (interval &&) noexcept=default |
| template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T> || std::is_same_v<T, Scalar>>> | |
| interval (T v) noexcept | |
| template<typename T, typename U> | |
| interval (T lo, U hi) noexcept | |
| template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>> | |
| constexpr interval & | operator= (T v) noexcept |
| operator float () const noexcept | |
| operator double () const noexcept | |
| operator long double () const noexcept | |
| constexpr interval | operator- () const noexcept |
| constexpr interval | operator+ () const noexcept |
| interval & | operator+= (const interval &rhs) noexcept |
| interval & | operator-= (const interval &rhs) noexcept |
| interval & | operator*= (const interval &rhs) noexcept |
| interval & | operator/= (const interval &rhs) |
| template<typename T> | |
| interval & | operator+= (T rhs) noexcept |
| template<typename T> | |
| interval & | operator-= (T rhs) noexcept |
| template<typename T> | |
| interval & | operator*= (T rhs) noexcept |
| template<typename T> | |
| interval & | operator/= (T rhs) |
| constexpr void | clear () noexcept |
| constexpr void | setzero () noexcept |
| constexpr void | setinf (bool sign=true) noexcept |
| constexpr void | setnan () noexcept |
| constexpr void | set (Scalar lo, Scalar hi) noexcept |
| constexpr void | setlo (Scalar lo) noexcept |
| constexpr void | sethi (Scalar hi) noexcept |
| constexpr Scalar | lo () const noexcept |
| constexpr Scalar | hi () const noexcept |
| constexpr Scalar | lower () const noexcept |
| constexpr Scalar | upper () const noexcept |
| constexpr Scalar | mid () const noexcept |
| Scalar | rad () const noexcept |
| Scalar | width () const noexcept |
| constexpr Scalar | mag () const noexcept |
| constexpr Scalar | mig () const noexcept |
| constexpr bool | iszero () const noexcept |
| constexpr bool | isdegenerate () const noexcept |
| constexpr bool | isnan () const noexcept |
| constexpr bool | isinf () const noexcept |
| constexpr bool | isfinite () const noexcept |
| constexpr bool | contains_zero () const noexcept |
| constexpr bool | contains (Scalar v) const noexcept |
| constexpr bool | ispos () const noexcept |
| constexpr bool | isneg () const noexcept |
| constexpr bool | subset_of (const interval &other) const noexcept |
| constexpr bool | proper_subset_of (const interval &other) const noexcept |
| constexpr bool | overlaps (const interval &other) const noexcept |
Static Public Attributes | |
| static constexpr bool | can_represent_unbounded |
| Can this interval represent an UNBOUNDED result? | |
Friends | |
| template<typename S> | |
| std::ostream & | operator<< (std::ostream &ostr, const interval< S > &v) |
| template<typename S> | |
| std::istream & | operator>> (std::istream &istr, interval< S > &v) |
| template<typename S> | |
| bool | operator== (const interval< S > &lhs, const interval< S > &rhs) |
| template<typename S> | |
| bool | operator!= (const interval< S > &lhs, const interval< S > &rhs) |
| template<typename S> | |
| bool | operator< (const interval< S > &lhs, const interval< S > &rhs) |
| template<typename S> | |
| bool | operator> (const interval< S > &lhs, const interval< S > &rhs) |
| template<typename S> | |
| bool | operator<= (const interval< S > &lhs, const interval< S > &rhs) |
| template<typename S> | |
| bool | operator>= (const interval< S > &lhs, const interval< S > &rhs) |
A parameterized interval number type [lo, hi] representing a closed interval.
The Scalar type can be any numeric type: float, double, or Universal types like cfloat<>.
Interval arithmetic follows the standard rules: [a,b] + [c,d] = [a+c, b+d] [a,b] - [c,d] = [a-d, b-c] [a,b] * [c,d] = [min(ac,ad,bc,bd), max(ac,ad,bc,bd)] [a,b] / [c,d] = [a,b] * [1/d, 1/c] (when 0 not in [c,d])
| Scalar | the type used for the lower and upper bounds |
| using sw::universal::interval< Scalar >::value_type = Scalar |
|
inlineconstexprnoexcept |
|
constexprdefaultnoexcept |
|
constexprdefaultnoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineexplicitnoexcept |
|
inlineexplicitnoexcept |
|
inlineexplicitnoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineconstexprnoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineconstexprnoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
constexprdefaultnoexcept |
|
constexprdefaultnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinenoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinenoexcept |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
staticconstexpr |
Can this interval represent an UNBOUNDED result?
Division by an interval containing zero has an unbounded exact result set, and the only way to enclose it is +/-infinity. Some Scalars have no infinity to offer: posit has NaR instead, and numeric_limits<posit>::infinity() returns maxpos – a finite value indistinguishable from ordinary data. lns likewise reports has_infinity = false.
The flag is derived from what infinity() actually IS, not from the has_infinity claim, because the two disagree for posit. When this is false the unbounded case throws rather than returning a finite interval that would claim to enclose values it does not contain.