packages feed

intervals 0.6 → 0.7

raw patch · 7 files changed

+64/−5 lines, 7 files

Files

CHANGELOG.markdown view
@@ -1,3 +1,8 @@+0.7+---+* Corrected the definition of `mignitude`.+* Added a notion of `distance` between intervals+ 0.6 --- * Added `Numeric.Interval.Exception`. For consistency, we tend to throw exceptions now instead of rely on `NaN` when working with empty intervals.
intervals.cabal view
@@ -1,5 +1,5 @@ name:              intervals-version:           0.6+version:           0.7 synopsis:          Interval Arithmetic description:   A 'Numeric.Interval.Interval' is a closed, convex set of floating point values.
src/Numeric/Interval.hs view
@@ -30,6 +30,7 @@   , bisectIntegral   , magnitude   , mignitude+  , distance   , contains   , isSubsetOf   , certainly, (<!), (<=!), (==!), (>=!), (>!)
src/Numeric/Interval/Internal.hs view
@@ -38,6 +38,7 @@   , bisectIntegral   , magnitude   , mignitude+  , distance   , contains   , isSubsetOf   , certainly, (<!), (<=!), (==!), (>=!), (>!)@@ -243,6 +244,22 @@ mignitude :: (Num a, Ord a) => Interval a -> a mignitude = inf . abs {-# INLINE mignitude #-}++-- | Hausdorff distance between intervals.+--+-- >>> distance (1 ... 7) (6 ... 10)+-- 0+--+-- >>> distance (1 ... 7) (15 ... 24)+-- 8+--+-- >>> distance (1 ... 7) (-10 ... -2)+-- 3+--+-- >>> distance Empty (1 ... 1)+-- *** Exception: empty interval+distance :: (Num a, Ord a) => Interval a -> Interval a -> a+distance i1 i2 = mignitude (i1 - i2)  instance (Num a, Ord a) => Num (Interval a) where   I a b + I a' b' = (a + a') ... (b + b')
src/Numeric/Interval/Kaucher.hs view
@@ -37,6 +37,7 @@   , bisect   , magnitude   , mignitude+  , distance   , contains   , isSubsetOf   , certainly, (<!), (<=!), (==!), (>=!), (>!)@@ -236,7 +237,7 @@ -- >>> magnitude (singleton 5) -- 5 magnitude :: (Num a, Ord a) => Interval a -> a-magnitude x = (max `on` abs) (inf x) (sup x)+magnitude = sup . abs {-# INLINE magnitude #-}  -- | \"mignitude\"@@ -245,14 +246,33 @@ -- 1 -- -- >>> mignitude (-20 ... 10)--- 10+-- 0 -- -- >>> mignitude (singleton 5) -- 5+--+-- >>> mignitude empty+-- NaN mignitude :: (Num a, Ord a) => Interval a -> a-mignitude x = (min `on` abs) (inf x) (sup x)+mignitude = inf . abs {-# INLINE mignitude #-} +-- | Hausdorff distance between non-empty intervals.+--+-- >>> distance (1 ... 7) (6 ... 10)+-- 0+--+-- >>> distance (1 ... 7) (15 ... 24)+-- 8+--+-- >>> distance (1 ... 7) (-10 ... -2)+-- 3+--+-- >>> distance empty (1 ... 1)+-- NaN+distance :: (Num a, Ord a) => Interval a -> Interval a -> a+distance i1 i2 = mignitude (i1 - i2)+ instance (Num a, Ord a) => Num (Interval a) where   I a b + I a' b' = (a + a') ... (b + b')   {-# INLINE (+) #-}@@ -266,7 +286,8 @@   abs x@(I a b)     | a >= 0    = x     | b <= 0    = negate x-    | otherwise = 0 ... max (- a) b+    | b > 0 && a < 0 = 0 ... max (- a) b+    | otherwise      = x -- preserve the empty interval   {-# INLINE abs #-}    signum = increasing signum
src/Numeric/Interval/NonEmpty.hs view
@@ -30,6 +30,7 @@   , singular   , width   , midpoint+  , distance   , intersection   , hull   , bisect
src/Numeric/Interval/NonEmpty/Internal.hs view
@@ -29,6 +29,7 @@   , singular   , width   , midpoint+  , distance   , intersection   , hull   , bisect@@ -246,6 +247,19 @@ midpoint :: Fractional a => Interval a -> a midpoint (I a b) = a + (b - a) / 2 {-# INLINE midpoint #-}++-- | Hausdorff distance between intervals.+--+-- >>> distance (1 ... 7) (6 ... 10)+-- 0+--+-- >>> distance (1 ... 7) (15 ... 24)+-- 8+--+-- >>> distance (1 ... 7) (-10 ... -2)+-- 3+distance :: (Num a, Ord a) => Interval a -> Interval a -> a+distance i1 i2 = mignitude (i1 - i2)  -- | Determine if a point is in the interval. --