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

Make @interval return a Float64 interval #127

Closed
dpsanders opened this issue Apr 12, 2018 · 2 comments · Fixed by #567
Closed

Make @interval return a Float64 interval #127

dpsanders opened this issue Apr 12, 2018 · 2 comments · Fixed by #567

Comments

@dpsanders
Copy link
Member

Since Float64 is the most common case, I suggest that @interval do what @floatinterval does now.

@lbenet
Copy link
Member

lbenet commented Apr 12, 2018

I think it already does that by default. Consider the following:

julia> using IntervalArithmetic

julia> a = big"0.1"
1.000000000000000000000000000000000000000000000000000000000000000000000000000002e-01

julia> f(x) = @interval a + x
f (generic function with 1 method)

julia> g(x) = @biginterval a + x
g (generic function with 1 method)

julia> @format full
6

julia> f(0.0)
Interval(0.09999999999999999, 0.1)

julia> g(0.0)
Interval(9.999999999999999999999999999999999999999999999999999999999999999999999999999914e-02, 1.000000000000000000000000000000000000000000000000000000000000000000000000000002e-01)

Or do you mean something else?

@dpsanders
Copy link
Member Author

julia> @macroexpand @interval 0.1
:((IntervalArithmetic.Interval)((IntervalArithmetic.atomic)((IntervalArithmetic.Interval){IntervalArithmetic.parameters.precision_type}, 0.1)))

julia> @macroexpand @floatinterval 0.1
:((IntervalArithmetic.Interval)((IntervalArithmetic.atomic)((IntervalArithmetic.Interval){Float64}, 0.1)))

@interval uses the nasty global precision business -- probably we should just get rid of that?
That leads to a factor 4 slowdown in

g(x) = @interval 0.1 + x
versus
h(x) = @floatinterval 0.1 + x

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

Successfully merging a pull request may close this issue.

3 participants