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: AnyRef): Boolean

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

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

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

    Annotations
    @macroImpl( ... )
  5. def +(rhs: FpFilter[A])(implicit ev: Semiring[A]): FpFilter[A]

    Annotations
    @macroImpl( ... )
  6. def -(rhs: FpFilter[A])(implicit ev: Rng[A]): FpFilter[A]

    Annotations
    @macroImpl( ... )
  7. def /(rhs: FpFilter[A])(implicit ev: Field[A]): FpFilter[A]

    Annotations
    @macroImpl( ... )
  8. def <(rhs: FpFilter[A])(implicit ev0: Signed[A], ev1: Rng[A]): Boolean

    Annotations
    @macroImpl( ... )
  9. def <=(rhs: FpFilter[A])(implicit ev0: Signed[A], ev1: Rng[A]): Boolean

    Annotations
    @macroImpl( ... )
  10. final def ==(arg0: AnyRef): Boolean

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

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

    Annotations
    @macroImpl( ... )
  13. def >(rhs: FpFilter[A])(implicit ev0: Signed[A], ev1: Rng[A]): Boolean

    Annotations
    @macroImpl( ... )
  14. def >=(rhs: FpFilter[A])(implicit ev0: Signed[A], ev1: Rng[A]): Boolean

    Annotations
    @macroImpl( ... )
  15. def abs(implicit ev: Signed[A]): FpFilter[A]

    Annotations
    @macroImpl( ... )
  16. val apx: Double

  17. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  18. def clone(): AnyRef

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

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

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

  22. lazy val exact: A

  23. def finalize(): Unit

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

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

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

  27. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  28. val mes: Double

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

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

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

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

    Annotations
    @macroImpl( ... )
  33. def sqrt(implicit ev: NRoot[A]): FpFilter[A]

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

    Definition Classes
    AnyRef
  35. def toString(): String

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

    Annotations
    @macroImpl( ... )
  37. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped