Class Interval
- java.lang.Object
-
- org.spaceroots.mantissa.utilities.Interval
-
public class Interval extends java.lang.ObjectThis class represents an interval on the real line.This class allows to perform simple interval operations like point inclusion tests and intersection operations.
There is no distinction between open and closed intervals because real numbers cannot be represented exactly.
- See Also:
IntervalsList
-
-
Constructor Summary
Constructors Constructor and Description Interval()Build the [0, 0] interval.Interval(double a, double b)Build an interval with the given bounds.Interval(Interval i)Copy-constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static Intervaladd(Interval i1, Interval i2)Add two intervals.voidaddToSelf(Interval i)Add an interval to the instance.booleancontains(double x)Check if the interval contains a point.booleancontains(Interval i)Check if the interval contains another interval.doublegetInf()Get the lower bound of the interval.doublegetLength()Get the length of the interval.doublegetSup()Get the upper bound of the interval.static Intervalintersection(Interval i1, Interval i2)Intersect two intervals.booleanintersects(Interval i)Check if an interval intersects the instance.voidintersectSelf(Interval i)Intersects the instance with an interval.
-
-
-
Constructor Detail
-
Interval
public Interval()
Build the [0, 0] interval.
-
Interval
public Interval(double a, double b)Build an interval with the given bounds.The given bounds do not need to be ordered, they will be reordered by the constructor.
- Parameters:
a- first boundb- second bound
-
Interval
public Interval(Interval i)
Copy-constructor.- Parameters:
i- interval to copy
-
-
Method Detail
-
getInf
public double getInf()
Get the lower bound of the interval.- Returns:
- lower bound of the interval
-
getSup
public double getSup()
Get the upper bound of the interval.- Returns:
- upper bound of the interval
-
getLength
public double getLength()
Get the length of the interval.- Returns:
- length of the interval
-
contains
public boolean contains(double x)
Check if the interval contains a point.- Parameters:
x- point to check- Returns:
- true if the interval contains x
-
contains
public boolean contains(Interval i)
Check if the interval contains another interval.- Parameters:
i- interval to check- Returns:
- true if i is completely included in the instance
-
intersects
public boolean intersects(Interval i)
Check if an interval intersects the instance.- Parameters:
i- interval to check- Returns:
- true if i intersects the instance
-
addToSelf
public void addToSelf(Interval i)
Add an interval to the instance.This method expands the instance.
This operation is not a union operation. If the instance and the interval are disjoints (i.e. if
intersects(i)would returnfalse), then the hole between the intervals is filled in.- Parameters:
i- interval to add to the instance
-
add
public static Interval add(Interval i1, Interval i2)
Add two intervals.This operation is not a union operation. If the intervals are disjoints (i.e. if
i1.intersects(i2)would returnfalse), then the hole between the intervals is filled in.- Parameters:
i1- first intervali2- second interval- Returns:
- a new interval
-
intersectSelf
public void intersectSelf(Interval i)
Intersects the instance with an interval.This method reduces the instance, it could even become empty if the interval does not intersects the instance.
- Parameters:
i- interval with which the instance should be intersected
-
-
DataMelt 3.0 © DataMelt by jWork.ORG