spire.math.fpf

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 Exponential). 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, and BigDecimals. Note that Real uses an FPFilter internally and thus nothing is gained by wrapping it. The reasoning behind this is that FPFilters add quite a bit of space requirements, as they may hold onto the entire expression tree (as call-by-name paramters), and, since Real also does this by design, the asymptotic space requirements remain the same.

Currently, the only way to operate on an FPFilter is by using its various numeric typeclasses.

Note: Don't use FPFilters in hash maps. Getting the hashCode will always force the evaluation of value.

[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(approx: MaybeDouble, x: ⇒ 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. final def ==(arg0: AnyRef): Boolean

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

    Definition Classes
    Any
  6. val approx: MaybeDouble

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

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

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

    Returns true if these values are equal.

    Returns true if these values are equal. Note that this will only return true on a successful comparison of this.value == that.value. However, it may return false based on only the floating point approximations. If you wish to take advantage of the case where this.approx == that.approx exactly, you'll need to use the Eq type class instead.

    Definition Classes
    FPFilter → AnyRef → Any
  11. def finalize(): Unit

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

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

    This will always evalute the underlying value and will lead to serious performance problems if used often.

    This will always evalute the underlying value and will lead to serious performance problems if used often.

    Definition Classes
    FPFilter → AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  18. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  19. def toString(): String

    Definition Classes
    AnyRef → Any
  20. lazy val value: A

  21. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any

Ungrouped