Skip to content
Closed
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
3 changes: 3 additions & 0 deletions src/dual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,9 @@ function Base.show(io::IO, d::Dual{T,V,N}) where {T,V,N}
end

for op in (:(Base.typemin), :(Base.typemax), :(Base.floatmin), :(Base.floatmax))
@eval function $op(::ForwardDiff.Dual{T,V,N}) where {T,V,N}
ForwardDiff.Dual{T,V,N}($op(V))
end
@eval function $op(::Type{ForwardDiff.Dual{T,V,N}}) where {T,V,N}
ForwardDiff.Dual{T,V,N}($op(V))
end
Expand Down
6 changes: 6 additions & 0 deletions test/DualTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,12 @@ end
@test isfinite(dfmin)
@test isfinite(dfmax)

# Functions can be called with type or value
@test typemin(d1) == typemin(typeof(d1))
@test typemax(d1) == typemax(typeof(d1))
@test floatmin(d1) == floatmin(typeof(d1))
@test floatmax(d1) == floatmax(typeof(d1))

@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

Expand Down
Loading