Skip to content

Commit

Permalink
Fix power_rev for exponents that are integer-valued but not integer-t…
Browse files Browse the repository at this point in the history
…yped (#38)

* Treat exponent 2.0 as if it were 2 by calling the integer version of power_rev

* Fix return type and add test

* Bump version
  • Loading branch information
dpsanders authored Aug 9, 2019
1 parent 06349c7 commit e95b5d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "IntervalContractors"
uuid = "15111844-de3b-5229-b4ba-526f2f385dc9"
version = "0.4.0"
version = "0.4.1"

[deps]
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
Expand Down
5 changes: 5 additions & 0 deletions src/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ end

function power_rev(a::Interval, b::Interval, c::Interval) # a = b^c

if isinteger(c)
temp = power_rev(a, b, Int(inf(c))) # use version with integer
return (temp[1], temp[2], interval(temp[3]))
end

b_new = b ( a^(inv(c) ))
c_new = c (log(a) / log(b))

Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ using Test

@test mul_rev(z, x, y) == (2..10, 2..5, 0.4..1.0)
end

@testset "Exponents with integer values but not types" begin
@test power_rev(-Inf..Inf, -4..4, 2.0) == (-..∞, -4..4, 2.0)
end
end

2 comments on commit e95b5d2

@dpsanders
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/2599

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.1 -m "<description of version>" e95b5d21425d6c757088d284f5a62adda4c7baa4
git push origin v0.4.1

Please sign in to comment.