Skip to content

Commit

Permalink
More methods Dual(::ExactReal)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbenet committed Oct 14, 2024
1 parent 2c466d2 commit d30a6ef
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ext/IntervalArithmeticForwardDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ using ForwardDiff: Dual, ≺, value, partials
# Needed to avoid method ambiguities:
ForwardDiff.can_dual(::Type{ExactReal}) = true
Dual(x::ExactReal) = Dual{Nothing, typeof(x), 0}(x.value)
Dual{T}(x::ExactReal) where {T} = Dual{T, typeof(x), 0}(x.value)
Dual{T, V}(x::ExactReal) where {T, V<:Real} = convert(Dual{T, V, 0}, x)
Dual{T, V, N}(x::ExactReal) where {T, V<:Real, N} = convert(Dual{T, V, N}, x)

Base.convert(::Type{Dual{T, V, N}}, x::ExactReal) where {T, V, N} = promote_rule(Dual{T, V, N}, typeof(x))(x.value)

Base.promote_rule(::Type{Dual{T, V, N}}, ::Type{Interval{S}}) where {T, V, N, S<:Union{AbstractFloat, Rational}} =
Expand Down

0 comments on commit d30a6ef

Please sign in to comment.