From eb8d755bc7752b4fe2a50bca5ffae336ef288c12 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sat, 10 Dec 2022 09:30:39 -0500 Subject: [PATCH] Backport #605 (dual exponent) to release-0.10 (#614) * dual exponent (#605) * add exponent(::Dual) * revert spacing * tell CI to run on this branch * version bump Co-authored-by: Paul Tiede --- .github/workflows/ci.yml | 3 +++ Project.toml | 2 +- src/dual.jl | 2 ++ test/DualTest.jl | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f83be7ce..56350777 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,9 +3,11 @@ on: pull_request: branches: - master + - release-0.10 push: branches: - master + - release-0.10 tags: '*' jobs: test: @@ -17,6 +19,7 @@ jobs: matrix: version: - '1.0' + - '1.6' - '1' - 'nightly' os: diff --git a/Project.toml b/Project.toml index a98f72a2..1bd9a6ae 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ForwardDiff" uuid = "f6369f11-7733-5829-9624-2563aa707210" -version = "0.10.32" +version = "0.10.34" [deps] CommonSubexpressions = "bbf7d656-a473-5ed7-a52c-81e309532950" diff --git a/src/dual.jl b/src/dual.jl index 48e14a7c..d5847083 100644 --- a/src/dual.jl +++ b/src/dual.jl @@ -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 diff --git a/test/DualTest.jl b/test/DualTest.jl index a01649fe..be3ea25a 100644 --- a/test/DualTest.jl +++ b/test/DualTest.jl @@ -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)