-
Notifications
You must be signed in to change notification settings - Fork 32
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
#1344 - Efficient intersection with intervals #1345
Conversation
This is awesome! 🚀 I started to read the logic of function intersection_b(X::Interval{N}, hs::HalfSpace{N})::Union{Interval{N}, EmptySet{N}} where {N<:Real}
@assert dim(hs) == 1 "cannot take the intersection between an interval " *
"and a $(dim(hs))-dimensional half-space"
lo = min(X); hi = max(X)
b = hs.b; a = hs.a[1]
b_over_a = b / a
if _geq(a, zero(N))
if _leq(b_over_a, lo)
return EmptySet()
else
return Interval(lo, min(b_over_a, hi))
end
else
if _geq(b_over_a, hi)
return EmptySet()
else
return Interval(max(b_over_a, l), hi)
end
end
end |
Using approximations for a sign check does not make sense to me. |
👍 it should be dropped |
I added a new version following your idea. It is, however, not as small as yours because there were problems with division by zero. |
This code does divides in |
Yes, I cared for that. I would say it can happen in practice that |
Closes #1344.