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
Numeric
type that wraps anotherNumeric
type, but defers its computation, instead providing a floating point (Double
) approximation. For some operations, likesignum
, comparisons, equality checks, toFloat, etc, theDouble
approximation may be used to compute the result, rather than having to compute the exact value.An
FPFilter
can generally be used with anyRing
numeric type (also supportsEuclideanRing
,Field
, andExponential
). However, it should be kept in mind thatFPFilter
knows nothing about the type its wrapping and assumes that, generally, it is more accurate than it is. When anFPFilter
cannot determine an answer to some predicate exactly, it will defer to the wrapped value, so it probably doesn't make sense to wrapInt
s, when anInt
will overflow before aDouble
!Good candidates to wrap in
FPFilter
areBigInt
s,Rational
s, andBigDecimal
s. Note thatAlgebraic
uses anFPFilter
internally and thus nothing is gained by wrapping it. The reasoning behind this is thatFPFilter
s add quite a bit of space requirements, as they may hold onto the entire expression tree (as call-by-name paramters), and, sinceAlgebraic
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
FPFilter
s in hash maps. Getting thehashCode
will always force the evaluation ofvalue
.[1] Burnikel, Funke, Seel. Exact Geometric Computation Using Cascading. SoCG 1998.