AERN-Real 0.9.7.2 → 0.9.8
raw patch · 9 files changed
+132/−6 lines, 9 filesdep +htmldep +regex-compatdep +stmdep ~hmpfrPVP ok
version bump matches the API change (PVP)
Dependencies added: html, regex-compat, stm
Dependency ranges changed: hmpfr
API changes (from Hackage documentation)
+ Data.Number.ER.Misc: compareListsWith :: (a -> a -> Ordering) -> [a] -> [a] -> Ordering
+ Data.Number.ER.Real.Approx.Interval: instance (ERRealBase b, HTML b) => HTML (ERInterval b)
+ Data.Number.ER.Real.DomainBox: compare :: (DomainBox box varid val) => (val -> val -> Ordering) -> box -> box -> Ordering
+ Data.Number.ER.ShowHTML: instance (HTML a) => HTML (Maybe a)
+ Data.Number.ER.ShowHTML: renderHtmlNoHeader :: Html -> String
+ Data.Number.ER.ShowHTML: showHTML :: (HTML t) => t -> String
+ Data.Number.ER.ShowHTML: toHtmlDefault :: (Show a) => a -> Html
Files
- AERN-Real.cabal +7/−5
- ChangeLog +6/−0
- src/Data/Number/ER/Misc.hs +11/−0
- src/Data/Number/ER/MiscSTM.hs +31/−0
- src/Data/Number/ER/Real/Approx/Interval.hs +12/−0
- src/Data/Number/ER/Real/Base/MPFR.hs +1/−1
- src/Data/Number/ER/Real/DomainBox.hs +1/−0
- src/Data/Number/ER/Real/DomainBox/IntMap.hs +12/−0
- src/Data/Number/ER/ShowHTML.hs +51/−0
AERN-Real.cabal view
@@ -1,5 +1,5 @@ Name: AERN-Real-Version: 0.9.7.2+Version: 0.9.8 Cabal-Version: >= 1.2 Build-Type: Simple License: BSD3@@ -42,19 +42,19 @@ if flag(containers-in-base) if flag(use-hmpfr) Build-Depends:- base < 3, binary >= 0.4, hmpfr == 0.1.1+ base < 3, binary >= 0.4, html >= 1.0, regex-compat >= 0.71, stm, hmpfr == 0.1.3 cpp-options: -DUSE_MPFR else Build-Depends:- base < 3, binary >= 0.4+ base < 3, binary >= 0.4, html >= 1.0, regex-compat >= 0.71, stm else if flag(use-hmpfr) Build-Depends:- base >= 3, containers, binary >= 0.4, hmpfr == 0.1.1+ base >= 3, containers, binary >= 0.4, html >= 1.0, regex-compat >= 0.71, stm, hmpfr == 0.1.3 cpp-options: -DUSE_MPFR else Build-Depends:- base >= 3, containers, binary >= 0.4+ base >= 3, containers, binary >= 0.4, html >= 1.0, regex-compat >= 0.71, stm Exposed-modules: Data.Number.ER, Data.Number.ER.Real,@@ -76,8 +76,10 @@ Data.Number.ER.Real.Approx, Data.Number.ER.Real.DomainBox, Data.Number.ER.Real.DomainBox.IntMap,+ Data.Number.ER.ShowHTML, Data.Number.ER.PlusMinus, Data.Number.ER.BasicTypes, Data.Number.ER.Misc,+ Data.Number.ER.MiscSTM, Data.Number.ER.ExtendedInteger
ChangeLog view
@@ -1,3 +1,9 @@+0.9.8: 1 December 2008+ * added instance of the HTML class for intervals+ * added syntactic comparison of variable-indexed domain boxes+ * some extra miscellaneous functions+ * moved miscellaneous facilities for STM from AERN-RnToRm-Plot to here so that they can be used by AERN-Net+ 0.9.7.2: 7 October 2008 * hmpfr interface now uses a faster toDouble conversion
src/Data/Number/ER/Misc.hs view
@@ -49,6 +49,17 @@ | x == y = compareLex xs ys | otherwise = compare x y +compareListsWith ::+ (a -> a -> Ordering) ->+ [a] -> [a] -> Ordering+compareListsWith _ [] [] = EQ+compareListsWith _ [] _ = LT+compareListsWith _ _ [] = GT+compareListsWith compareVals (x:xs) (y:ys) =+ case compareVals x y of+ EQ -> compareListsWith compareVals xs ys+ res -> res+ mapFst :: (a1 -> a2) -> (a1,b) -> (a2,b) mapFst f (a,b) = (f a,b) mapSnd :: (b1 -> b2) -> (a,b1) -> (a,b2)
+ src/Data/Number/ER/MiscSTM.hs view
@@ -0,0 +1,31 @@+{-|+ Utilities related to concurrency.+-}+module Data.Number.ER.MiscSTM where++import Control.Concurrent as Concurrent+import Control.Concurrent.STM as STM++modifyTVar tv update =+ do+ value <- readTVar tv+ writeTVar tv $ update value++modifyTVarGetOldVal tv update =+ do+ value <- readTVar tv+ writeTVar tv $ update value+ return value++modifyTVarHasChanged tv update =+ do+ value <- readTVar tv+ let newValue = update value+ if value == newValue+ then return False+ else + do+ writeTVar tv $ update value+ return True+ +
src/Data/Number/ER/Real/Approx/Interval.hs view
@@ -30,6 +30,8 @@ import Data.Ratio +import qualified Text.Html as H+ import Data.Typeable import Data.Generics.Basics import Data.Binary@@ -319,6 +321,15 @@ "[" ++ showBase l ++ "," ++ showBase r ++ "]" showBase = B.showDiGrCmp numDigits showGran showComponents +instance (B.ERRealBase b, H.HTML b) => H.HTML (ERInterval b)+ where+ toHtml (ERInterval l r) + | l == r =+ H.toHtml $ show l+ | otherwise =+ H.simpleTable [] [] [[H.toHtml l],[H.toHtml r]]+ toHtml i = H.toHtml $ show i + instance (B.ERRealBase b) => Num (ERInterval b) where fromInteger n = normaliseERInterval $ ERInterval (fromInteger n) (fromInteger n)@@ -530,3 +541,4 @@ instance (B.ERRealBase b, RealFrac b) => RAEL.ERApproxElementary (ERInterval b) -- all operations here have appropriate default implementations+
src/Data/Number/ER/Real/Base/MPFR.hs view
@@ -66,7 +66,7 @@ isPlusInfinity x = M.isInfinite x && x > 0 plusInfinity = 1/0 fromDouble = M.fromDouble M.Up 53- toDouble = fromRational . toRational+ toDouble = M.toDouble M.Up fromFloat = B.fromDouble . fromRational . toRational toFloat = fromRational . toRational . B.toDouble showDiGrCmp numDigits _showGran _showComponents f =
src/Data/Number/ER/Real/DomainBox.hs view
@@ -68,6 +68,7 @@ fromAscList :: [(varid, val)] -> box -- toMap :: box -> Map.Map varid val -- fromMap :: Map.Map varid val -> box+ compare :: (val -> val -> Ordering) -> box -> box -> Ordering insert :: varid -> val -> box -> box insertWith :: (val -> val -> val) -> varid -> val -> box -> box delete :: varid -> box -> box
src/Data/Number/ER/Real/DomainBox/IntMap.hs view
@@ -23,6 +23,8 @@ import qualified Data.Number.ER.Real.DomainBox as DBox import Data.Number.ER.Real.DomainBox (VariableID(..), DomainBox, DomainBoxMappable, DomainIntBox) +import Data.Number.ER.Misc+ import qualified Data.IntMap as IMap import qualified Data.Set as Set @@ -51,6 +53,16 @@ fromAscList = IMap.fromAscList -- toMap = id -- fromMap = id+ compare compareVals b1 b2 =+ compareListsWith comparePairs (IMap.toList b1) (IMap.toList b2)+ where+ comparePairs (k1,v1) (k2,v2) =+ compareComposeMany+ [+ compare k1 k2,+ compareVals v1 v2+ ]+ insert = IMap.insert insertWith = IMap.insertWith delete = IMap.delete
+ src/Data/Number/ER/ShowHTML.hs view
@@ -0,0 +1,51 @@+{-|+ Module : Data.Number.ER.ShowHTML+ Description : Misc facilities for HTML rendering.+ Copyright : (c) Michal Konecny+ License : BSD3++ Maintainer : mik@konecny.aow.cz+ Stability : experimental+ Portability : portable+ + +-}+module Data.Number.ER.ShowHTML where++import qualified Text.Html as H+import Text.Regex++{-|+ Render HTML is a way that can be inlined in + Javascript strings etc.+-}+showHTML :: + (H.HTML t) =>+ t -> String+showHTML v =+ escapeNewLines $+ renderHtmlNoHeader $ + H.toHtml v+ where+-- stripHeader s =+-- (splitRegex (mkRegex "-->") s) !! 1+ escapeNewLines s =+ (subRegex (mkRegex "([^\\])$") s "\\1\\\\") ++abovesTable attrs cells =+ H.table H.! attrs H.<< (H.aboves $ map (H.td H.<<) cells)+besidesTable attrs cells =+ H.table H.! attrs H.<< (H.aboves [H.besides $ map (H.td H.<<) cells])++renderHtmlNoHeader :: H.Html -> String+renderHtmlNoHeader theHtml =+ foldr (.) id (map (H.renderHtml' 0)+ (H.getHtmlElements theHtml)) "\n"++toHtmlDefault :: (Show a) => a -> H.Html+toHtmlDefault = H.toHtml . show++instance (H.HTML a) => H.HTML (Maybe a) where+ toHtml Nothing = H.toHtml $ "[Nothing]"+ toHtml (Just a) = H.toHtml a+