Skip to content

Commit 58202dd

Browse files
Merge pull request #453 from johnmyleswhite/patch-1
Add prevfloat and nextfloat for Dual
2 parents 9c196ea + d51f235 commit 58202dd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/dual.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,14 @@ Base.copy(d::Dual) = d
257257
Base.eps(d::Dual) = eps(value(d))
258258
Base.eps(::Type{D}) where {D<:Dual} = eps(valtype(D))
259259

260+
function Base.nextfloat(d::ForwardDiff.Dual{T,V,N}) where {T,V,N}
261+
ForwardDiff.Dual{T}(nextfloat(d.value), d.partials)
262+
end
263+
264+
function Base.prevfloat(d::ForwardDiff.Dual{T,V,N}) where {T,V,N}
265+
ForwardDiff.Dual{T}(prevfloat(d.value), d.partials)
266+
end
267+
260268
Base.rtoldefault(::Type{D}) where {D<:Dual} = Base.rtoldefault(valtype(D))
261269

262270
Base.floor(::Type{R}, d::Dual) where {R<:Real} = floor(R, value(d))

0 commit comments

Comments
 (0)