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 decorated interval the default #590

Merged
merged 33 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c421962
Make decorated interval the default
OlivierHnt Oct 30, 2023
ecfc3ef
Remove warning
OlivierHnt Oct 30, 2023
f9d5afe
Fix decoration
OlivierHnt Oct 30, 2023
25d6630
Fix tests
OlivierHnt Oct 30, 2023
731df23
Fix tests
OlivierHnt Oct 30, 2023
d20e2df
Fix NaI
OlivierHnt Nov 1, 2023
01921a0
Minor cleanup
OlivierHnt Nov 13, 2023
0b14d21
Add docstring for `_unsafe_bareinterval`
OlivierHnt Nov 13, 2023
e9271ff
Remove decoration `bad` in favour of a new field
OlivierHnt Nov 13, 2023
45990ac
Minor cleanup
OlivierHnt Nov 14, 2023
1390772
Remove `signbit`
OlivierHnt Nov 14, 2023
70c9abf
Fix `pow` and cleanup
OlivierHnt Nov 14, 2023
56cec04
Fix tests
OlivierHnt Nov 14, 2023
5991c5b
Special display for unguaranteed interval
OlivierHnt Nov 14, 2023
9c1283e
Cleanup
OlivierHnt Nov 18, 2023
49d6c8e
Update docs
OlivierHnt Nov 18, 2023
cb6c91e
Fix doctest
OlivierHnt Nov 18, 2023
736971f
Do not error for missing docstring
OlivierHnt Nov 18, 2023
bde155f
Rename `guarantee` to `isguaranteed`
OlivierHnt Nov 27, 2023
d1ab589
Delete empty file decorations.md
OlivierHnt Nov 27, 2023
ad4bc09
Fix missing field infos in docstring
OlivierHnt Nov 27, 2023
0dd6a75
Update `isguaranteed` docstring
OlivierHnt Nov 27, 2023
795dd3b
Update docs
OlivierHnt Nov 27, 2023
a0f88ce
Ensures `NaN` is converted to a NaI
OlivierHnt Nov 28, 2023
1df80e0
Update docs
OlivierHnt Nov 28, 2023
ecbb119
Minor cleanup
OlivierHnt Nov 28, 2023
fb730de
Fix typo
OlivierHnt Dec 1, 2023
d7fcc98
Fix error for boolean functions from Base
OlivierHnt Dec 1, 2023
5d7dbf2
Add docstrings
OlivierHnt Dec 1, 2023
7844416
Fix bug
OlivierHnt Dec 1, 2023
5fb425d
Fix `StackOverflow`
OlivierHnt Dec 1, 2023
7b2def0
Fix `StackOverFlow`
OlivierHnt Dec 1, 2023
dfb71a6
Set correct cuurent version
OlivierHnt Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ If you use the IntervalArithmetic library in your publication, research, teachin
This project began in 2014 during a masters' course in the postgraduate programs of Mathematics and Physics at the Universidad Nacional Autónoma de México. It was initially written in Python, then reinitiated in 2015 and rewritten in Julia. We thank the participants of the courses for their contribution, energy and ideas.



## Support

