Packages

sealed abstract class Interval[A] extends Serializable

Interval represents a set of values, usually numbers.

Intervals have upper and lower bounds. Each bound can be one of four kinds:

* Closed: The boundary value is included in the interval. * Open: The boundary value is excluded from the interval. * Unbound: There is no boundary value. * Empty: The interval itself is empty.

When the underlying type of the interval supports it, intervals may be used in arithmetic. There are several possible interpretations of interval arithmetic: the interval can represent uncertainty about a single value (for instance, a quantity +/- tolerance in engineering) or it can represent all values in the interval simultaneously. In this implementation we have chosen to use the probabillistic interpretation.

One common pitfall with interval arithmetic is that many familiar algebraic relations do not hold. For instance, given two intervals a and b:

a == b does not imply a * a == a * b

Consider a = b = [-1, 1]. Since any number times itself is non-negative, a * a = [0, 1]. However, a * b = [-1, 1], since we may actually have a=1 and b=-1.

These situations will result in loss of precision (in the form of wider intervals). The result is not wrong per se, but less acccurate than it could be.

These intervals should not be used with floating point bounds, as proper rounding is not implemented. Generally, the JVM is not an easy platform to perform robust arithmetic, as the IEEE 754 rounding modes cannot be set.

Self Type
Interval[A]
Linear Supertypes
Serializable, Serializable, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Interval
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def lowerBound: Bound[A]
  2. abstract def upperBound: Bound[A]

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def &(rhs: Interval[A]): Interval[A]
  4. def *(rhs: A)(implicit ev: Semiring[A]): Interval[A]
  5. def *(rhs: Interval[A])(implicit ev: Semiring[A]): Interval[A]
  6. def +(rhs: A)(implicit ev: AdditiveSemigroup[A]): Interval[A]
  7. def +(rhs: Interval[A])(implicit ev: AdditiveSemigroup[A]): Interval[A]
  8. def -(rhs: A)(implicit ev: AdditiveGroup[A]): Interval[A]
  9. def -(rhs: Interval[A])(implicit ev: AdditiveGroup[A]): Interval[A]
  10. def --(rhs: Interval[A]): List[Interval[A]]
  11. def /(rhs: A)(implicit ev: Field[A]): Interval[A]
  12. def /(rhs: Interval[A])(implicit ev: Field[A]): Interval[A]
  13. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  14. def \(rhs: Interval[A]): List[Interval[A]]
  15. def abs(implicit m: AdditiveGroup[A]): Interval[A]
  16. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  17. def bottom(epsilon: A)(implicit r: AdditiveGroup[A]): Option[A]
  18. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. def combine(rhs: Interval[A])(f: (A, A) ⇒ A): Interval[A]
  20. def contains(t: A): Boolean
  21. def crosses(t: A): Boolean
  22. def crossesZero(implicit ev: AdditiveMonoid[A]): Boolean
  23. def dist(min: A, max: A, epsilon: A)(implicit u: Uniform[A], r: AdditiveGroup[A]): Dist[A]
  24. def doesNotContain(t: A): Boolean
  25. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  26. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  27. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  28. def fold[B](f: (Bound[A], Bound[A]) ⇒ B): B
  29. def foldOver[B](init: B, step: A)(f: (B, A) ⇒ B)(implicit ev: AdditiveMonoid[A], nt: NumberTag[A]): B
  30. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  31. def hasAbove(t: A): Boolean
  32. def hasAtOrAbove(t: A): Boolean
  33. def hasAtOrBelow(t: A): Boolean
  34. def hasBelow(t: A): Boolean
  35. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  36. def intersect(rhs: Interval[A]): Interval[A]
  37. def intersects(rhs: Interval[A]): Boolean
  38. def isAt(t: A): Boolean
  39. def isBounded: Boolean
  40. final def isClosed(flags: Int): Boolean
    Attributes
    protected[this]
    Annotations
    @inline()
  41. final def isClosedLower(flags: Int): Boolean
    Attributes
    protected[this]
    Annotations
    @inline()
  42. final def isClosedUpper(flags: Int): Boolean
    Attributes
    protected[this]
    Annotations
    @inline()
  43. def isEmpty: Boolean
  44. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  45. final def isOpen(flags: Int): Boolean
    Attributes
    protected[this]
    Annotations
    @inline()
  46. final def isOpenLower(flags: Int): Boolean
    Attributes
    protected[this]
    Annotations
    @inline()
  47. final def isOpenUpper(flags: Int): Boolean
    Attributes
    protected[this]
    Annotations
    @inline()
  48. def isPoint: Boolean
  49. def isProperSubsetOf(rhs: Interval[A]): Boolean
  50. def isProperSupersetOf(rhs: Interval[A]): Boolean
  51. def isSubsetOf(rhs: Interval[A]): Boolean
  52. def isSupersetOf(rhs: Interval[A]): Boolean
  53. def iterator(step: A)(implicit ev: AdditiveMonoid[A], nt: NumberTag[A]): Iterator[A]

    Build an Iterator[A] from an Interval[A] and a (step: A) parameter.

    Build an Iterator[A] from an Interval[A] and a (step: A) parameter.

    A positive 'step' means we are proceeding from the lower bound up, and a negative 'step' means we are proceeding from the upper bound down. In each case, the interval must be bounded on the side we are starting with (though it may be unbound on the opposite side). A zero 'step' is not allowed.

    The step is repeatedly added to the starting parameter as long as the sum remains within the interval. This means that arithmetic error can accumulate (e.g. with doubles). However, this method does overflow checking to ensure that Intervals parameterized on integer types will behave correctly.

    Users who want to avoid using arithmetic error should consider starting with an Interval[Rational], calling iterator with the exact step desired, then mapping to the original type (e.g. Double). For example:

    val ns = Interval.closed(Rational(0), Rational(5)) val it = ns.iterator(Rational(1, 7)).map(_.toDouble)

    This method provides some of the same functionality as Scala's NumericRange class.

  54. def loop(step: A)(f: (A) ⇒ Unit)(implicit ev: AdditiveMonoid[A], nt: NumberTag[A]): Unit
  55. final def lowerFlag(flags: Int): Int
    Attributes
    protected[this]
    Annotations
    @inline()
  56. final def lowerFlagToUpper(flags: Int): Int
    Attributes
    protected[this]
  57. def lowerPairBelow(lower1: A, flags1: Int, lower2: A, flags2: Int): Boolean
    Attributes
    protected[this]
  58. def mapAroundZero[B](f: (Interval[A]) ⇒ B)(implicit ev: AdditiveMonoid[A]): (B, B)
  59. def mapBounds[B](f: (A) ⇒ B)(implicit arg0: Order[B]): Interval[B]
  60. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  61. def nonEmpty: Boolean
  62. final def notify(): Unit
    Definition Classes
    AnyRef
  63. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  64. def nroot(k: Int)(implicit r: Ring[A], n: NRoot[A]): Interval[A]
  65. def overlap(rhs: Interval[A]): Overlap[A]

    Result of overlapping this interval with another one.

    Result of overlapping this interval with another one. Can be one of the following: - Equal if intervals are equal - Disjoint if intervals are notEmpty don't intersect - PartialOverlap if intervals intersect and neither is a subset of another - Subset if one interval (possibly empty) is a subset of another

    Except for Equal, both original intervals are bound to respective result fields, allowing to determine exact overlap type.

    For example (pseudo-code): { val a = [5, 6] val b = (0, 1)

    // this returns Disjoint(b, a). Note a and b placement here, it means that b is strictly less then a. a.overlap(b) }

  66. def pow(k: Int)(implicit r: Ring[A]): Interval[A]
  67. def reciprocal(implicit ev: Field[A]): Interval[A]
  68. final def reverseFlags(flags: Int): Int
    Attributes
    protected[this]
    Annotations
    @inline()
  69. final def reverseLowerFlag(flags: Int): Int
    Attributes
    protected[this]
    Annotations
    @inline()
  70. final def reverseUpperFlag(flags: Int): Int
    Attributes
    protected[this]
    Annotations
    @inline()
  71. def split(t: A): (Interval[A], Interval[A])
  72. def splitAtZero(implicit ev: AdditiveMonoid[A]): (Interval[A], Interval[A])
  73. def sqrt(implicit r: Ring[A], n: NRoot[A]): Interval[A]
  74. final def swapFlags(flags: Int): Int
    Attributes
    protected[this]
    Annotations
    @inline()
  75. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  76. def toString(): String
    Definition Classes
    Interval → AnyRef → Any
  77. def top(epsilon: A)(implicit r: AdditiveGroup[A]): Option[A]
  78. def translate(p: Polynomial[A])(implicit ev: Field[A]): Interval[A]

    Apply the given polynomial to the interval.

    Apply the given polynomial to the interval.

    For every point contained in the interval, this method maps that point through the given polynomial. The resulting interval is the set of all the translated points. I.e.

    result = { p(x) | x ∈ interval }

  79. def unary_-()(implicit ev: AdditiveGroup[A]): Interval[A]
  80. def unary_~(): List[Interval[A]]
  81. def union(rhs: Interval[A]): Interval[A]
  82. final def upperFlag(flags: Int): Int
    Attributes
    protected[this]
    Annotations
    @inline()
  83. final def upperFlagToLower(flags: Int): Int
    Attributes
    protected[this]
  84. def upperPairAbove(upper1: A, flags1: Int, upper2: A, flags2: Int): Boolean
    Attributes
    protected[this]
  85. def vmax(rhs: Interval[A])(implicit m: AdditiveMonoid[A]): Interval[A]
  86. def vmin(rhs: Interval[A])(implicit m: AdditiveMonoid[A]): Interval[A]
  87. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  88. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  89. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  90. def |(rhs: Interval[A]): Interval[A]
  91. def ∈:(a: A): Boolean
  92. def ∉:(a: A): Boolean
  93. def (rhs: A): Boolean
  94. def (rhs: A): Boolean
  95. def (rhs: Interval[A]): Interval[A]
  96. def (rhs: Interval[A]): Interval[A]
  97. def (rhs: Interval[A]): Boolean
  98. def (rhs: Interval[A]): Boolean
  99. def (rhs: Interval[A]): Boolean
  100. def (rhs: Interval[A]): Boolean

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped