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
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
8 changes: 6 additions & 2 deletions test/DualTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ForwardDiff.:≺(::Type{OuterTestTag}, ::Type{TestTag}) = false
PARTIALS3 = Partials{N,V}(ntuple(n -> intrand(V), N))
PRIMAL3 = intrand(V)
FDNUM3 = Dual{TestTag()}(PRIMAL3, PARTIALS3)

if !allunique([PRIMAL, PRIMAL2, PRIMAL3])
@info "testing with non-unique primals" PRIMAL PRIMAL2 PRIMAL3
end
Expand Down Expand Up @@ -162,6 +162,10 @@ ForwardDiff.:≺(::Type{OuterTestTag}, ::Type{TestTag}) = false
@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 Expand Up @@ -414,7 +418,7 @@ ForwardDiff.:≺(::Type{OuterTestTag}, ::Type{TestTag}) = false
#----------#

if M > 0 && N > 0
# Recall that FDNUM = Dual{TestTag()}(PRIMAL, PARTIALS) has N partials,
# Recall that FDNUM = Dual{TestTag()}(PRIMAL, PARTIALS) has N partials,
# all random numbers nonzero, and FDNUM2 another draw. M only affects NESTED_FDNUM.
@test Dual{1}(FDNUM) / Dual{1}(PRIMAL) === Dual{1}(FDNUM / PRIMAL)
@test Dual{1}(PRIMAL) / Dual{1}(FDNUM) === Dual{1}(PRIMAL / FDNUM)
Expand Down