Package edu.jas.root

Class Interval<C extends RingElem<C> & Rational>

java.lang.Object
edu.jas.root.Interval<C>
Type Parameters:
C - coefficient type.
All Implemented Interfaces:
Serializable

public class Interval<C extends RingElem<C> & Rational> extends Object implements Serializable
Interval. For example isolating interval for real roots.
See Also:
  • Field Details

  • Constructor Details

    • Interval

      public Interval(C left, C right)
      Constructor.
      Parameters:
      left - interval border.
      right - interval border.
    • Interval

      public Interval(C mid)
      Constructor.
      Parameters:
      mid - left and right interval border.
  • Method Details

    • toString

      public String toString()
      String representation of Interval.
      Overrides:
      toString in class Object
      See Also:
    • toScript

      public String toScript()
      Get a scripting compatible string representation.
      Returns:
      script compatible representation for this Interval.
    • copy

      public Interval<C> copy()
      Copy this.
      Returns:
      a copy of this.
    • equals

      public boolean equals(Object b)
      Comparison with any other object.
      Overrides:
      equals in class Object
      See Also:
    • hashCode

      public int hashCode()
      Hash code for this Interval.
      Overrides:
      hashCode in class Object
      See Also:
    • contains

      public boolean contains(C c)
      Test if an element is contained in this interval.
      Parameters:
      c - element to test.
      Returns:
      true, if left ≤ b ≤ right;
    • contains

      public boolean contains(Interval<C> vc)
      Test if an interval is contained in this interval.
      Parameters:
      vc - interval to test.
      Returns:
      true, if left ≤ vc.left and vc.right ≤ right;
    • length

      public C length()
      Length.
      Returns:
      |left-right|;
    • rationalLength

      public BigRational rationalLength()
      BigRational Length.
      Returns:
      |left-right|;
    • toDecimal

      public BigDecimal toDecimal()
      BigDecimal representation of Interval.
    • rationalMiddle

      public BigRational rationalMiddle()
      Rational middle point.
      Returns:
      (left+right)/2;
    • middle

      public C middle()
      Middle point.
      Returns:
      (left+right)/2;
    • randomPoint

      public C randomPoint()
      Random point of interval.
      Returns:
      a random point contained in this interval.
    • sum

      public Interval<C> sum(Interval<C> o)
      Sum of intervals.
      Parameters:
      o - other interval.
      Returns:
      this+other
    • subtract

      public Interval<C> subtract(Interval<C> o)
      Subtract intervals.
      Parameters:
      o - other interval.
      Returns:
      this-other
    • multiply

      public Interval<C> multiply(Interval<C> o)
      Multiply intervals.
      Parameters:
      o - other interval.
      Returns:
      this*other