Interval class

An Interval is defined by its minimum and maximum values, where min <= max.

This implementation offers basic interval arithmetic operations like addition, subtraction, multiplication and division. Operations always return a new interval and will not modify the existing ones. Additionally this class implementions comparison relations for intervals.

This implementation (partly) supports unbounded intervals with borders at +/- infinity and empty sets.

Operator and comparison definitions are based on: Bohlender, Gerd, and Ulrich Kulisch. 2010. "Definition of the Arithmetic Operations and Comparison Relations for an Interval Arithmetic Standard" (https://interval.louisiana.edu/reliable-computing-journal/volume-15/no-1/reliable-computing-15-pp-36-42.pdf). Reliable Computing 15 (1): 36–42.

Note: This implementation does not offer a complete set of operations yet:

  • No handling of unbounded intervals in operators.
  • No proper rounding.
Implemented types

Constructors

Interval(num min, num max)
Creates a new interval with given borders.
Interval.empty()
Returns an immutable empty set.
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
max num
Interval bounds.
getter/setter pair
min num
Interval bounds.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

compareTo(Interval other) int
Compares this object to another object.
override
contains(num element) bool
Element-of relation. Returns true, if given element is included in this interval. Defined on a real number i and an interval:
containsZero() bool
Returns true, if this interval contains zero (min <= 0 <= max).
glb(Interval i) Interval
Returns the greatest lower bound.
includes(Interval i) bool
Inclusion relation. Returns true, if the given interval is included in this interval.
isBound() bool
Returns true, if neither min or max values are infinite.
isEmpty() bool
Returns true, if this is the empty set.
isPositive() bool
Returns true, if this interval is positive (min >= 0)
length() num
Returns the length of this interval.
lub(Interval i) Interval
Returns the least upper bound.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator *(Interval i) Interval
Performs an interval multiplication.
operator +(Interval i) Interval
Performs an interval addition.
operator -(Interval i) Interval
Performs an interval subtraction.
operator /(Interval i) Interval
Performs an interval division.
operator <(Interval i) bool
Less than operator on intervals.
operator <=(Interval i) bool
Less or equal than operator on intervals.
operator ==(Object i) bool
Equals operator on intervals.
override
operator >(Interval i) bool
Greater than operator on intervals.
operator >=(Interval i) bool
Greater or equal than operator on intervals.
operator unary-() Interval
Unary minus on intervals.