Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/dual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ end
if S ≺ T
d
else
throw(DualMismatchError(T,S))
throw(DualMismatchError(T,S))
end
end

Expand Down Expand Up @@ -612,3 +612,11 @@ function Base.show(io::IO, d::Dual{T,V,N}) where {T,V,N}
end
print(io, ")")
end

function Base.typemin(::Type{ForwardDiff.Dual{T,V,N}}) where {T,V,N}
ForwardDiff.Dual{T,V,N}(typemin(V))
end

function Base.typemax(::Type{ForwardDiff.Dual{T,V,N}}) where {T,V,N}
ForwardDiff.Dual{T,V,N}(typemax(V))
end
11 changes: 11 additions & 0 deletions test/DualTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,15 @@ end
@test pow(x1, 0) === x1^0 === Dual{:t1}(1.0, 0.0)
end

@testset "Type min/max" begin
d1 = Dual(1.0)
dinf = typemax(typeof(d1))
dminf = typemin(typeof(d1))
@test dminf < d1 < dinf
@test typeof(dminf) === typeof(d1)
@test typeof(dinf) === typeof(d1)
@test !isfinite(dminf)
@test !isfinite(dinf)
end

end # module