User API
These are functions you can use on any ThickNumber
subtype when writing your code. Generally you shouldn't need to implement these directly (they all have default implementations), although you can of course specialize them as needed as long as your implementation does not violate the interface requirements.
Types
ThickNumbers.valuetype
— Functionvaluetype(::Type{<:ThickNumber})
Return the type of the numbers in the span, i.e., the T
in ThickNumber{T}
.
Examples
julia> valuetype(Interval{Float64})
Float64
Query functions
API functions from the Interval Arithmetic Standard (IEEE Std 1788-2015), Table 9.2 are supported. One (deliberate) exception is inf
and sup
, which are replaced by loval
and hival
: inf
and sup
have well-defined mathematical meanings that may not be appropriate for all ThickNumber
subtypes (e.g., gaussian random variables don't have finite lower and upper bounds). If you are creating an interval arithmetic package, of course you can choose to define
inf(x::MyInterval) = loval(x)
sup(x::MyInterval) = hival(x)
in order to comply with the standard.
ThickNumbers.mid
— Functionmid(x::ThickNumber)
The midpoint of the span of x
. Required by IEEE Std 1788-2015, Table 9.2.
Default implementation
The default implementation is
mid(x::ThickNumber) = (loval(x) + hival(x))/2
ThickNumbers.mag
— Functionmag(x::ThickNumber)
The maximum absolute value of x
. Required by IEEE Std 1788-2015, Table 9.2.
Default implementation
The default implementation is
mag(x::ThickNumber) = max(abs(loval(x)), abs(hival(x)))
ThickNumbers.mig
— Functionmig(x::ThickNumber)
The minimum absolute value of x
. Required by IEEE Std 1788-2015, Table 9.2.
Default implementation
The default implementation checks to see if the set contains zero, and if so returns zero. Otherwise, it returns the minimum absolute value of the endpoints:
mig(x::ThickNumber) = zero(T) ∈ x ? zero(T) : min(abs(loval(x)), abs(hival(x)))
ThickNumbers.rad
— Functionrad(x::ThickNumber)
Half the width of the span of x
. Required by IEEE Std 1788-2015, Table 9.2.
Default implementation
The default implementation is
rad(x::ThickNumber) = wid(x)/2
ThickNumbers.wid
— Functionwid(x::ThickNumber)
The width of the span of x
. Required by IEEE Std 1788-2015, Table 9.2.
Default implementation
The default implementation is
wid(x::ThickNumber) = hival(x) - loval(x)
ThickNumbers.isfinite_tn
— Functionisfinite_tn(x::ThickNumber)
Returns true
if all values in x
are finite, false
otherwise.
ThickNumbers.isinf_tn
— Functionisinf_tn(x::ThickNumber)
Returns true
if any value in x
is infinite, false
otherwise.
ThickNumbers.isnan_tn
— Functionisnan_tn(x::ThickNumber)
Returns true
if any value in x
is NaN, false
otherwise.
Comparison operators
ThickNumbers.iseq_tn
— Functioniseq_tn(a::ThickNumber, b::ThickNumber)
a ≐ b (`\doteq`-TAB`)
Returns true
if a
and b
are both empty or both loval
and hival
are equal in the sense of ==
. It is false
otherwise.
ThickNumbers.isequal_tn
— Functionisequal_tn(a::ThickNumber, b::ThickNumber)
Returns true
if a
and b
are both empty or both loval
and hival
are equal in the sense of isequal
. It is false
otherwise.
ThickNumbers.isapprox_tn
— Functionisapprox_tn(a::ThickNumber, b::ThickNumber; atol=0, rtol::Real=atol>0 ? 0 : √eps)
a ⩪ b (`\dotsim`-TAB)
Returns true
if a
and b
are both empty or both loval
and hival
are approximately equal (≈). It is false
otherwise.
ThickNumbers.isless_tn
— Functionisless_tn(a::ThickNumber, b::ThickNumber)
Returns true
if isless(hival(a), loval(b))
, false
otherwise. See also ≺
.
ThickNumbers.:≺
— Functiona ≺ b
Returns true
if hival(a) < loval(b)
, false
otherwise. Use \prec
-TAB to type.
ThickNumbers.:≻
— Functiona ≻ b
Returns true
if loval(a) > hival(b)
, false
otherwise. Use \succ
-TAB to type.
ThickNumbers.:⪯
— Functiona ≼ b
Returns true
if hival(a) ≤ loval(b)
, false
otherwise. Use \preceq
-TAB to type.
ThickNumbers.:⪰
— Functiona ≽ b
Returns true
if loval(a) ≥ hival(b)
, false
otherwise. Use \succeq
-TAB to type.
Set operations
See also IntervalSets for a more flexible way of supporting intervals as sets.
Base.in
— Methodin(x::Real, a::ThickNumber)
Returns true
if x
is in the span of a
(i.e., between loval(a)
and hival(a)
), false
otherwise.
ThickNumbers.hull
— Functionhull(a::ThickNumber, b::ThickNumber, c::ThickNumber...)
Construct a ThickNumber
containing a
, b
, and c...
.
Base.isempty
— Methodisempty(x::ThickNumber)
Returns true
if hival(x) < loval(x)
is empty, false
otherwise.
ThickNumbers.issubset_tn
— Functionissubset_tn(a::ThickNumber, b::ThickNumber)
⫃(a::ThickNumber, b::ThickNumber)
Returns true
if a
is a subset of b
, false
otherwise.
See documentation for why this is not just ⊆
ThickNumbers.issupset_tn
— Functionissupset_tn(a::ThickNumber, b::ThickNumber)
⫄(a::ThickNumber, b::ThickNumber)
The converse of issubset_tn
.
ThickNumbers.is_strict_subset_tn
— Functionis_strict_subset_tn(a::ThickNumber, b::ThickNumber)
⪽(a::ThickNumber, b::ThickNumber)
Returns true
if a
is a strict subset of b
, false
otherwise. a
is a strict subset if a
is a subset of b
not equal to b
.
See documentation for why this is not just ⊂
.
ThickNumbers.is_strict_supset_tn
— Functionis_strict_supset_tn(a::ThickNumber, b::ThickNumber)
⪾(a::ThickNumber, b::ThickNumber)
The converse of is_strict_subset_tn
.
Also supported are Base
's:
isdisjoint
intersect
Operations with real numbers
clamp(::Real, ::ThickNumber)