connections-0.1.0: Orders, Galois connections, and lattices.

Safe HaskellSafe
LanguageHaskell2010

Data.Order.Double

Contents

Synopsis

Documentation

open :: Double -> Double -> Interval Double Source #

Construnct an open interval.

>>> contains 1 $ open 1 2
False
>>> contains 2 $ open 1 2
False

openl :: Double -> Double -> Interval Double Source #

Construnct a half-open interval.

>>> contains 1 $ openl 1 2
False
>>> contains 2 $ openl 1 2
True

openr :: Double -> Double -> Interval Double Source #

Construnct a half-open interval.

>>> contains 1 $ openr 1 2
True
>>> contains 2 $ openr 1 2
False

covers :: Double -> Double -> Bool Source #

Covering relation on the N5 lattice of doubles.

https://en.wikipedia.org/wiki/Covering_relation

>>> covers 1 (shift 1 1)
True
>>> covers 1 (shift 2 1)
False

ulp :: Double -> Double -> Maybe (Ordering, Word64) Source #

Compute the signed distance between two doubles in units of least precision.

>>> ulp 1.0 (shift 1 1.0)
Just (LT,1)
>>> ulp (0.0/0.0) 1.0
Nothing

shift :: Int64 -> Double -> Double Source #

Shift by n units of least precision.

>>> shift 1 0
1.0e-45
>>> shift 1 $ 0/0
NaN
>>> shift (-1) $ 0/0
NaN
>>> shift 1 $ 1/0
Infinity

within :: Word64 -> Double -> Double -> Bool Source #

Compare two double-precision floats for approximate equality.

Required accuracy is specified in units of least precision.

See also https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/.

lower64 :: Preorder a => Double -> (Double -> a) -> a -> Double Source #

lower64 x is the least element y in the descending chain such that not $ f y <~ x.

upper64 :: Preorder a => Double -> (Double -> a) -> a -> Double Source #

upper64 y is the greatest element x in the ascending chain such that g x <~ y.

minimal :: Double Source #

Minimal positive value.

>>> minimal
5.0e-324
>>> shift (-1) minimal
0

maximal :: Double Source #

Maximum finite value.

>>> maximal
1.7976931348623157e308
>>> shift 1 maximal
Infinity
>>> shift (-1) $ negate maximal
-Infinity

epsilon :: Double Source #

Difference between 1 and the smallest representable value greater than 1.

epsilon = shift 1 1 - 1
>>> epsilon
2.220446049250313e-16

Orphan instances

Universe Double Source # 
Instance details

Methods

universe :: [Double] #

Finite Double Source # 
Instance details