Documentation of 'org.spaceroots.mantissa.utilities.Interval' Java class
Interval
org.spaceroots.mantissa.utilities

Class Interval



  • public class Interval
    extends java.lang.Object
    This 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 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 bound
        b - 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 return false), 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 return false), then the hole between the intervals is filled in.

        Parameters:
        i1 - first interval
        i2 - 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
      • intersection

        public static Interval intersection(Interval i1,
                                            Interval i2)
        Intersect two intervals.
        Parameters:
        i1 - first interval
        i2 - second interval
        Returns:
        a new interval which is the intersection of i1 with i2

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.