Skip to content

Commit

Permalink
Add ambiguity solutions proposed by @OlivierHnt, and revert 47605eb
Browse files Browse the repository at this point in the history
47605eb solved some ambiguities, but induced (construction) errors

Co-authored-by: Olivier Hénot <[email protected]>
  • Loading branch information
lbenet and OlivierHnt committed Oct 12, 2024
1 parent 47605eb commit 2819244
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/intervals/construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ interval(::Type{T}, A::AbstractArray, d::AbstractArray{Decoration}; format::Symb
interval(A::AbstractArray, d::AbstractArray{Decoration}; format::Symbol = :infsup) = interval.(A, d; format = format)
interval(::Type{T}, A::AbstractArray, B::AbstractArray, d::AbstractArray{Decoration}; format::Symbol = :infsup) where {T} = interval.(T, A, B, d; format = format)
interval(A::AbstractArray, B::AbstractArray, d::AbstractArray{Decoration}; format::Symbol = :infsup) = interval.(A, B, d; format = format)
interval(T::Type, d::Decoration; format::Symbol = :infsup) = throw(MethodError(interval, (T, d)))

# standard format

Expand Down Expand Up @@ -469,7 +470,7 @@ function _interval_infsup(::Type{T}, x::Union{BareInterval,Interval}, y::Union{B
return _unsafe_interval(z, min(decoration(x), decoration(y), decoration(z), d), t)
end
end
function _interval_infsup(::Type{T}, x::Union{BareInterval,Interval}, y::NumTypes, d::Decoration) where {T<:NumTypes}
function _interval_infsup(::Type{T}, x::Union{BareInterval,Interval}, y, d::Decoration) where {T<:NumTypes}
lo = _inf(x)
hi = _sup(y)
if !is_valid_interval(lo, hi) || d == ill
Expand All @@ -480,7 +481,7 @@ function _interval_infsup(::Type{T}, x::Union{BareInterval,Interval}, y::NumType
return _unsafe_interval(z, min(decoration(x), decoration(z), d), isguaranteed(x))
end
end
function _interval_infsup(::Type{T}, x::NumTypes, y::Union{BareInterval,Interval}, d::Decoration) where {T<:NumTypes}
function _interval_infsup(::Type{T}, x, y::Union{BareInterval,Interval}, d::Decoration) where {T<:NumTypes}
lo = _inf(x)
hi = _sup(y)
if !is_valid_interval(lo, hi) || d == ill
Expand All @@ -492,6 +493,11 @@ function _interval_infsup(::Type{T}, x::NumTypes, y::Union{BareInterval,Interval
end
end

_interval_infsup(::Type{T}, a::Complex, b::Union{BareInterval,Interval}, d::Decoration = com) where {T<:NumTypes} =
complex(_interval_infsup(T, real(a), real(b), d), _interval_infsup(T, imag(a), imag(b), d))
_interval_infsup(::Type{T}, a::Union{BareInterval,Interval}, b::Complex, d::Decoration = com) where {T<:NumTypes} =
complex(_interval_infsup(T, real(a), real(b), d), _interval_infsup(T, imag(a), imag(b), d))

_interval_infsup(::Type{T}, a::Complex, b::Complex, d::Decoration = com) where {T<:NumTypes} =
complex(_interval_infsup(T, real(a), real(b), d), _interval_infsup(T, imag(a), imag(b), d))
_interval_infsup(::Type{T}, a::Complex, b, d::Decoration = com) where {T<:NumTypes} =
Expand Down
2 changes: 2 additions & 0 deletions src/intervals/exact_literals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ struct ExactReal{T<:Real} <: Real
ExactReal(value::T) where {T<:Real} = new{T}(value)
end

ExactReal(x::ExactReal) = x

_value(x::ExactReal) = x.value # hook for interval constructor

# utilities
Expand Down

0 comments on commit 2819244

Please sign in to comment.