From f8fd2a7a35498f57837b20c5cb21941b00bf7bec Mon Sep 17 00:00:00 2001 From: Luis Benet Date: Mon, 14 Oct 2024 14:36:28 -0600 Subject: [PATCH] Return Dual's for promote_rule --- ext/IntervalArithmeticForwardDiffExt.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ext/IntervalArithmeticForwardDiffExt.jl b/ext/IntervalArithmeticForwardDiffExt.jl index 869d926e..520ff828 100644 --- a/ext/IntervalArithmeticForwardDiffExt.jl +++ b/ext/IntervalArithmeticForwardDiffExt.jl @@ -5,13 +5,16 @@ 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)} + Dual{T,Interval{IntervalArithmetic.promote_numtype(V, S)},N} + +Base.promote_rule(::Type{Interval{S}}, ::Type{ForwardDiff.Dual{T, V, N}}) where {S<:Union{AbstractFloat, Rational}, T, V, N} = + Dual{T,Interval{IntervalArithmetic.promote_numtype(V, S)},N} Base.promote_rule(::Type{ExactReal{S}}, ::Type{Dual{T, V, N}}) where {S<:Real, T, V, N} = - ExactReal{IntervalArithmetic.promote_numtype(V, S)} + Dual{T,ExactReal{IntervalArithmetic.promote_numtype(V, S)},N} Base.promote_rule(::Type{Dual{T, V, N}}, ::Type{ExactReal{S}}) where {S<:Real, T, V, N} = - ExactReal{IntervalArithmetic.promote_numtype(V, S)} + Dual{T,ExactReal{IntervalArithmetic.promote_numtype(V, S)},N} Base.:(==)(x::Union{BareInterval,Interval}, y::Dual) = isthin(x, y) Base.:(==)(x::Dual, y::Union{BareInterval,Interval}) = y == x