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

Safe HaskellSafe
LanguageHaskell2010

Data.Order.Float

Contents

Synopsis

Documentation

open :: Float -> Float -> Interval Float Source #

Construnct an open interval.

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

openl :: Float -> Float -> Interval Float Source #

Construnct a half-open interval.

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

openr :: Float -> Float -> Interval Float Source #

Construnct a half-open interval.

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

covers :: Float -> Float -> Bool Source #

Covering relation on the N5 lattice of floats.

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

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

indexFromTo :: Interval Float -> [Float] Source #

Generate a list of the contents on an interval.

Returns the list of values in the interval defined by a bounding pair.

Lawful variant of enumFromTo.

ulp :: Float -> Float -> Maybe (Ordering, Word32) Source #

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

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

shift :: Int32 -> Float -> Float Source #

Shift a float 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 :: Word32 -> Float -> Float -> Bool Source #

Compare two 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/.

lower32 :: Preorder a => Float -> (Float -> a) -> a -> Float Source #

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

upper32 :: Preorder a => Float -> (Float -> a) -> a -> Float Source #

upper32 y is the greatest element x in the ascending chain such that not $ g x >~ y.

minimal :: Float Source #

Minimal positive value.

>>> minimal
1.0e-45
>>> shift (-1) minimal
0

maximal :: Float Source #

Maximum finite value.

>>> maximal
3.4028235e38
>>> shift 1 maximal
Infinity
>>> shift (-1) $ negate maximal
-Infinity

epsilon :: Float Source #

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

epsilon = shift 1 1 - 1
>>> epsilon
1.1920929e-7

Orphan instances

Universe Float Source # 
Instance details

Methods

universe :: [Float] #

Finite Float Source # 
Instance details