Skip to content

Commit 80b9d5d

Browse files
authored
dual exponent (#605)
* add exponent(::Dual) * revert spacing
1 parent 25f8f73 commit 80b9d5d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/dual.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ Base.fld(x::Dual, y::Dual) = fld(value(x), value(y))
332332

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

335+
Base.exponent(x::Dual) = exponent(value(x))
336+
335337
if VERSION v"1.4"
336338
Base.div(x::Dual, y::Dual, r::RoundingMode) = div(value(x), value(y), r)
337339
else

test/DualTest.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ForwardDiff.:≺(::Type{OuterTestTag}, ::Type{TestTag}) = false
4444
PARTIALS3 = Partials{N,V}(ntuple(n -> intrand(V), N))
4545
PRIMAL3 = intrand(V)
4646
FDNUM3 = Dual{TestTag()}(PRIMAL3, PARTIALS3)
47-
47+
4848
if !allunique([PRIMAL, PRIMAL2, PRIMAL3])
4949
@info "testing with non-unique primals" PRIMAL PRIMAL2 PRIMAL3
5050
end
@@ -162,6 +162,10 @@ ForwardDiff.:≺(::Type{OuterTestTag}, ::Type{TestTag}) = false
162162
@test fld(FDNUM, PRIMAL2) === fld(PRIMAL, PRIMAL2)
163163
@test fld(PRIMAL, FDNUM2) === fld(PRIMAL, PRIMAL2)
164164

165+
@test exponent(FDNUM) === exponent(PRIMAL)
166+
@test exponent(FDNUM2) === exponent(PRIMAL2)
167+
@test exponent(NESTED_FDNUM) === exponent(PRIMAL)
168+
165169
@test cld(FDNUM, FDNUM2) === cld(PRIMAL, PRIMAL2)
166170
@test cld(FDNUM, PRIMAL2) === cld(PRIMAL, PRIMAL2)
167171
@test cld(PRIMAL, FDNUM2) === cld(PRIMAL, PRIMAL2)
@@ -414,7 +418,7 @@ ForwardDiff.:≺(::Type{OuterTestTag}, ::Type{TestTag}) = false
414418
#----------#
415419

416420
if M > 0 && N > 0
417-
# Recall that FDNUM = Dual{TestTag()}(PRIMAL, PARTIALS) has N partials,
421+
# Recall that FDNUM = Dual{TestTag()}(PRIMAL, PARTIALS) has N partials,
418422
# all random numbers nonzero, and FDNUM2 another draw. M only affects NESTED_FDNUM.
419423
@test Dual{1}(FDNUM) / Dual{1}(PRIMAL) === Dual{1}(FDNUM / PRIMAL)
420424
@test Dual{1}(PRIMAL) / Dual{1}(FDNUM) === Dual{1}(PRIMAL / FDNUM)

0 commit comments

Comments
 (0)