-
Notifications
You must be signed in to change notification settings - Fork 70
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
[WIP / RFC] Configuration mechanism for directed rounding and fast powers #388
Changes from all commits
fa7aab4
ce61769
4f1a4b0
0a5e2ac
089a7e6
c6feb3f
81134b9
cfddaef
044c947
524cd4c
de103ee
b2fb8ec
7a8838c
c3a07c6
6e9ed32
1e714b5
42f6c74
8989bb3
d3aa7c0
73fc001
d585a4d
997e32c
3c00c99
d35b415
5751634
b669b09
57f401f
d40067e
9e36c14
afdd6b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
Holds configuration information for the package: | ||
|
||
- `directed_rounding`: | ||
|
||
Which method to use to implement **directed rounding**. | ||
Possible values are: | ||
|
||
- `:tight`: correct rounding using error-free arithmetic and CRlibm. Gives | ||
the tightest resulting intervals, with a width of 1 ulp for each basic operation | ||
- `:fast`: uses `prevfloat` and `nextfloat` to give a faster result, with width 2 ulps | ||
- `:none`: no rounding; does *not* guarantee that the results are correct. | ||
|
||
- `powers`: | ||
Method to implement powers. Possible values are | ||
- `:tight`: gives tightest possible result by using `BigFloat` internally, and hence is slow | ||
- `:fast`: uses repeated multiplication based on `Base.power_by_squaring`, and hence is faster but gives slightly looser results | ||
""" | ||
|
||
const configuration = Dict(:directed_rounding => :tight, | ||
:powers => :fast) | ||
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have as default configuration that both defaults are |
||
|
||
const allowed_values = Dict(:directed_rounding => (:tight, :fast, :none), | ||
:powers => (:tight, :fast)) | ||
|
||
function configure!(; directed_rounding=nothing, powers=nothing) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about fixing the defaults here, instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rebump question... |
||
if directed_rounding != nothing | ||
if directed_rounding ∉ allowed_values[:directed_rounding] | ||
throw(ArgumentError("directed_rounding must be one of $(allowed_values[:directed_rounding])")) | ||
end | ||
|
||
configuration[:directed_rounding] = directed_rounding | ||
|
||
# name mismatch | ||
if directed_rounding == :fast | ||
directed_rounding = :accurate | ||
end | ||
Comment on lines
+34
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should only use one of them, say |
||
|
||
set_directed_rounding(directed_rounding) | ||
end | ||
|
||
if powers != nothing | ||
if powers ∉ allowed_values[:powers] | ||
throw(ArgumentError("powers must be one of $(allowed_values[:powers])")) | ||
end | ||
|
||
configuration[:powers] = powers | ||
|
||
set_power_type(powers) | ||
end | ||
|
||
return configuration | ||
|
||
end | ||
|
||
|
||
configure!(directed_rounding=:tight, powers=:fast) |
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.
Since we are getting rid of
rounding
andsetrounding
, shouldn't we amend (in parallel) the docs? Similarly, we should add the corresponding docs ofIntervalArithmetic.set_directed_rounding