Class/Object

spire.math

FpFilter

Related Docs: object FpFilter | package math

Permalink

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
Visibility
  1. Public
  2. All

Instance Constructors

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

    Permalink

Value Members

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

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

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

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

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

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

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

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

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

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

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

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

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

    Permalink
  14. val apx: Double

    Permalink
  15. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  16. def clone(): AnyRef

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

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

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

    Permalink
  20. lazy val exact: A

    Permalink
  21. def finalize(): Unit

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

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

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

    Permalink
  25. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  26. val mes: Double

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

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
  33. def toString(): String

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

    Permalink
  35. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped