Skip to content

Commit

Permalink
Update intervalbox.jl (#520)
Browse files Browse the repository at this point in the history
* Update intervalbox.jl

* Update multidim.jl

* Update Project.toml
  • Loading branch information
mforets authored and lucaferranti committed May 27, 2022
1 parent 1b84a19 commit ffda697
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "IntervalArithmetic"
uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
repo = "https://github.com/JuliaIntervals/IntervalArithmetic.jl.git"
version = "0.20.5"
version = "0.20.6"

[deps]
CRlibm = "96374032-68de-5a5b-8d9e-752f78720389"
Expand Down
5 changes: 5 additions & 0 deletions src/multidim/intervalbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ end
(X::AbstractVector, Y::IntervalBox{N, T}) where {N, T} = all(X .∈ Y)
(X, Y::IntervalBox{N, T}) where {N, T} = throw(ArgumentError("$X$Y is not defined"))

# mixing intervals with one-dimensional interval boxes
for op in (:, :, :, :, :)
@eval $(op)(a::Interval, X::IntervalBox{1}) = $(op)(a, first(X))
@eval $(op)(X::IntervalBox{1}, a::Interval) = $(op)(first(X), a)
end

#=
On Julia 0.6 can now write
Expand Down
9 changes: 8 additions & 1 deletion test/multidim_tests/multidim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ let X, A # avoid problems with global variables
@test A B.v B
end

x = 0.5 .. 3
a = IntervalBox(A[1]) # 1 .. 2
@test !(x a) && a x
@test !(x a) && a x
@test x a == a x == A[1]
@test x a == a x == x

X = IntervalBox(1..2, 3..4)
Y = IntervalBox(3..4, 3..4)

Expand Down Expand Up @@ -333,7 +340,7 @@ end
@test hull(vb3...) ib3
@test hull(vb3) ib3
@test all(mince(ib3, (4,4,4)) .≛ vb3)
@test all(mince(ib3, (2,1,1)) .≛ [(-1 .. 0)×(-1 .. 1)×(-1 .. 1),
@test all(mince(ib3, (2,1,1)) .≛ [(-1 .. 0)×(-1 .. 1)×(-1 .. 1),
(0 .. 1)×(-1 .. 1)×(-1 .. 1)])
@test hull(mince(ib3, (2,1,1))) ib3

Expand Down

0 comments on commit ffda697

Please sign in to comment.