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.valuetypeFunction
valuetype(::Type{<:ThickNumber})

Return the type of the numbers in the span, i.e., the T in ThickNumber{T}.

Examples

julia> valuetype(Interval{Float64})
Float64
source

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.midFunction
mid(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
source
ThickNumbers.magFunction
mag(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)))
source
ThickNumbers.migFunction
mig(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)))
source
ThickNumbers.radFunction
rad(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
source
ThickNumbers.widFunction
wid(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)
source

Comparison operators

ThickNumbers.iseq_tnFunction
iseq_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.

source
ThickNumbers.isequal_tnFunction
isequal_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.

source
ThickNumbers.isapprox_tnFunction
isapprox_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.

source
ThickNumbers.isless_tnFunction
isless_tn(a::ThickNumber, b::ThickNumber)

Returns true if isless(hival(a), loval(b)), false otherwise. See also .

source
ThickNumbers.:≺Function
a ≺ b

Returns true if hival(a) < loval(b), false otherwise. Use \prec-TAB to type.

source
ThickNumbers.:≻Function
a ≻ b

Returns true if loval(a) > hival(b), false otherwise. Use \succ-TAB to type.

source
ThickNumbers.:⪯Function
a ≼ b

Returns true if hival(a) ≤ loval(b), false otherwise. Use \preceq-TAB to type.

source
ThickNumbers.:⪰Function
a ≽ b

Returns true if loval(a) ≥ hival(b), false otherwise. Use \succeq-TAB to type.

source

Set operations

See also IntervalSets for a more flexible way of supporting intervals as sets.

Base.inMethod
in(x::Real, a::ThickNumber)

Returns true if x is in the span of a (i.e., between loval(a) and hival(a)), false otherwise.

source
ThickNumbers.hullFunction
hull(a::ThickNumber, b::ThickNumber, c::ThickNumber...)

Construct a ThickNumber containing a, b, and c....

source
Base.isemptyMethod
isempty(x::ThickNumber)

Returns true if hival(x) < loval(x) is empty, false otherwise.

source
ThickNumbers.issubset_tnFunction
issubset_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

source
ThickNumbers.is_strict_subset_tnFunction
is_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 .

source

Also supported are Base's:

  • isdisjoint
  • intersect

Operations with real numbers

  • clamp(::Real, ::ThickNumber)