AnderGray / IntervalUnionArithmetic.jl

An implementation of interval union arithmetic in Julia
MIT License
11 stars 4 forks source link

Type piracy with the union operator #5

Open dpsanders opened 3 years ago

dpsanders commented 3 years ago

Loading this package pirates the union operator from IntervalArithmetic. I guess this is OK but it should be documented.

AnderGray commented 3 years ago

This is a good point. We'll make a note of it in the documentation. I believe using hull between intervals should have the same functionality

abraunst commented 2 years ago

To me, it seems that this is a "bug" in IntervalArithmetic, as the union of two interval is not necessary an interval (and the convex hull is different from the union in general!). So IntervalArithmetic maybe should define hull but not union ?

dpsanders commented 2 years ago

I take your point, but I want to be able to use for two intervals and stay within the (standard) interval world. If you want the interval union version, you can use IntervalUnions as your inputs I guess (even though they have a single interval inside).

Also, what should union give if the intervals overlap (in the IntervalUnion case)? There are type-stability, and hence performance, issues to be careful with. The answer should always be an IntervalUnion, even if there's only a single interval.

abraunst commented 2 years ago

I take your point, but I want to be able to use for two intervals and stay within the (standard) interval world. If you want the interval union version, you can use IntervalUnions as your inputs I guess (even though they have a single interval inside).

I see :) Forgive me for the question, but why is it important to use instead of hull? I'm using IntervalUnionArithmetic probably in a rather atypical way (and don't use IntervalArithmetic directly yet) so maybe I don't see the full picture. But it's super useful to me (so thanks both by the way)! At the moment the type piracy thing is a bit ugly, at the very least because it gives a warning in precompilation.

Also, what should union give if the intervals overlap (in the IntervalUnion case)? There are type-stability, and hence performance, issues to be careful with. The answer should always be an IntervalUnion, even if there's only a single interval.

Yes, agreed... hull on the other hand could and should always return an Interval.