spire.math

FpFilter

final class FpFilter[A] extends AnyRef

A Floating-point Filter [1] provides a Numeric type that wraps another Numeric type, but defers its computation, instead providing a floating point (Double) approximation. For some operations, like signum, comparisons, equality checks, toFloat, etc, the Double approximation may be used to compute the result, rather than having to compute the exact value.

An FpFilter can generally be used with any Ring numeric type (also supports EuclideanRing, Field, and NRoot). However, it should be kept in mind that FpFilter knows nothing about the type its wrapping and assumes that, generally, it is more accurate than it is. When an FpFilter cannot determine an answer to some predicate exactly, it will defer to the wrapped value, so it probably doesn't make sense to wrap Ints, when an Int will overflow before a Double!

Good candidates to wrap in FpFilter are BigInts, Rationals, BigDecimals, and Algebraic. Note that while Algebraic has an internal floating-point filter, this still provides benefits. Namely, the operator-fusion and allocation removal provided by the macros can make for much faster hot paths.

Note: Both equals and hashCode will generally force the exact computation. They should be avoided (prefer === for equals)... otherwise why use bother?

[1] Burnikel, Funke, Seel. Exact Geometric Computation Using Cascading. SoCG 1998.

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

Instance Constructors

  1. new FpFilter(apx: Double, mes: Double, ind: Int, exact0: ⇒ A)

Value Members

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

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. macro def *(rhs: FpFilter[A])(implicit ev: Semiring[A]): FpFilter[A]

  4. macro def +(rhs: FpFilter[A])(implicit ev: Semiring[A]): FpFilter[A]

  5. macro def -(rhs: FpFilter[A])(implicit ev: Rng[A]): FpFilter[A]

  6. macro def /(rhs: FpFilter[A])(implicit ev: Field[A]): FpFilter[A]

  7. macro def <(rhs: FpFilter[A])(implicit ev0: Signed[A], ev1: Rng[A]): Boolean

  8. macro def <=(rhs: FpFilter[A])(implicit ev0: Signed[A], ev1: Rng[A]): Boolean

  9. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. macro def ===(rhs: FpFilter[A])(implicit ev0: Signed[A], ev1: Rng[A]): Boolean

  11. macro def >(rhs: FpFilter[A])(implicit ev0: Signed[A], ev1: Rng[A]): Boolean

  12. macro def >=(rhs: FpFilter[A])(implicit ev0: Signed[A], ev1: Rng[A]): Boolean

  13. macro def abs(implicit ev: Signed[A]): FpFilter[A]

  14. val apx: Double

  15. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  16. def clone(): AnyRef

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

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

    Definition Classes
    FpFilter → AnyRef → Any
  19. def error: Double

  20. lazy val exact: A

  21. def finalize(): Unit

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

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

    Definition Classes
    FpFilter → AnyRef → Any
  24. val ind: Int

  25. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  26. val mes: Double

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

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

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

    Definition Classes
    AnyRef
  30. macro def signum(implicit ev: Signed[A]): Int

  31. macro def sqrt(implicit ev: NRoot[A]): FpFilter[A]

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

    Definition Classes
    AnyRef
  33. def toString(): String

    Definition Classes
    AnyRef → Any
  34. macro def unary_-(implicit ev: Rng[A]): FpFilter[A]

  35. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped