Skip to content

AnderGray/IntervalUnionArithmetic.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IntervalUnionArithmetic.jl

Build Status codecov

An extension to IntervalArithmetic.jl with interval unions. Interval unions are sets defined by unions of disjoint intervals.

Conversation in PR#452

This package includes constructors, arithmetic (including with intervals and scalars) and complement functions.

Installation

This is a registered julia package:

julia> ]
pkg> add IntervalUnionArithmetic.jl

or the most up to date version:

julia> ]
pkg> add https://github.com/AnderGray/IntervalUnionArithmetic.jl#master

Example

julia> a = interval(0,2)  interval(3,4)
  [0, 2]  [3, 4]

julia> b = interval(1,2)  interval(4,5)  ∅
  [1, 2]  [4, 5]

julia> c = a * b 
  [0, 10]  [12, 20]

Division and sqrt

julia> x = interval(2,5); 
julia> y = interval(-1,1);
julia> x / y                # Standard interval arithmetic
  [-∞, ∞]
  
julia> x1 = intervalUnion(x);   # Convert to interval union
julia> y1 = intervalUnion(y);
julia> x1 / y1              # Does x1 / y1 for y1\{0} if 0 ∈ y1
  [-∞, -2]  [2, ∞]

julia> sqrt(x)
  [1.41421, 2.23607]

julia> sqrt(x1)
  [-2.23607, -1.41421]  [1.41421, 2.23607]

Set operations

julia> a = interval(0,1)  interval(2,3)
  [0, 1]  [2, 3]

julia> b = interval(-1,0.5)  interval(2.5,5)
  [-1, 0.5]  [2.5, 5]

julia> complement(a)         # complement
  [-∞, 0]  [1, 2]  [3, ∞]

julia> a  b                 # Intersect
  [0, 0.5]  [2.5, 3]
  
julia> a \ b                 # Set difference
  [0.5, 1]  [2, 2.5]
  
julia> bisect(a,0.5)         # Cut at a = 0.5
  [0, 0.5]  [0.5, 1]  [2, 3]
  
julia> a  interval(0,3)     # Subset
  true

Bibiography

About

An implementation of interval union arithmetic in Julia

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages