Skip to content

Commit

Permalink
Merge pull request #656 from chriselrod/sametagnestedconvert
Browse files Browse the repository at this point in the history
`floatmin` for nested `Dual`s sharing the same tag
  • Loading branch information
ChrisRackauckas authored Aug 9, 2023
2 parents dc5f08c + a87a482 commit 2ff6808
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ForwardDiff"
uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.35"
version = "0.10.36"

[deps]
CommonSubexpressions = "bbf7d656-a473-5ed7-a52c-81e309532950"
Expand Down
1 change: 1 addition & 0 deletions src/dual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ for R in (Irrational, Real, BigFloat, Bool)
end

@inline Base.convert(::Type{Dual{T,V,N}}, d::Dual{T}) where {T,V,N} = Dual{T}(V(value(d)), convert(Partials{N,V}, partials(d)))
@inline Base.convert(::Type{Dual{T,Dual{T,V,M},N}}, d::Dual{T,V,M}) where {T,V,N,M} = Dual{T}(d, Partials{N,Dual{T,V,M}}(zero_tuple(NTuple{N,Dual{T,V,M}})))
@inline Base.convert(::Type{Dual{T,V,N}}, x) where {T,V,N} = Dual{T}(V(x), zero(Partials{N,V}))
@inline Base.convert(::Type{Dual{T,V,N}}, x::Number) where {T,V,N} = Dual{T}(V(x), zero(Partials{N,V}))
Base.convert(::Type{D}, d::D) where {D<:Dual} = d
Expand Down
2 changes: 2 additions & 0 deletions test/DualTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ end
@test typeof(dfmax) === typeof(d1)
@test isfinite(dfmin)
@test isfinite(dfmax)

@test floatmin(Dual{Nothing, ForwardDiff.Dual{Nothing, Float64, 2}, 1}) === Dual{Nothing}(Dual{Nothing}(floatmin(Float64),0.0,0.0),Dual{Nothing}(0.0,0.0,0.0))
end

@testset "Integer" begin
Expand Down

0 comments on commit 2ff6808

Please sign in to comment.