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.
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.
A Floating Point Filter [1] provides a
Numerictype that wraps anotherNumerictype, but defers its computation, instead providing a floating point (Double) approximation. For some operations, likesignum, comparisons, equality checks, toFloat, etc, theDoubleapproximation may be used to compute the result, rather than having to compute the exact value.An
FPFiltercan generally be used with anyRingnumeric type (also supportsEuclideanRing,Field, andExponential). However, it should be kept in mind thatFPFilterknows nothing about the type its wrapping and assumes that, generally, it is more accurate than it is. When anFPFiltercannot determine an answer to some predicate exactly, it will defer to the wrapped value, so it probably doesn't make sense to wrapInts, when anIntwill overflow before aDouble!Good candidates to wrap in
FPFilterareBigInts,Rationals, andBigDecimals. Note thatAlgebraicuses anFPFilterinternally and thus nothing is gained by wrapping it. The reasoning behind this is thatFPFilters add quite a bit of space requirements, as they may hold onto the entire expression tree (as call-by-name paramters), and, sinceAlgebraicalso does this by design, the asymptotic space requirements remain the same.Currently, the only way to operate on an
FPFilteris by using its various numeric typeclasses.Note: Don't use
FPFilters in hash maps. Getting thehashCodewill always force the evaluation ofvalue.[1] Burnikel, Funke, Seel. Exact Geometric Computation Using Cascading. SoCG 1998.