Portability | GHC only |
---|---|

Stability | experimental |

Maintainer | ekmett@gmail.com |

Safe Haskell | Safe-Infered |

Interval arithmetic

- data Interval a = I !a !a
- (...) :: a -> a -> Interval a
- whole :: Fractional a => Interval a
- empty :: Fractional a => Interval a
- null :: Ord a => Interval a -> Bool
- singleton :: a -> Interval a
- elem :: Ord a => a -> Interval a -> Bool
- notElem :: Ord a => a -> Interval a -> Bool
- inf :: Interval a -> a
- sup :: Interval a -> a
- singular :: Ord a => Interval a -> Bool
- width :: Num a => Interval a -> a
- intersection :: (Fractional a, Ord a) => Interval a -> Interval a -> Interval a
- hull :: Ord a => Interval a -> Interval a -> Interval a
- bisection :: Fractional a => Interval a -> (Interval a, Interval a)
- magnitude :: (Num a, Ord a) => Interval a -> a
- mignitude :: (Num a, Ord a) => Interval a -> a
- contains :: Ord a => Interval a -> Interval a -> Bool
- isSubsetOf :: Ord a => Interval a -> Interval a -> Bool
- certainly :: Ord a => (forall b. Ord b => b -> b -> Bool) -> Interval a -> Interval a -> Bool
- (<!) :: Ord a => Interval a -> Interval a -> Bool
- (<=!) :: Ord a => Interval a -> Interval a -> Bool
- (==!) :: Eq a => Interval a -> Interval a -> Bool
- (>=!) :: Ord a => Interval a -> Interval a -> Bool
- (>!) :: Ord a => Interval a -> Interval a -> Bool
- possibly :: Ord a => (forall b. Ord b => b -> b -> Bool) -> Interval a -> Interval a -> Bool
- (<?) :: Ord a => Interval a -> Interval a -> Bool
- (<=?) :: Ord a => Interval a -> Interval a -> Bool
- (==?) :: Ord a => Interval a -> Interval a -> Bool
- (>=?) :: Ord a => Interval a -> Interval a -> Bool
- (>?) :: Ord a => Interval a -> Interval a -> Bool
- idouble :: Interval Double -> Interval Double
- ifloat :: Interval Float -> Interval Float

# Documentation

I !a !a |

Eq a => Eq (Interval a) | |

(RealExtras a, Ord a) => Floating (Interval a) | |

(Fractional a, Ord a) => Fractional (Interval a) | |

(Num a, Ord a) => Num (Interval a) | |

Ord a => Ord (Interval a) | |

Real a => Real (Interval a) | This means that realToFrac will use the midpoint What moron put an Ord instance requirement on Real! |

RealExtras a => RealFloat (Interval a) | We have to play some semantic games to make these methods make sense. Most compute with the midpoint of the interval. |

RealFloat a => RealFrac (Interval a) | |

Show a => Show (Interval a) | |

RealExtras a => RealExtras (Interval a) |

(...) :: a -> a -> Interval aSource

The rule of thumb is you should only use this to construct using values that you took out of the interval. Otherwise, use I, to force rounding

whole :: Fractional a => Interval aSource

The whole real number line

empty :: Fractional a => Interval aSource

An empty interval

singular :: Ord a => Interval a -> BoolSource

Is the interval a singleton point? N.B. This is fairly fragile and likely will not hold after even a few operations that only involve singletons

intersection :: (Fractional a, Ord a) => Interval a -> Interval a -> Interval aSource

Calculate the intersection of two intervals.

hull :: Ord a => Interval a -> Interval a -> Interval aSource

Calculate the convex hull of two intervals

bisection :: Fractional a => Interval a -> (Interval a, Interval a)Source

Bisect an interval at its midpoint.

certainly :: Ord a => (forall b. Ord b => b -> b -> Bool) -> Interval a -> Interval a -> BoolSource

For all `x`

in `X`

, `y`

in `Y`

. `x `

`op`

y

possibly :: Ord a => (forall b. Ord b => b -> b -> Bool) -> Interval a -> Interval a -> BoolSource

Does there exist an `x`

in `X`

, `y`

in `Y`

such that `x `

?
`op`

y

(<?) :: Ord a => Interval a -> Interval a -> BoolSource

Does there exist an `x`

in `X`

, `y`

in `Y`

such that `x `

?
`<`

y

(<=?) :: Ord a => Interval a -> Interval a -> BoolSource

Does there exist an `x`

in `X`

, `y`

in `Y`

such that `x `

?
`<=`

y

(==?) :: Ord a => Interval a -> Interval a -> BoolSource

Does there exist an `x`

in `X`

, `y`

in `Y`

such that `x `

?
`==`

y

(>=?) :: Ord a => Interval a -> Interval a -> BoolSource

Does there exist an `x`

in `X`

, `y`

in `Y`

such that `x `

?
`>=`

y