Skip to content

Commit f76563f

Browse files
committed
Update ext
1 parent df8e419 commit f76563f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ IntervalArithmeticSparseArraysExt = "SparseArrays"
2929
[compat]
3030
CRlibm = "1.0.2"
3131
DiffRules = "1"
32-
ForwardDiff = "0.10"
32+
ForwardDiff = "1"
3333
IntervalSets = "0.7"
3434
LinearAlgebra = "1.10"
3535
MacroTools = "0.5"

ext/IntervalArithmeticDiffRulesExt.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module IntervalArithmeticDiffRulesExt
33
using IntervalArithmetic
44
import DiffRules
55

6-
function DiffRules._abs_deriv(x::Interval)
7-
r = sign(bareinterval(x))
6+
function DiffRules._abs_deriv(x::Interval{T}) where {T<:IntervalArithmetic.NumTypes}
7+
r = ifelse(isthinzero(x), bareinterval(-one(T), one(T)), sign(bareinterval(x)))
88
d = decoration(x)
99
d = min(d, ifelse(in_interval(0, x), trv, d)) # if `x` contains 0, then `trv` decoration
1010
return IntervalArithmetic._unsafe_interval(r, d, isguaranteed(x))

ext/IntervalArithmeticForwardDiffExt.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ ForwardDiff.Dual{T,V}(x::ExactReal) where {T,V} = convert(Dual{T,V}, x)
1414

1515
Base.convert(::Type{Dual{T,V,N}}, x::ExactReal) where {T,V,N} = Dual{T}(V(x), zero(Partials{N,V}))
1616

17-
Base.promote_rule(::Type{Dual{T, V, N}}, ::Type{Interval{S}}) where {T, V, N, S<:Union{AbstractFloat, Rational}} =
17+
Base.promote_rule(::Type{Dual{T, V, N}}, ::Type{Interval{S}}) where {T, V, N, S<:IntervalArithmetic.NumTypes} =
1818
Dual{T,Interval{IntervalArithmetic.promote_numtype(V, S)},N}
19-
Base.promote_rule(::Type{Interval{S}}, ::Type{Dual{T, V, N}}) where {S<:Union{AbstractFloat, Rational}, T, V, N} =
19+
Base.promote_rule(::Type{Interval{S}}, ::Type{Dual{T, V, N}}) where {S<:IntervalArithmetic.NumTypes, T, V, N} =
2020
Dual{T,Interval{IntervalArithmetic.promote_numtype(V, S)},N}
2121
Base.promote_rule(::Type{ExactReal{S}}, ::Type{Dual{T, V, N}}) where {S<:Real, T, V, N} =
2222
Dual{T,ExactReal{IntervalArithmetic.promote_numtype(V, S)},N}

0 commit comments

Comments
 (0)