Copyright | Copyright (c) 2010, Patrick Perry <patperry@gmail.com> |
---|---|
License | BSD3 |
Maintainer | Patrick Perry <patperry@gmail.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
A type class for approximate and exact equalilty comparisons and instances for common data types.
Documentation
class Eq a => AEq a where Source
Types with approximate and exact equality comparisons.
Nothing
(===) :: a -> a -> Bool infix 4 Source
An exact equality comparison.
For real IEEE
types, two values are equivalent in the
following cases:
- both values are
+0
; - both values are
-0
; - both values are nonzero and equal to each other
(according to
==
); - both values are
NaN
with the same payload and sign.
For complex IEEE
types, two values are equivalent if their
real and imaginary parts are equivalent.
(~==) :: a -> a -> Bool infix 4 Source
An approximate equality comparison operator.
For real IEEE
types, two values are approximately equal in the
following cases:
- at least half of their significand bits agree;
- both values are less than
epsilon
; - both values are
NaN
.
For complex IEEE
types, two values are approximately equal in the
followiing cases:
- their magnitudes are approximately equal and the angle between
them is less than
32*
;epsilon
- both magnitudes are less than
epsilon
; - both have a
NaN
real or imaginary part.
Admitedly, the 32
is a bit of a hack. Future versions of the
library may switch to a more principled test of the angle.