Financial support is acknowledged from DGAPA-UNAM PAPIME grants PE-105911 and PE-107114, and DGAPA-UNAM PAPIIT grant IN-117214.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/manual/construction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Constructing an interval is the most basic operation in the library. The [`inter

```@repl construction
using IntervalArithmetic
setformat(:full) # print the interval in full
setdisplay(:full) # print the interval in full
interval(0.1) # interval(Float64, 0.1)
interval(0.1, 0.2) # interval(Float64, 0.1, 0.2)
interval(3.1f0) # interval(Float32, 3.1f0)
Expand Down
26 changes: 13 additions & 13 deletions docs/src/manual/decorations.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ An example will be given at the end of this section.

## Initialisation

The simplest way to create a `DecoratedInterval` is as follows:
The simplest way to create a `Interval` is as follows:
```
julia> X = DecoratedInterval(3, 4)
julia> X = Interval(3, 4)
[3, 4]
```

By default, decorations are not displayed. The following turns on display of decorations:
```
julia> setformat(decorations=true)
julia> setdisplay(decorations=true)
Display parameters:
- format: standard
- decorations: true
Expand All @@ -47,7 +47,7 @@ julia> X

To parse string, for decorated interval add `_dec` at the end of the string otherwise decoration is determined using `decoration` function.

If no decoration is explicitly specified when a `DecoratedInterval` is created, then it is initialised with a decoration according to its interval `X`:
If no decoration is explicitly specified when a `Interval` is created, then it is initialised with a decoration according to its interval `X`:

- `com`: if `X` is nonempty and bounded;
- `dac` if `X` is unbounded;
Expand All @@ -56,20 +56,20 @@ If no decoration is explicitly specified when a `DecoratedInterval` is created,

An explicit decoration may be provided for advanced use:
```
julia> DecoratedInterval(3, 4, dac)
julia> Interval(3, 4, dac)
[3, 4]_dac

julia> DecoratedInterval(X, def)
julia> Interval(X, def)
[3, 4]_def
```
Here, a new `DecoratedInterval` was created by extracting the interval from another one and appending a different decoration.
Here, a new `Interval` was created by extracting the interval from another one and appending a different decoration.

## Action of functions

A decoration is the combination of an interval together with the sequence of functions that it has passed through. Here are some examples:

```
julia> X1 = DecoratedInterval(0.5, 3)
julia> X1 = Interval(0.5, 3)
[0.5, 3]_com

julia> sqrt(X1)
Expand All @@ -78,7 +78,7 @@ julia> sqrt(X1)
In this case, both input and output are "common" intervals, meaning that they are closed and bounded, and that the resulting function is continuous over the input interval, so that fixed-point theorems may be applied. Since `sqrt(X1) ⊆ X1`, we know that there must be a fixed point of the function inside the interval `X1` (in this case, `sqrt(1) == 1`).

```
julia> X2 = DecoratedInterval(3, ∞)
julia> X2 = Interval(3, ∞)
[3, ∞]_dac

julia> sqrt(X2)
Expand All @@ -87,7 +87,7 @@ julia> sqrt(X2)
Since the intervals are unbounded here, the maximum decoration possible is `dac`.

```
julia> X3 = DecoratedInterval(-3, 4)
julia> X3 = Interval(-3, 4)
[-3, 4]_com

julia> sign(X3)
Expand All @@ -96,7 +96,7 @@ julia> sign(X3)
The `sign` function is discontinuous at 0, but is defined everywhere on the input interval, so the decoration is `def`.

```
julia> X4 = DecoratedInterval(-3.5, 4.1)
julia> X4 = Interval(-3.5, 4.1)
[-3.5, 4.1]_com

julia> sqrt(X4)
Expand All @@ -108,13 +108,13 @@ The negative part of `X` is discarded by the `sqrt` function, since its domain i
In this case, we know why the decoration was reduced to `trv`. But if this were just a single step in a longer calculation, a resulting `trv` decoration shows only that something like this happened *at some step*. For example:

```
julia> X5 = DecoratedInterval(-3, 3)
julia> X5 = Interval(-3, 3)
[-3, 3]_com

julia> asin(sqrt(X5))
[0, 1.5708]_trv

julia> X6 = DecoratedInterval(0, 3)
julia> X6 = Interval(0, 3)
[0, 3]_com

julia> asin(sqrt(X6))
Expand Down
18 changes: 9 additions & 9 deletions docs/src/manual/usage.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Display modes

There are several useful output representations for intervals, some of which we have already touched on. The display is controlled globally by the `setformat` function, which has
the following options, specified by keyword arguments (type `?setformat` to get help at the REPL):
There are several useful output representations for intervals, some of which we have already touched on. The display is controlled globally by the `setdisplay` function, which has
the following options, specified by keyword arguments (type `?setdisplay` to get help at the REPL):

- `format`: interval output format

Expand All @@ -17,17 +17,17 @@ the following options, specified by keyword arguments (type `?setformat` to get

```@repl
using IntervalArithmetic
setformat() # default values
setdisplay() # default values
a = interval(1.1, pi)
setformat(; sigdigits = 10)
setdisplay(; sigdigits = 10)
a
setformat(:full)
setdisplay(:full)
a
setformat(:midpoint)
setdisplay(:midpoint)
a
setformat(; sigdigits = 4)
setdisplay(; sigdigits = 4)
a
setformat(:standard)
setdisplay(:standard)
a
```

Expand All @@ -45,7 +45,7 @@ For example,

```@repl usage
using IntervalArithmetic
setformat(:full)
setdisplay(:full)
X = interval(0, 1)
Y = interval(1, 2)
X + Y
Expand Down
26 changes: 8 additions & 18 deletions src/IntervalArithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ using SetRounding
using EnumX

import Base:
+, -, *, /, //, muladd, fma,
^, sqrt, exp, log, exp2, exp10, log2, log10, inv, cbrt, hypot,
zero, one, eps, typemin, typemax, abs, abs2, min, max,
rad2deg, deg2rad,
sin, cos, tan, cot, csc, sec, asin, acos, atan, acot, sinpi, cospi, sincospi,
+, -, *, /, inv, //, muladd, fma, sqrt,
sinh, cosh, tanh, coth, csch, sech, asinh, acosh, atanh, acoth,
rad2deg, deg2rad, sin, cos, tan, cot, csc, sec, asin, acos, atan, acot, sinpi, cospi, sincospi,
exp, log, exp2, exp10, log2, log10, cbrt, hypot, ^,
zero, one, eps, typemin, typemax, abs, abs2, min, max,
float, big,
floor, ceil, trunc, sign, round, copysign, flipsign, signbit,
expm1, log1p,
precision,
abs, abs2,
show,
parse, hash

Expand All @@ -36,15 +34,14 @@ end
#

include("intervals/intervals.jl")
export Interval, interval, ±, @I_str,
export BareInterval, bareinterval, Interval, interval, decoration, @I_str,
diam, radius, mid, midradius, scaled_mid, mag, mig, hull,
emptyinterval, isempty_interval,
isequal_interval,
in_interval,
issubset_interval, isstrictsubset_interval,
precedes, strictprecedes,
isweakless, isstrictless,
contains_zero,
isthinzero, isthin,
isbounded, isunbounded,
isdisjoint_interval, intersect_interval, setdiff_interval,
Expand All @@ -54,21 +51,14 @@ export Interval, interval, ±, @I_str,
RoundTiesToEven, RoundTiesToAway,
IntervalRounding,
cancelminus, cancelplus,
pow, extended_div, nthroot,
fastpow, extended_div, nthroot, nthpow,
bisect,
overlap, Overlap

include("bisect.jl")
export bisect

include("decorations/decorations.jl")
export decoration, DecoratedInterval, com, dac, def, trv, ill

include("rand.jl")

include("parsing.jl")

include("display.jl")
export setformat
export setdisplay

include("symbols.jl")

Expand Down
24 changes: 0 additions & 24 deletions src/bisect.jl

This file was deleted.

13 changes: 0 additions & 13 deletions src/decorations/decorations.jl

This file was deleted.

Loading
Loading