Skip to content

Commit d51f235

Browse files
johnmyleswhiteJohn Myles White
authored andcommitted
Add prevfloat and nextfloat for Dual
Add the prevfloat and nextfloat methods for Dual numbers
1 parent 920717a commit d51f235

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)