edu.jas.root
Class Interval<C extends RingElem<C> & Rational>

java.lang.Object
  extended by edu.jas.root.Interval<C>
Type Parameters:
C - coefficient type.

public class Interval<C extends RingElem<C> & Rational>
extends java.lang.Object

Interval. For example isolating interval for real roots.

Author:
Heinz Kredel

Field Summary
 C left
          left interval border.
 C right
          right interval border.
 
Constructor Summary
Interval(C mid)
          Constructor.
Interval(C left, C right)
          Constructor.
 
Method Summary
 Interval<C> clone()
          Clone this.
 boolean contains(C c)
          Test if an element is contained in this interval.
 boolean contains(Interval<C> vc)
          Test if an interval is contained in this interval.
 boolean equals(java.lang.Object b)
          Comparison with any other object.
 int hashCode()
          Hash code for this Interval.
 C length()
          Length.
 C randomPoint()
          Random point of interval.
 BigRational rationalLength()
          BigRational Length.
 BigRational rationalMiddle()
          Rational middle point.
 BigDecimal toDecimal()
          BigDecimal representation of Interval.
 java.lang.String toScript()
          Get a scripting compatible string representation.
 java.lang.String toString()
          String representation of Interval.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

left

public final C extends RingElem<C> & Rational left
left interval border.


right

public final C extends RingElem<C> & Rational right
right interval border.

Constructor Detail

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 Detail

toString

public java.lang.String toString()
String representation of Interval.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

toScript

public java.lang.String toScript()
Get a scripting compatible string representation.

Returns:
script compatible representation for this Interval.

clone

public Interval<C> clone()
Clone this.

Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

equals

public boolean equals(java.lang.Object b)
Comparison with any other object.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Hash code for this Interval.

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

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;

randomPoint

public C randomPoint()
Random point of interval.

Returns:
a random point contained in this interval.