Skip to content

Commit

Permalink
Try to solve some ambiguities related to ForwardDiff
Browse files Browse the repository at this point in the history
  • Loading branch information
lbenet committed Oct 14, 2024
1 parent 3ca341d commit 82baf63
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ext/IntervalArithmeticForwardDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ module IntervalArithmeticForwardDiffExt
using IntervalArithmetic, ForwardDiff
using ForwardDiff: Dual, , value, partials

#
# Needed to avoid method ambiguities:
Base.promote_rule(::Type{Dual{T, V, N}}, ::Type{Interval{S}}) where {T, V, N, S<:Union{AbstractFloat, Rational}} =
Interval{IntervalArithmetic.promote_numtype(V, S)}

Base.promote_rule(::Type{ExactReal{S}}, ::Type{Dual{T, V, N}}) where {S<:Real, T, V, N} =
ExactReal{IntervalArithmetic.promote_numtype(V, S)}

Base.promote_rule(::Type{Dual{T, V, N}}, ::Type{ExactReal{S}}) where {S<:Real, T, V, N} =
ExactReal{IntervalArithmetic.promote_numtype(V, S)}

Base.:(==)(x::Union{BareInterval,Interval}, y::Dual) = isthin(x, y)
Base.:(==)(x::Dual, y::Union{BareInterval,Interval}) = y == x


function Base.:(^)(x::Dual{Txy,<:Interval}, y::Dual{Txy,<:Interval}) where {Txy}
vx, vy = value(x), value(y)
Expand Down

0 comments on commit 82baf63

Please sign in to comment.