Skip to content

Commit

Permalink
dual exponent (JuliaDiff#605)
Browse files Browse the repository at this point in the history
* add exponent(::Dual)

* revert spacing
  • Loading branch information
ptiede authored and mcabbott committed Dec 3, 2022
1 parent 61e4dd4 commit 4bea4bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/dual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ Base.fld(x::Dual, y::Dual) = fld(value(x), value(y))

Base.cld(x::Dual, y::Dual) = cld(value(x), value(y))

Base.exponent(x::Dual) = exponent(value(x))

if VERSION v"1.4"
Base.div(x::Dual, y::Dual, r::RoundingMode) = div(value(x), value(y), r)
else
Expand Down
4 changes: 4 additions & 0 deletions test/DualTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ for N in (0,3), M in (0,4), V in (Int, Float32)
@test fld(FDNUM, PRIMAL2) === fld(PRIMAL, PRIMAL2)
@test fld(PRIMAL, FDNUM2) === fld(PRIMAL, PRIMAL2)

@test exponent(FDNUM) === exponent(PRIMAL)
@test exponent(FDNUM2) === exponent(PRIMAL2)
@test exponent(NESTED_FDNUM) === exponent(PRIMAL)

@test cld(FDNUM, FDNUM2) === cld(PRIMAL, PRIMAL2)
@test cld(FDNUM, PRIMAL2) === cld(PRIMAL, PRIMAL2)
@test cld(PRIMAL, FDNUM2) === cld(PRIMAL, PRIMAL2)
Expand Down

0 comments on commit 4bea4bc

Please sign in to comment.