spire.math.fpf

MaybeDouble

final class MaybeDouble extends AnyRef

A MaybeDouble will hold a Double approximation so long as the Double's sign can be computed exactly. It is not a general number type, but is meant to be used in tandem with a more accurate, but slow (computationally), number type. When performing comparisons then, this can be checked first to save on potentially slow computation.

For this type, if a method returns an Optional value, then that indicates that if None is returned, the answer cannot be computed exactly, but if Some(x) is returned, then that is guaranteed to be correct. For example, toLong, toFloat, sign, isWhole, etc. return these types of optional, only-if-correct, type values.

Most likely you would not use this directly, but just wrap your number type in a FPFilter which maintains a MaybeDouble and handles all the lazy computation of the more accurate number type for you.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. MaybeDouble
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MaybeDouble(approx: Double, mes: Double, ind: Int)

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def *(that: MaybeDouble): MaybeDouble

  5. def +(that: MaybeDouble): MaybeDouble

  6. def -(that: MaybeDouble): MaybeDouble

  7. def /(that: MaybeDouble): MaybeDouble

  8. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  10. def abs: MaybeDouble

  11. val approx: Double

  12. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  13. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  14. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. def equals(that: Any): Boolean

    Definition Classes
    MaybeDouble → AnyRef → Any
  16. lazy val error: Double

  17. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  18. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  19. def hashCode(): Int

    Definition Classes
    MaybeDouble → AnyRef → Any
  20. def isExact: Boolean

    Returns true if this MaybeDouble is both valid and exact (has an error of 0.

    Returns true if this MaybeDouble is both valid and exact (has an error of 0.0).

  21. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  22. def isValid: Boolean

    Sometimes a number is too large to fit in a Double, the result of an operation cannot be computed (eg.

    Sometimes a number is too large to fit in a Double, the result of an operation cannot be computed (eg. sqrt of a negative number), other times we just give up when trying to keep track of the error... In any case, the approx is set to either NaN or an Infinity, and it will be marked as invalid. In that case, this will return false otherwise it will return true.

  23. def isWhole: Option[Boolean]

  24. def mod(that: MaybeDouble): MaybeDouble

    This implements the modulus operator.

    This implements the modulus operator. It will behave similar to % for Double, Long, Int, etc.

  25. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  26. final def notify(): Unit

    Definition Classes
    AnyRef
  27. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  28. def nroot(n: Int): MaybeDouble

    FIXME: Implement arbitrary nroots w/ error bounds.

  29. def opt: Option[Double]

    If this MaybeDouble's sign can be computed exactly, then Some(x) is returned where x is the Double approximation.

    If this MaybeDouble's sign can be computed exactly, then Some(x) is returned where x is the Double approximation. Otherwise, None is returned.

  30. def pow(k: Int): MaybeDouble

  31. def quot(that: MaybeDouble): MaybeDouble

    Currently, if this can't be answered exactly, then the result is made invalid.

    Currently, if this can't be answered exactly, then the result is made invalid. This should be fixed. If the answer is exact, then it is returned with a 0 error bound.

  32. val sign: Option[Sign]

    If this MaybeDouble's sign can be computed exactly, then Some(s) is returned, where s is the sign of the number.

    If this MaybeDouble's sign can be computed exactly, then Some(s) is returned, where s is the sign of the number. Otherwise, None is returned.

  33. def sqrt: MaybeDouble

  34. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  35. def toBigInt: Option[BigInt]

  36. def toDouble: Option[Double]

  37. def toFloat: Option[Float]

    Returns Some(f), where f is a Float, if f is known to be exact.

    Returns Some(f), where f is a Float, if f is known to be exact. Otherwise, returns None.

  38. def toInt: Option[Int]

  39. def toLong: Option[Long]

    If this can be converted, exactly, into a Long, then Some(n) will be returned, where n is a Long.

    If this can be converted, exactly, into a Long, then Some(n) will be returned, where n is a Long. Otherwise, None will be returned.

  40. def toString(): String

    Definition Classes
    MaybeDouble → AnyRef → Any
  41. def unary_-(): MaybeDouble

  42. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  43. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  44. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any

Ungrouped