Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions src/IntervalArithmetic.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This file is part of the IntervalArithmetic.jl package; MIT licensed

module IntervalArithmetic

import CRlibm
Expand All @@ -15,29 +13,25 @@ using EnumX
import LinearAlgebra: ×, dot, norm
export ×, dot


import Base:
+, -, *, /, //, fma,
<, >, ==, !=, ⊆, ^, <=, >=,
in, zero, one, eps, typemin, typemax, abs, abs2, min, max,
sqrt, exp, log, exp2, exp10, log2, log10, inv, cbrt, hypot,
^, sqrt, exp, log, exp2, exp10, log2, log10, inv, cbrt, hypot,
zero, one, eps, typemin, typemax, abs, abs2, min, max,
rad2deg, deg2rad,
sin, cos, tan, cot, csc, sec, asin, acos, atan, acot, sinpi, cospi, sincospi,
sinh, cosh, tanh, coth, csch, sech, asinh, acosh, atanh, acoth,
union, intersect, isempty,
in, union, intersect, issubset, isempty, isdisjoint,
convert, eltype, size,
BigFloat, float, big,
∩, ∪, ⊆, ⊇, ∈, eps,
floor, ceil, trunc, sign, round, copysign, flipsign, signbit,
expm1, log1p,
precision,
isfinite, isnan, isinf, iszero,
isfinite, isinteger, isnan, isinf, iszero,
abs, abs2,
show,
isinteger, setdiff,
parse, hash

import Base: # for IntervalBox
setdiff,
parse, hash,
# for IntervalBox
broadcast, length,
getindex, setindex,
iterate, eltype
Expand All @@ -51,22 +45,21 @@ export
Interval, BooleanInterval,
interval, ±, @I_str,
diam, radius, mid, scaled_mid, mag, mig, hull,
emptyinterval, isempty, isinterior, isdisjoint,
precedes, strictprecedes, ⊂, ⊃, ⊇, contains_zero, isthinzero,
emptyinterval, isempty, isinterior,
precedes, strictprecedes, ≺, ⊂, ⊃, contains_zero, isthinzero,
isweaklyless, isstrictless, overlap, Overlap,
≛,
entireinterval, isentire, nai, isnai, isthin, iscommon, isatomic,
inf, sup, bounds, bisect, mince,
eps, dist,
dist,
midpoint_radius,
RoundTiesToEven, RoundTiesToAway,
IntervalRounding,
PointwisePolicy,
cancelminus, cancelplus, isbounded, isunbounded,
pow, extended_div, nthroot,
setformat

import Base: isdisjoint


export
setindex # re-export from StaticArrays for IntervalBox
Expand All @@ -79,7 +72,7 @@ export

## Decorations
export
interval, decoration, DecoratedInterval,
decoration, DecoratedInterval,
com, dac, def, trv, ill

## Union type
Expand Down
10 changes: 7 additions & 3 deletions src/decorations/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ one(::DecoratedInterval{T}) where {T<:NumTypes} = DecoratedInterval(one(T))
one(::Type{DecoratedInterval{T}}) where {T<:NumTypes} = DecoratedInterval(one(T))

## Bool functions

Base.:(==)(::DecoratedInterval, ::DecoratedInterval) =
throw(ArgumentError("== is purposely not supported, use ≛ instead"))

const bool_functions = (
:isempty, :isentire, :isunbounded,
:isfinite, :isnan,
:isthin, :iscommon
)

const bool_binary_functions = (
:<, :>, :!=, :⊆, :<=, :(==),
:isinterior, :isdisjoint, :precedes, :strictprecedes,
:issubset,
:isinterior, :isdisjoint, :precedes, :strictprecedes, :isstrictless, :isweaklyless,
:≛, :overlap
)

Expand Down Expand Up @@ -131,7 +135,7 @@ function ^(xx::DecoratedInterval{T}, qq::DecoratedInterval{S}) where {T,S}
r = x^q
d = min(decoration(xx), decoration(qq), decoration(r))
if inf(x) > zero(T) || (inf(x) ≥ zero(T) && inf(q) > zero(T)) ||
(isthin(q) && isinteger(inf(q)) && inf(q) > zero(q)) ||
(isthin(q) && isinteger(inf(q)) && inf(q) > zero(T)) ||
(isthin(q) && isinteger(inf(q)) && zero(T) ∉ x)
return DecoratedInterval(r, d)
end
Expand Down
5 changes: 3 additions & 2 deletions src/intervals/interval_operations/boolean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ function ≛(a::Interval, b::Interval)
isempty(a) && isempty(b) && return true
return inf(a) == inf(b) && sup(a) == sup(b)
end
Base.:(==)(::Interval, ::Interval) =
throw(ArgumentError("== is purposely not supported, use ≛ instead"))

"""
≛(a::Interval, x::Real)
Expand All @@ -45,7 +47,7 @@ Typed with \\subseteq<TAB>.

Implement the `subset` function of the IEEE Standard 1788-2015 (Table 9.3).
"""
function (a::Interval, b::Interval)
function issubset(a::Interval, b::Interval)
isempty(a) && return true
return inf(b) ≤ inf(a) && sup(a) ≤ sup(b)
end
Expand All @@ -62,7 +64,6 @@ function ⊂(a::Interval, b::Interval)
return a ⊆ b
end

⊇(a::Interval, b::Interval) = b ⊆ a
⊃(a::Interval, b::Interval) = b ⊂ a

"""
Expand Down
221 changes: 0 additions & 221 deletions src/intervals/interval_operations/pointwise_boolean.jl

This file was deleted.

13 changes: 8 additions & 5 deletions src/intervals/interval_operations/set_operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ This function is applicable to any number of input intervals, as in
If your use case needs to splat the input, as in `intersect(a...)`, consider
`reduce(intersect, a)` instead, because you save the cost of splatting.
"""
intersect(a::Interval...) = interval(maximum(inf.(a)), minimum(sup.(a)))
intersect(a::Union{Interval,Complex{<:Interval}}, b::Union{Interval,Complex{<:Interval}}...) = reduce(intersect, b; init = a)

"""
hull(a, b)
Expand All @@ -53,8 +53,10 @@ hull(a::Interval{T}, b::Interval{S}) where {T<:NumTypes,S<:NumTypes} =
unsafe_interval(promote_numtype(T, S), min(inf(a), inf(b)), max(sup(a), sup(b)))
hull(a::Complex{<:Interval}, b::Complex{<:Interval}) =
complex(hull(real(a), real(b)), hull(imag(a), imag(b)))
hull(a...) = reduce(hull, a)
hull(a::AbstractVector{<:Interval}) = reduce(hull, a)
hull(a::Interval, b::Complex{<:Interval}) = complex(hull(a, real(b)), imag(b))
hull(a::Complex{<:Interval}, b::Interval) = complex(hull(real(a), b), imag(a))
hull(a::Union{Interval,Complex{<:Interval}}, b::Union{Interval,Complex{<:Interval}}...) = reduce(hull, b; init = a)
hull(a::AbstractVector{<:Union{<:Interval,Complex{<:Interval}}}) = reduce(hull, a)

"""
union(a, b)
Expand All @@ -65,8 +67,9 @@ to `hull(a,b)`.

Implement the `converxHull` function of the IEEE Standard 1788-2015 (Section 9.3).
"""
union(a::Interval, b::Interval) = hull(a, b)
union(a::Complex{<:Interval}, b::Complex{<:Interval}) = hull(a, b)
union(a::Union{Interval,Complex{<:Interval}}, b::Union{Interval,Complex{<:Interval}}) = hull(a, b)
union(a::Union{Interval,Complex{<:Interval}}, b::Union{Interval,Complex{<:Interval}}...) = hull(a, b...)
union(a::AbstractVector{<:Union{<:Interval,Complex{<:Interval}}}) = hull(a)

"""
setdiff(x::Interval, y::Interval)
Expand Down
1 change: 0 additions & 1 deletion src/intervals/intervals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ include("interval_operations/extended_div.jl")
include("interval_operations/boolean.jl")
include("interval_operations/overlap.jl")
include("interval_operations/numeric.jl")
include("interval_operations/pointwise_boolean.jl")
include("interval_operations/set_operations.jl")
Loading