Skip to content

Commit 2da7077

Browse files
authored
Bump IntervalArithmetic to 0.22 (#57)
* Use \sqcup and \sqcap * Comment out stuff with DecoratedIntervals * Replace a.lo with inf(a) and similarly for .hi and sup * More updates * Bump minor version * Replace == and === in tests with isequal_interval * Fix CI to 1.10 * Bump IntervalBoxes version * Replace Interval() with interval() * Add eq function for testing bareinterval equality * Add single-argument sqr_rev * Add single-arg abs_rev * Add NEWS.md * Add single-argument versions of sin_rev and cos_rev * Typo * Remove usage of member symbol * Fix mulrev_to_pair tests * Add more single-variable versions * Fix another isempty * Correct fix for mul_rev_to_pair tests * Tests passing * Working for bare intervals * Fix tests * Fix test
1 parent 9844021 commit 2da7077

29 files changed

+2369
-2370
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
version:
14-
- '1'
14+
- '1.10'
1515
- 'nightly'
1616
os:
1717
- ubuntu-latest

NEWS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# IntervalContractors.jl NEWS.md
2+
3+
## v0.5.0
4+
- Update to `IntervalArithmetic.jl` v0.22
5+
- Use square versions of intersection and union symbols (available from v0.22.12)
6+
- Some previous functions were removed from `IntervalArithmetic.jl`
7+
8+
- Adds a dependency on the separate `IntervalBoxes.jl` package (to replace the functionality removed from
9+
`IntervalArithmetic.jl`)
10+
11+
- `Interval` now refers to a *decorated* interval

Project.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
name = "IntervalContractors"
22
uuid = "15111844-de3b-5229-b4ba-526f2f385dc9"
3-
version = "0.4.7"
3+
version = "0.5.0"
44

55
[deps]
66
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
7+
IntervalBoxes = "43d83c95-ebbb-40ec-8188-24586a1458ed"
78

89
[compat]
9-
IntervalArithmetic = "0.16, 0.17, 0.18, 0.19, 0.20"
10-
julia = "1.3, 1.4, 1.5"
10+
IntervalArithmetic = "0.22.12"
11+
IntervalBoxes = "0.2"
12+
julia = "1"
1113

1214
[extras]
1315
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
The reverse function of a function `f` calculates the (interval hull of) its inverse function, `f⁻¹`.
2020

21-
For example, `sin_rev(Y::Interval, X::Interval)` calculates the (interval hull of) those `x ∈ X` such that `sin(x) ∈ Y`. This can also be thought of as an inverse function, calculating `X_new := sin⁻¹(Y) X`.
21+
For example, `sin_rev(Y::IntervalType, X::IntervalType)` calculates the (interval hull of) those `x ∈ X` such that `sin(x) ∈ Y`. This can also be thought of as an inverse function, calculating `X_new := sin⁻¹(Y) X`.
2222
The return value is `(Y, X_new)`.
2323

24-
Functions such as `mul_rev(C::Interval, A::Interval, B::Interval)` take three arguments, and correspond to `C = A * B`; they return `(C, A_new, B_new)`, with `A_new` and `B_new` similarly defined to be the corresponding inverse images of the multiplication operator in each component.
24+
Functions such as `mul_rev(C::IntervalType, A::IntervalType, B::IntervalType)` take three arguments, and correspond to `C = A * B`; they return `(C, A_new, B_new)`, with `A_new` and `B_new` similarly defined to be the corresponding inverse images of the multiplication operator in each component.
2525

2626
### Contractors
2727

examples/examples.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ function sawtooth(X::IntervalBox)
55

66
x, y = X
77

8-
x = x (-1..1)
9-
y = y (-2..2)
8+
x = x interval(-1, 1)
9+
y = y interval(-2, 2)
1010

11-
y = y (2x)
12-
x = x (y/2)
11+
y = y (2x)
12+
x = x (y / 2)
1313

1414
return IntervalBox(x, y)
1515
end
1616

1717

1818
function constant_contractor(X, y_val)
1919
x, y = X
20-
y = y Interval(y_val)
20+
y = y interval(y_val)
2121
return IntervalBox(x, y)
2222
end
2323

@@ -26,8 +26,8 @@ end
2626
function add_one(X) # y = x + 1
2727
x, y = X
2828

29-
y = y (x + 1)
30-
x = x (y - 1)
29+
y = y (x + 1)
30+
x = x (y - 1)
3131

3232
return IntervalBox(x, y)
3333
end
@@ -38,10 +38,10 @@ function cube0(X::IntervalBox) # contractor for y=x^3, x>=0
3838

3939
x, y = X
4040

41-
x = x (0..)
41+
x = x (interval(0, Inf))
4242

43-
y = y (x ^ 3)
44-
x = x Interval(y.lo ^ (1/3), y.hi^(1/3)) # not rigorous!
43+
y = y (x ^ 3)
44+
x = x interval(inf(y) ^ (1/3), sup(y)^(1/3)) # not rigorous!
4545

4646
return x × y
4747
end
@@ -53,7 +53,7 @@ odd(X::IntervalBox) = ( (x,y) = X; IntervalBox(-x, -y) )
5353
"""
5454

5555
cube_neg = symmetrise(cube0, odd)
56-
cube = cube0 cube_neg
56+
cube = cube0 cube_neg
5757

5858
ff(x) = x^2 - x^3
5959

@@ -63,10 +63,10 @@ function ff(X::IntervalBox)
6363
a = x^2
6464
b = x^3
6565

66-
y = y (a - b) # y = a - b
66+
y = y (a - b) # y = a - b
6767

68-
a = a (y + b)
69-
b = b (a - y)
68+
a = a (y + b)
69+
b = b (a - y)
7070

7171
x, a = square(IntervalBox(x, a))
7272
x, b = cube(IntervalBox(x, b))

src/IntervalContractors.jl

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
__precompile__(true)
2-
31
module IntervalContractors
42

53
export plus_rev, minus_rev, inv_rev,
@@ -15,14 +13,28 @@ export plus_rev, minus_rev, inv_rev,
1513
mul_rev_IEEE1788, mul_rev_to_pair,
1614
pow_rev1, pow_rev2
1715

18-
using IntervalArithmetic
16+
using IntervalArithmetic, IntervalArithmetic.Symbols
17+
using IntervalBoxes
18+
19+
const IntervalType{T} = Union{Interval{T}, BareInterval{T}}
20+
21+
# @generated
22+
# half_pi(::Type{T}) where {T <: IntervalType} = :(ExactReal(0.5) * convert($T, ExactReal(pi)))
23+
# @generated
24+
# two_pi(::Type{T}) where {T <: IntervalType} = :(ExactReal(2.0) * convert($T, ExactReal(pi)))
25+
26+
@generated function half_pi(x::T) where {T <: IntervalType}
27+
return ExactReal(0.5) * convert(T, ExactReal(pi))
28+
end
29+
30+
@generated function two_pi(x::T) where {T <: IntervalType}
31+
return ExactReal(2.0) * convert(T, ExactReal(pi))
32+
end
1933

20-
const half_pi = IntervalArithmetic.half_pi(Float64) # interval
21-
const two_pi = IntervalArithmetic.two_pi(Float64) # interval
34+
@generated function pi_interval(x::T) where {T <: IntervalType}
35+
return convert(T, ExactReal(pi))
36+
end
2237

23-
#
24-
# Base.:∪(f::Function, g::Function) = X -> ( f(X) ∪ g(X) )
25-
# Base.:∩(f::Function, g::Function) = X -> ( f(X) ∩ g(X) ) # or f(g(X)) for contractors
2638

2739
include("arithmetic.jl")
2840
include("transformations.jl")
@@ -33,7 +45,6 @@ include("inverse_trig.jl")
3345
include("hyperbolic.jl")
3446
include("inverse_hyperbolic.jl")
3547
include("extrema.jl")
36-
include("decorated.jl")
3748

3849
"""
3950
Dictionary mapping functions to their reverse functions.

0 commit comments

Comments
 (0)