-
Notifications
You must be signed in to change notification settings - Fork 71
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
Add methods for IntervalBox previously in IntervalRootFinding #160
Conversation
See also JuliaIntervals/IntervalRootFinding.jl#78, which requires a new patch version. |
@dpsanders Question: Currently, Incidentally, tests are passing (except maybe for appveyor). |
Codecov Report
@@ Coverage Diff @@
## master #160 +/- ##
=========================================
+ Coverage 91.95% 92.15% +0.2%
=========================================
Files 22 23 +1
Lines 1044 1058 +14
=========================================
+ Hits 960 975 +15
+ Misses 84 83 -1
Continue to review full report at Codecov.
|
@dpsanders Should I go ahead and merge this? |
The default for |
src/multidim/intervalbox.jl
Outdated
@@ -45,7 +45,7 @@ Return a vector of the `mid` of each interval composing the `IntervalBox`. | |||
See `mid(X::Interval, α=0.5)` for more informations. | |||
""" | |||
mid(X::IntervalBox) = mid.(X) | |||
mid(X::IntervalBox, α) = mid.(X, α) | |||
mid(X::IntervalBox, α) = mid.(X[:], α) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be left as mid.(X, alpha)
after incorporating the change in #159
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/multidim/intervalbox.jl
Outdated
@@ -73,6 +73,12 @@ diam(X::IntervalBox) = maximum(diam.(X.v)) | |||
|
|||
emptyinterval(X::IntervalBox{N,T}) where {N,T} = IntervalBox(emptyinterval.(X.v)) | |||
|
|||
isinf(X::IntervalBox) = any(isinf.(X)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be written any(isinf, X)
, which I believe should be slightly faster.
src/multidim/intervalbox.jl
Outdated
|
||
isinterior(X::IntervalBox{N,T}, Y::IntervalBox{N,T}) where {N,T} = all(isinterior.(X, Y)) | ||
|
||
contains_zero(X::SVector) = all(contains_zero.(X)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all(contains_zero, X)
src/multidim/intervalbox.jl
Outdated
isinterior(X::IntervalBox{N,T}, Y::IntervalBox{N,T}) where {N,T} = all(isinterior.(X, Y)) | ||
|
||
contains_zero(X::SVector) = all(contains_zero.(X)) | ||
contains_zero(X::IntervalBox) = all(contains_zero.(X)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
@@ -14,7 +14,6 @@ end | |||
|
|||
@testset "Complex functions" begin | |||
Z = (3 ± 1e-7) + (4 ± 1e-7)*im | |||
@test sin(Z) == Interval(3.853734949309744, 3.8537411265295543) - Interval(27.016810169394066, 27.016816346613904)*im | |||
|
|||
@test sin(Z) == complex(sin(real(Z))*cosh(imag(Z)),sinh(imag(Z))*cos(real(Z))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I though this way is more stable :-)
LGTM, thanks! Feel free to incorporate #159 here. |
I've merged #159, rebased to current master, included a missing suggestion of your review. I'll wait for travis tests to pass, and then merge. |
Merged. |
@@ -0,0 +1,42 @@ | |||
|
|||
const where_bisect = 0.49609375 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a magic constant :) 0.5 - 1/256, if I'm not mistaken. Is there a particular reason for that?
No particular reason, just something close to 0.5 but not exactly equal to 0.5. |
I think we needed something close to zero and to be exactly-representable floating point. Also, I think there were cases were rounding down had some sort of preference. |
Fixes #158