Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update intervalbox.jl #520

Merged
merged 3 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -81,6 +81,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
7 changes: 6 additions & 1 deletion test/multidim_tests/multidim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ 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