spire.math.fpf

FastMaybeFloat

object FastMaybeFloat

A Long encoded version of MaybeDouble, geared for unboxed speed. This is significantly less accurate, but may provide good speed gains in common cases.

The values approx and measure are both truncated floats with the full 8 bit exponent, but only 16 bit mantissa. Since the measure is always positive, we only need 2 * (16 + 8) + 1 = 49 bits for these 2 numbers, which leaves 15 bits for the index. These sizes were chosen so that worst case relative error, ind * eps, has a value less than 1. In our case, with worst case ind = -1 >>> 17, we have ind * eps =~ 0.5.

This was inspired by Erik Osheim's awesome FastComplex, which encodes the imaginary and real parts as 2 Floats in the a single Long.

TODO: Perhaps, if we've only used + or *, we could store a higher precision float instead, since we don't need measure. Use 1 bit to handle the switching, taken from the index.

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

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. final def ==(arg0: AnyRef): Boolean

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

    Definition Classes
    Any
  6. final val Invalid: Long(-1L)

  7. def apply(x: Rational): Long

  8. def apply(x: BigDecimal): Long

  9. def apply(x: BigInt): Long

  10. def apply(x: Long): Long

  11. def apply(x: Int): Long

  12. def apply(x: Double): Long

  13. def apply(x: Float): Long

  14. final def approx(mf: Long): Float

  15. def asFloat(x: Long): Float

    Annotations
    @inline()
  16. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  17. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  18. final def div(a: Long, b: Long): Long

  19. final val eps: Float

  20. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  21. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  22. final def error(mf: Long): Float

  23. def finalize(): Unit

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

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

    Definition Classes
    AnyRef → Any
  26. final def index(mf: Long): Int

    Annotations
    @inline()
  27. def invalid(a: Long): Boolean

    Annotations
    @inline()
  28. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  29. def max(a: Int, b: Int): Int

    Annotations
    @inline()
  30. final def measure(mf: Long): Float

    Annotations
    @inline()
  31. def min(a: Int, b: Int): Int

    Annotations
    @inline()
  32. final def minus(a: Long, b: Long): Long

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

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

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

    Definition Classes
    AnyRef
  36. def nroot(a: Long, n: Int): Long

  37. final def plus(a: Long, b: Long): Long

  38. def pow(a: Long, k: Int): Long

  39. def sqrt(a: Long): Long

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

    Definition Classes
    AnyRef
  41. final def times(a: Long, b: Long): Long

  42. def toString(): String

    Definition Classes
    AnyRef → Any
  43. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any

Ungrouped