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

Returned type of arithmetic operations and functions for IntervalBoxes #149

Closed
lbenet opened this issue May 15, 2018 · 4 comments
Closed

Comments

@lbenet
Copy link
Member

lbenet commented May 15, 2018

I just noticed the following behavior:

julia> using IntervalArithmetic

julia> b = (0..1) × (0..1)
IntervalBox(Interval(0.0, 1.0), Interval(0.0, 1.0))

julia> b+b
2-element StaticArrays.SArray{Tuple{2},IntervalArithmetic.Interval{Float64},1,2}:
 Interval(0.0, 2.0)
 Interval(0.0, 2.0)

julia> typeof(ans)
StaticArrays.SArray{Tuple{2},IntervalArithmetic.Interval{Float64},1,2}

Similar behavior is obtained for other arithmetic operations and functions:

julia> 2*b
2-element StaticArrays.SArray{Tuple{2},IntervalArithmetic.Interval{Float64},1,2}:
 Interval(0.0, 2.0)
 Interval(0.0, 2.0)

julia> exp(b)
2-element StaticArrays.SArray{Tuple{2},IntervalArithmetic.Interval{Float64},1,2}:
 Interval(1.0, 2.7182818284590455)
 Interval(1.0, 2.7182818284590455)

In order to use interval boxes in functions or types which require interval boxes, the returned type of such arithmetic operations should be an IntervalBox.

@lbenet
Copy link
Member Author

lbenet commented May 15, 2018

Is there a reason not to have IntervalBoxes be the returned type in the above cases?

Tests actually check things like A + B == IntervalBox( A .+ B), which A and B IntervalBoxes. My suggestion is to that A + B returns directly IntervalBox( A .+ B).

@dpsanders
Copy link
Member

Yes I think these opérations should return IntervalBoxes as you suggest.

@lbenet
Copy link
Member Author

lbenet commented May 16, 2018

I just noticed i actually don't need this in TaylorModels, but still it would be nice to have it like that. I'll send a PR tomorrow; I haven't completed the tests...

@lbenet
Copy link
Member Author

lbenet commented May 26, 2018

Closing in favor of #150

@lbenet lbenet closed this as completed May 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants