intervals-0.2.2.1: Interval Arithmetic

Portability | GHC only
Stability | experimental
Maintainer | ekmett@gmail.com
Safe Haskell | Safe-Inferred

Numeric.Interval

Description

Interval arithmetic

Synopsis

- 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
- midpoint :: Fractional 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

data Interval a Source

Constructors

I !a !a |

Instances

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

null :: Ord a => Interval a -> Bool Source

negation handles NaN properly

singleton :: a -> Interval aSource

A singleton point

elem :: Ord a => a -> Interval a -> Bool Source

notElem :: Ord a => a -> Interval a -> Bool Source

inf :: Interval a -> aSource

The infinumum (lower bound) of an interval

sup :: Interval a -> aSource

The supremum (upper bound) of an interval

singular :: Ord a => Interval a -> Bool Source

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

width :: Num a => Interval a -> aSource

Calculate the width of an interval.

midpoint :: Fractional a => Interval a -> aSource

Nearest point to the midpoint of the interval.

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.

magnitude :: (Num a, Ord a) => Interval a -> aSource

magnitude

mignitude :: (Num a, Ord a) => Interval a -> aSource

mignitude

contains :: Ord a => Interval a -> Interval a -> Bool Source

isSubsetOf :: Ord a => Interval a -> Interval a -> Bool Source

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

For all `x` in `X`, `y` in `Y`. `x `op` y`

(<!) :: Ord a => Interval a -> Interval a -> Bool Source

For all `x` in `X`, `y` in `Y`. `x `<` y`

(<=!) :: Ord a => Interval a -> Interval a -> Bool Source

For all `x` in `X`, `y` in `Y`. `x `<=` y`

(==!) :: Eq a => Interval a -> Interval a -> Bool Source

For all `x` in `X`, `y` in `Y`. `x `==` y`

(>=!) :: Ord a => Interval a -> Interval a -> Bool Source

For all `x` in `X`, `y` in `Y`. `x `>=` y`

(>!) :: Ord a => Interval a -> Interval a -> Bool Source

For all `x` in `X`, `y` in `Y`. `x `>` y`

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

Does there exist an `x` in `X`, `y` in `Y` such that `x `op` y`?

(<?) :: Ord a => Interval a -> Interval a -> Bool Source

Does there exist an `x` in `X`, `y` in `Y` such that `x `<` y`?

(<=?) :: Ord a => Interval a -> Interval a -> Bool Source

Does there exist an `x` in `X`, `y` in `Y` such that `x `<=` y`?

(==?) :: Ord a => Interval a -> Interval a -> Bool Source

Does there exist an `x` in `X`, `y` in `Y` such that `x `==` y`?

(>=?) :: Ord a => Interval a -> Interval a -> Bool Source

Does there exist an `x` in `X`, `y` in `Y` such that `x `>=` y`?

(>?) :: Ord a => Interval a -> Interval a -> Bool Source

Does there exist an `x` in `X`, `y` in `Y` such that `x `>` y`?

idouble :: Interval Double -> Interval Double Source

ifloat :: Interval Float -> Interval Float Source