-
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
Implement systems for flavor, pointwise extensions, default bound and rounding mode #271
Changes from 55 commits
c8ff400
595af4d
13068ab
2bfdc2a
e0a47c4
97f5a03
39b86fa
eabd93b
86594e4
2819ec8
c67a0f3
ebde437
de2f573
c3eb5fb
4609669
74686d4
4c2b6d2
4ae53b7
8bcab47
33c21b0
bf18a2f
036a1d8
12cfc39
53e4866
ab8fd8b
89358e6
80bbaca
7dfb3f5
474f026
933a89b
cabfeb7
88491f3
9c0ee5c
31409c3
9b48379
f932c61
d6c1e08
fb76b31
09632e8
584aba0
dce76b4
cc5694f
78980f0
91b9250
b3091de
34568d8
3eefa4d
4661780
63cb3b8
67a1fb2
a75eabe
18b3fe2
d1dde57
2fcb8ca
9b46da7
766749f
1cbdc9b
8206d52
7cee9c9
7435671
6a0dcba
9a65cb1
43571ba
bb65c89
87781c1
25110b2
9f44928
a8b7d5a
ac3c35b
8f6e905
0c26577
f02282e
15c2c3c
1765225
a6eb8ab
8554f66
fc69f93
ef69cc3
a08cae5
727aae8
3cd5790
1c51825
2fd86c2
96b090b
a993ef8
8709e1f
ebb2307
df715e2
83d76e9
2c718e4
d58dfae
c2b09f9
a9d5acb
d8e71bb
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
docs/build/ | ||
|
||
.vscode/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
Review intervals folder: | ||
General: | ||
☐ Choose whether to use x == zero(T) or x == 0 across files | ||
Kolaru marked this conversation as resolved.
Show resolved
Hide resolved
|
||
☐ Check that default flavor always return safe result | ||
☐ {F <: Type} -> {F<:Type} (remove spaces) | ||
✔ Replace "IEEE standard" -> "IEEE Std 1788-2015" @done(19-08-22 16:13) | ||
✔ "Corresponds to" -> "Implement" in doc @done(19-08-22 16:13) | ||
✔ Rename `RR` -> `RR` @done(19-08-19 19:14) | ||
☐ Investigate compile time warnings | ||
✔ Check if intervals of different flavor type can/should be equal in the sense of `isidentical` @done(19-12-08 01:12) | ||
☐ Operation on different flavors of interval should always error. | ||
|
||
Kolaru marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Discussion: | ||
☐ Do we want to keep `@floatinterval` and `@biginteral` or use `@interval(F, expr1, expr2)` instead ? | ||
|
||
Global precision: | ||
✔ Get rid of it @done(19-08-20 16:49) | ||
✔ Replace pi_interval(T) by Interval{T}(π) everywhere @done(19-12-18 22:59) | ||
✔ Be sure it is done in compliance with #338 @done(19-12-18 22:59) | ||
|
||
Flavors: | ||
lbenet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Implement set based flavor: | ||
☐ Check all requested stuff 10.5. | ||
☐ Error on undefined | ||
☐ Implement cset flavor | ||
☐ Make cset default | ||
☐ Implement all the needed conversions | ||
☐ Automatise with Cassette.jl ? | ||
|
||
macros.jl: | ||
✔ Review @done(19-08-23 01:57) | ||
☐ Clean or open issue for cleaning of the file | ||
|
||
precision.jl: | ||
✔ Review @done(19-08-19 01:49) | ||
|
||
rounding.jl: | ||
✔ Review @done(19-08-19 01:50) | ||
|
||
conversion.jl: | ||
✔ Review @done(19-08-23 03:25) | ||
☐ Fix ambiguous errors | ||
|
||
complex.jl: | ||
Should we even bother ? | ||
☐ Review | ||
|
||
9.1. Arithmetic functions: | ||
☐ Distribute everything from arithmetic.jl in other files | ||
basic.jl: | ||
✔ Split @done(19-08-19 01:14) | ||
✔ Verify all requested functions are there @done(19-08-19 02:01) | ||
✔ Common @done(19-08-19 01:11) | ||
☐ Adapt for the removal of promotion | ||
☐ Make sure all cases are in the test suite | ||
☐ Solve ambiguity error for real flavors | ||
☐ Flavor dependent * | ||
☐ Flavor dependent / | ||
☐ Flavor dependent inv | ||
☐ Flavor dependent fma | ||
power.jl: | ||
✔ Split @done(19-08-19 01:14) | ||
✔ Verify all requested functions are there @done(19-08-19 04:29) | ||
✔ Common @done(19-08-22 16:25) | ||
☐ Add doc to generated funcs | ||
☐ Flavor dependent power (for negative power) | ||
☐ Flavor dependant log | ||
☐ zero(T) or 0 ? | ||
Kolaru marked this conversation as resolved.
Show resolved
Hide resolved
|
||
trigonometric.jl: | ||
✔ Split @done(19-08-19 02:00) | ||
✔ Verify all requested functions are there @done(19-08-19 02:00) | ||
✔ Clean constants @done(19-08-19 14:13) | ||
✔ Common @done(19-08-19 15:19) | ||
☐ zero(T) or 0 ? | ||
hyperbolic.jl: | ||
✔ Split @done(19-08-19 15:23) | ||
✔ Verify all requested functions are there @done(19-08-19 15:23) | ||
✔ Common @done(19-08-19 15:31) | ||
✔ Add docstring to generated funcs @done(19-08-19 16:45) | ||
☐ Flavor dependent atanh | ||
integer.jl: | ||
✔ Split @done(19-08-19 17:31) | ||
✔ Verify all requested functions are there @done(19-08-19 17:35) | ||
✔ Common @done(19-08-19 17:43) | ||
absmax.jl: | ||
✔ Split @done(19-08-19 17:46) | ||
✔ Verify all requested functions are there @done(19-08-19 17:46) | ||
✔ Common @done(19-08-19 17:48) | ||
|
||
9.2. Cancellative: | ||
✔ Split @done(19-08-19 19:14) | ||
✔ Verify all requested functions are there @done(19-08-19 19:14) | ||
✔ Common @done(19-08-19 19:14) | ||
☐ Check if cancelminus has flavor dependent edge cases | ||
|
||
9.3 Set operations: | ||
✔ Split @done(19-08-19 19:31) | ||
✔ Verify all requested functions are there @done(19-08-19 19:31) | ||
✔ Common @done(19-08-19 19:31) | ||
|
||
9.4. Numeric functions: | ||
✔ Split @done(19-08-19 01:26) | ||
✔ Common @done(19-08-19 01:11) | ||
☐ Solve mid(a, 0.5) != mid(a) discrepency | ||
☐ Flavor dependent mid | ||
|
||
9.5. Boolean functions: | ||
These are in the set_operations.jl file | ||
✔ Split @done(19-08-19 19:30) | ||
✔ Verify all requested functions are there @done(19-08-19 19:31) | ||
✔ Common @done(19-08-19 19:36) | ||
✔ equal is not the same as == @done(19-08-19 19:36) | ||
☐ Check `islessprime` | ||
☐ Flavor dependent issubset/isinterior ? | ||
|
||
9.6. Operatons on/with decoration: | ||
☐ Split | ||
☐ Verify all requested functions are there | ||
☐ Review | ||
|
||
9.7. Literals: | ||
☐ Review | ||
|
||
9.8. Constructor: | ||
☐ Review | ||
☐ Check correctness and tightness for Interval{T}(x) | ||
☐ Document flavors | ||
☐ Document constructors | ||
☐ Make `..` work correctly for all input types | ||
☐ Move `DefaultBound` definition before constructors to be able to use them | ||
✔ Add Interval{T}(π) @done(19-08-19 01:58) | ||
✔ Check performance @done(19-12-18 23:00) | ||
|
||
10.5. Required operations in set-based falvor: | ||
10.5.1. Literals: | ||
☐ No idea, but do it | ||
10.5.2. Constants: | ||
✔ Add ref to doc @done(19-08-21 00:09) | ||
☐ Move deprecation warning to a separated file ? | ||
10.5.3. Forward mode elementary functions: | ||
✔ Add ref to doc @done(19-08-21 00:20) | ||
10.5.4. Reverse mode elementary functions: | ||
✔ Open issue about their absence @done(19-08-20 03:16) | ||
They are in IntervalConstraint.jl | ||
10.5.5. Two output division: | ||
✔ Add ref to doc @done(19-08-21 00:23) | ||
☐ Flavor dependent edge case | ||
☐ Recent GH issue | ||
10.5.6. Cancellative: | ||
✔ Add ref to doc @done(19-08-22 15:51) | ||
☐ Check that the set-based follow the required behavior for undbounded intervals | ||
10.5.7. Set opeations: | ||
✔ Add ref to doc @done(19-08-22 15:55) | ||
10.5.8. Constructors: | ||
☐ Review I guess | ||
10.5.9. Numeric functions: | ||
✔ Add ref to doc @done(19-08-22 15:55) | ||
10.5.10. Boolean: | ||
✔ Check everything required is present @done(19-08-22 16:07) | ||
✔ Add ref to doc @done(19-08-22 16:07) | ||
10.6. Recommended operations: | ||
☐ Check all that stuff | ||
|
||
|
||
Other: | ||
bisect.jl: | ||
☐ Review | ||
display.jl: | ||
☐ Review | ||
InteralArithmetic.jl: | ||
☐ Review | ||
☐ Make sure everything is exported correctly | ||
☐ Check renamed/new functions are exported | ||
parsing.jl: | ||
✔ parsing of bare interval @done(19-08-23 02:28) | ||
☐ parsing of decorated interval | ||
rand.jl: | ||
☐ Review | ||
symbols.jl: | ||
☐ Make sure everything is here | ||
|
||
|
||
Review other folders: | ||
Check PR #271 for details | ||
☐ Do it | ||
|
||
Bugs: | ||
✔ `Int` times `Interval` errors (e.g. `2*a`) @done(19-12-14 23:50) | ||
|
||
Tests: | ||
☐ Uncomment complex tests in `construction.jl` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Changelog | ||
|
||
- File structure changed to match the IEEE standard | ||
- Symbols that alias another function moved to `symbols.jl` | ||
- Removed global precision | ||
- `make_interval` renamed `wrap_literals` | ||
- Removed `pi_interval(T)` in favor of `Interval{T}(π)` | ||
- Renamed `multiply_by_positive_constant` to `scale` | ||
- `@round` now take the flavor of the returned interval as first argument | ||
- Removed `find_quadrants_tan` as it was a duplicate of `find_quadrants` | ||
- Renamed `mid(a, α)` -> `scaled_mid(a, α)` (to avoid discrepency with default parameter) | ||
- Functions returning intervals based on bound type now required a flavor type as parameter | ||
- Renamed `entireinterval` -> `RR` | ||
- Added check of the "IA_DEFAULT_FLAVOR" and "IA_DEFAULT_BOUND_TYPE" keys in `ENV` to get the flavor (`Interval`) and bound type (`DefaultBound`). The default interval type is thus `Interval{DefaultBound}`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ export ×, dot | |
import Base: | ||
+, -, *, /, //, fma, | ||
<, >, ==, !=, ⊆, ^, <=, | ||
isless, | ||
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. If we import 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.
Note that we definitely don't want |
||
in, zero, one, eps, typemin, typemax, abs, abs2, real, min, max, | ||
sqrt, exp, log, sin, cos, tan, cot, inv, cbrt, csc, hypot, sec, | ||
exp2, exp10, log2, log10, | ||
|
@@ -50,18 +51,19 @@ import Base.MPFR: MPFRRoundUp, MPFRRoundDown, MPFRRoundNearest, MPFRRoundToZero, | |
import .Broadcast: broadcasted | ||
|
||
export | ||
AbstractInterval, Interval, | ||
Interval, DefaultBound, | ||
interval, | ||
@interval, @biginterval, @floatinterval, @make_interval, | ||
diam, radius, mid, mag, mig, hull, | ||
emptyinterval, ∅, ∞, isempty, isinterior, ⪽, | ||
precedes, strictprecedes, ≼, ≺, ⊂, ⊃, ⊇, contains_zero, | ||
entireinterval, isentire, nai, isnai, isthin, iscommon, isatomic, | ||
@interval, @biginterval, @floatinterval, | ||
diam, radius, mid, scaled_mid, mag, mig, hull, | ||
emptyinterval, ∅, ∞, isempty, isinterior, isdisjoint, ⪽, | ||
precedes, strictprecedes, ≺, ⊂, ⊃, ⊇, contains_zero, | ||
isidentical, isdistinct, | ||
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. Maybe export |
||
RR, isentire, nai, isnai, isthin, iscommon, isatomic, | ||
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. Since |
||
widen, inf, sup, bisect, mince, | ||
parameters, eps, dist, | ||
eps, dist, | ||
midpoint_radius, interval_from_midpoint_radius, | ||
RoundTiesToEven, RoundTiesToAway, | ||
cancelminus, cancelplus, isunbounded, | ||
cancelminus, cancelplus, isbounded, isunbounded, | ||
.., @I_str, ±, | ||
pow, extended_div, | ||
setformat, @format | ||
|
@@ -76,8 +78,6 @@ end | |
export | ||
setindex # re-export from StaticArrays for IntervalBox | ||
|
||
|
||
|
||
export showfull | ||
|
||
import Base: rounding, setrounding, setprecision | ||
|
@@ -102,28 +102,24 @@ export | |
|
||
function __init__() | ||
setrounding(BigFloat, RoundNearest) | ||
|
||
|
||
setprecision(Interval, 256) # set up pi | ||
setprecision(Interval, Float64) | ||
end | ||
|
||
|
||
## Includes | ||
|
||
include("intervals/intervals.jl") | ||
|
||
include("multidim/multidim.jl") | ||
include("bisect.jl") | ||
include("decorations/decorations.jl") | ||
|
||
include("rand.jl") | ||
include("parsing.jl") | ||
include("display.jl") | ||
include("symbols.jl") | ||
|
||
include("plot_recipes/plot_recipes.jl") | ||
|
||
include("deprecated.jl") | ||
|
||
""" | ||
Region{T} = Union{Interval{T}, IntervalBox{T}} | ||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ Returns a tuple of the new intervals. | |
function bisect(X::Interval, α=where_bisect) | ||
@assert 0 ≤ α ≤ 1 | ||
|
||
m = mid(X, α) | ||
m = scaled_mid(X, α) | ||
|
||
return (Interval(X.lo, m), Interval(m, X.hi)) | ||
end | ||
|
@@ -40,3 +40,38 @@ function bisect(X::IntervalBox, i::Integer, α=where_bisect) | |
|
||
return (X1, X2) | ||
end | ||
|
||
""" | ||
mince(x::Interval, n) | ||
|
||
Splits `x` in `n` intervals of the same diameter, which are returned | ||
as a vector. | ||
""" | ||
function mince(x::Interval, n) | ||
nodes = range(x.lo, x.hi, length = n+1) | ||
return [Interval(nodes[i], nodes[i+1]) for i in 1:length(nodes)-1] | ||
end | ||
|
||
""" | ||
mince(x::IntervalBox, n) | ||
|
||
Splits `x` in `n` intervals in each dimension of the same diameter. These | ||
intervals are combined in all possible `IntervalBox`-es, which are returned | ||
as a vector. | ||
""" | ||
@generated function mince(x::IntervalBox{N,T}, n) where {N,T} | ||
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. Comment: I just noticed that there is also |
||
quote | ||
nodes_matrix = Array{Interval{T},2}(undef, n, N) | ||
for i in 1:N | ||
nodes_matrix[1:n,i] .= mince(x[i], n) | ||
end | ||
|
||
nodes = IntervalBox{$N,T}[] | ||
Base.Cartesian.@nloops $N i _->(1:n) begin | ||
Base.Cartesian.@nextract $N ival d->nodes_matrix[i_d, d] | ||
ibox = Base.Cartesian.@ncall $N IntervalBox ival | ||
push!(nodes, ibox) | ||
end | ||
nodes | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
include("intervals.jl") | ||
include("functions.jl") | ||
|
||
# TODO Check if it is consistent with #386 | ||
isnan(x::AbstractFlavor) = false # NaI is always decorated | ||
|
||
# TODO adapt for each flavor | ||
"""`NaI` not-an-interval: [NaN, NaN].""" | ||
nai(::Type{T}) where T = DecoratedInterval(convert(T, NaN), convert(T, NaN), ill) | ||
nai(::Type{F}) where {T, F<:Interval{T}} = nai(T) | ||
nai(::Interval{T}) where T<:Real = nai(T) | ||
nai(::DecoratedInterval{T}) where T<:Real = nai(T) | ||
nai() = nai(Interval{DefaultBound}) | ||
|
||
isnai(x::Interval) = isnan(x.lo) || isnan(x.hi) | ||
isnai(x::DecoratedInterval) = isnai(interval(x)) && x.decoration == ill |
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.
could you please gitignore this and the changelog? It adds a lot of noise when browsing the PR from github.