packages feed

aern2-mp 0.2.1.1 → 0.2.2.0

raw patch · 10 files changed

+158/−37 lines, 10 filesdep ~mixed-types-numPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: mixed-types-num

API changes (from Hackage documentation)

- AERN2.MP.Accuracy: instance AERN2.MP.Accuracy.HasAccuracy Numeric.MixedTypes.Kleenean.Kleenean
- AERN2.MP.Enclosure: instance (AERN2.MP.Enclosure.CanUnionSameType t, Numeric.CollectErrors.Type.CanTakeCNErrors t) => Numeric.MixedTypes.Literals.HasIfThenElse Numeric.MixedTypes.Kleenean.Kleenean t
- AERN2.MP.Enclosure: instance AERN2.MP.Enclosure.CanIntersectAsymmetric (Numeric.CollectErrors.Type.CN Numeric.MixedTypes.Kleenean.Kleenean) (Numeric.CollectErrors.Type.CN b) => AERN2.MP.Enclosure.CanIntersectAsymmetric Numeric.MixedTypes.Kleenean.Kleenean (Numeric.CollectErrors.Type.CN b)
- AERN2.MP.Enclosure: instance AERN2.MP.Enclosure.CanIntersectAsymmetric (Numeric.CollectErrors.Type.CN a) (Numeric.CollectErrors.Type.CN Numeric.MixedTypes.Kleenean.Kleenean) => AERN2.MP.Enclosure.CanIntersectAsymmetric (Numeric.CollectErrors.Type.CN a) Numeric.MixedTypes.Kleenean.Kleenean
- AERN2.MP.Enclosure: instance AERN2.MP.Enclosure.CanIntersectAsymmetric Numeric.MixedTypes.Kleenean.Kleenean Numeric.MixedTypes.Kleenean.Kleenean
+ AERN2.Kleenean: CertainFalse :: Kleenean
+ AERN2.Kleenean: CertainTrue :: Kleenean
+ AERN2.Kleenean: TrueOrFalse :: Kleenean
+ AERN2.Kleenean: data Kleenean
+ AERN2.Kleenean: instance GHC.Classes.Eq AERN2.Kleenean.Kleenean
+ AERN2.Kleenean: instance GHC.Generics.Generic AERN2.Kleenean.Kleenean
+ AERN2.Kleenean: instance GHC.Show.Show AERN2.Kleenean.Kleenean
+ AERN2.Kleenean: instance Numeric.MixedTypes.Bool.CanAndOrAsymmetric AERN2.Kleenean.Kleenean AERN2.Kleenean.Kleenean
+ AERN2.Kleenean: instance Numeric.MixedTypes.Bool.CanAndOrAsymmetric AERN2.Kleenean.Kleenean GHC.Types.Bool
+ AERN2.Kleenean: instance Numeric.MixedTypes.Bool.CanAndOrAsymmetric GHC.Types.Bool AERN2.Kleenean.Kleenean
+ AERN2.Kleenean: instance Numeric.MixedTypes.Bool.CanNeg AERN2.Kleenean.Kleenean
+ AERN2.Kleenean: instance Numeric.MixedTypes.Bool.CanTestCertainly AERN2.Kleenean.Kleenean
+ AERN2.Kleenean: instance Numeric.MixedTypes.Literals.ConvertibleExactly AERN2.Kleenean.Kleenean AERN2.Kleenean.Kleenean
+ AERN2.Kleenean: instance Numeric.MixedTypes.Literals.ConvertibleExactly GHC.Types.Bool AERN2.Kleenean.Kleenean
+ AERN2.Kleenean: kleenean :: CanBeKleenean t => t -> Kleenean
+ AERN2.Kleenean: tKleenean :: T Kleenean
+ AERN2.MP.Accuracy: instance AERN2.MP.Accuracy.HasAccuracy AERN2.Kleenean.Kleenean
+ AERN2.MP.Enclosure: instance (AERN2.MP.Enclosure.CanUnionSameType t, Numeric.CollectErrors.Type.CanTakeCNErrors t) => Numeric.MixedTypes.Literals.HasIfThenElse AERN2.Kleenean.Kleenean t
+ AERN2.MP.Enclosure: instance AERN2.MP.Enclosure.CanIntersectAsymmetric (Numeric.CollectErrors.Type.CN AERN2.Kleenean.Kleenean) (Numeric.CollectErrors.Type.CN b) => AERN2.MP.Enclosure.CanIntersectAsymmetric AERN2.Kleenean.Kleenean (Numeric.CollectErrors.Type.CN b)
+ AERN2.MP.Enclosure: instance AERN2.MP.Enclosure.CanIntersectAsymmetric (Numeric.CollectErrors.Type.CN a) (Numeric.CollectErrors.Type.CN AERN2.Kleenean.Kleenean) => AERN2.MP.Enclosure.CanIntersectAsymmetric (Numeric.CollectErrors.Type.CN a) AERN2.Kleenean.Kleenean
+ AERN2.MP.Enclosure: instance AERN2.MP.Enclosure.CanIntersectAsymmetric AERN2.Kleenean.Kleenean AERN2.Kleenean.Kleenean

Files

README.md view
@@ -39,21 +39,26 @@  ```Text ...> pi100 = piBallP (prec 100)+...> pi100+[3.14159265358979323846264338... ± ~7.8886e-31 ~2^(-100)]+ ...> pi10000 = piBallP (prec 10000)+...> pi10000+[3.14159265358979323846264338... ± ~0.0000 ~2^(-10000)]  ...> sin pi100-[0.0000000000000000000000000000001694818351060767... ± ~7.8925e-31 ~2^(-99)]+[0.00000000000000000000000000... ± ~7.8925e-31 ~2^(-99)]  ...> sin pi10000-[0.0000000000000000000000000000000000000000000000... ± ~0.0000 ~2^(-9999)]-(0.07 secs, 64,466,432 bytes)+[0.00000000000000000000000000... ± ~0.0000 ~2^(-9999)]+(0.08 secs, 64,529,960 bytes) ```  The Prelude power operator works only for integral types:  ```Text ...> pi100 ^ 2-[9.8696044010893586188344909998725639610631902560... ± ~8.1120e-30 ~2^(-96)]+[9.86960440108935861883449099... ± ~1.5777e-29 ~2^(-95)]  ...> pi100 ^ pi100 <interactive>:18:1: error:@@ -87,11 +92,11 @@ ...> pi10000 = piBallP (prec 10000)  ...> pi100 ^ pi100-[36.4621596072079117709908260226198218149834948802... ± ~1.8696e-28 ~2^(-92)]+[36.46215960720791177099082602... ± ~1.8696e-28 ~2^(-92)]  ...> pi10000 ^ pi10000-[36.4621596072079117709908260226921236663655084022... ± ~0.0000 ~2^(-9992)]-(0.27 secs, 204,657,248 bytes)+[36.46215960720791177099082602... ± ~0.0000 ~2^(-9992)]+(0.28 secs, 206,026,032 bytes) ```  Interval comparison now returns a `Kleenean` instead of `Bool`, supporting undecided comparisons:
aern2-mp.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack ----- hash: b173a95426982332154ff9bd4b378842b3f7e36987e6c3cd6105fa8b5381f8c2+-- hash: db2ad6fe0e6460591de35bce8f443dcc33712ff74369d8be93d12371b3ccd0b7  name:           aern2-mp-version:        0.2.1.1+version:        0.2.2.0 synopsis:       Multi-precision ball (interval) arithmetic description:    Please see the README on GitHub at <https://github.com/michalkonecny/aern2/#readme> category:       Math@@ -29,6 +29,7 @@  library   exposed-modules:+      AERN2.Kleenean       AERN2.Limit       AERN2.MP       AERN2.MP.Accuracy@@ -60,8 +61,20 @@       Paths_aern2_mp   hs-source-dirs:       src-  default-extensions: RebindableSyntax, ScopedTypeVariables, DeriveGeneric, TypeFamilies, TypeOperators, ConstraintKinds, DefaultSignatures, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, UndecidableInstances-  other-extensions: TemplateHaskell+  default-extensions:+      RebindableSyntax,+      ScopedTypeVariables,+      DeriveGeneric,+      TypeFamilies,+      TypeOperators,+      ConstraintKinds,+      DefaultSignatures,+      MultiParamTypeClasses,+      FlexibleContexts,+      FlexibleInstances,+      UndecidableInstances+  other-extensions:+      TemplateHaskell   ghc-options: -Wall   build-depends:       QuickCheck@@ -71,7 +84,7 @@     , deepseq     , hspec     , integer-logarithms-    , mixed-types-num >=0.5.1+    , mixed-types-num >=0.5.4     , reflection     , regex-tdfa     , template-haskell@@ -87,8 +100,20 @@       Paths_aern2_mp   hs-source-dirs:       test-  default-extensions: RebindableSyntax, ScopedTypeVariables, DeriveGeneric, TypeFamilies, TypeOperators, ConstraintKinds, DefaultSignatures, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, UndecidableInstances-  other-extensions: TemplateHaskell+  default-extensions:+      RebindableSyntax,+      ScopedTypeVariables,+      DeriveGeneric,+      TypeFamilies,+      TypeOperators,+      ConstraintKinds,+      DefaultSignatures,+      MultiParamTypeClasses,+      FlexibleContexts,+      FlexibleInstances,+      UndecidableInstances+  other-extensions:+      TemplateHaskell   ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall   build-depends:       QuickCheck@@ -99,7 +124,7 @@     , deepseq     , hspec     , integer-logarithms-    , mixed-types-num >=0.5.1+    , mixed-types-num >=0.5.4     , reflection     , regex-tdfa     , template-haskell
changelog.md view
@@ -1,5 +1,7 @@ # Change log for aern2-mp +* v 0.2.2 2021-05-21+  * move Kleenean from mixed-types-num to here * v 0.2.1 2021-05-18   * add WithAnyPrec existential type wrapper for WithCurrentPrec * v 0.2.0 2021-05-17
+ src/AERN2/Kleenean.hs view
@@ -0,0 +1,96 @@+{-# OPTIONS_GHC -Wno-orphans #-}+{-# LANGUAGE DeriveGeneric #-}+{-|+    Module      :  AERN2.Kleenean+    Description :  Three-valued logic+    Copyright   :  (c) Michal Konecny+    License     :  BSD3++    Maintainer  :  mikkonecny@gmail.com+    Stability   :  experimental+    Portability :  portable++-}+module AERN2.Kleenean+(+    Kleenean(..), kleenean, tKleenean+)+where++import Numeric.MixedTypes.PreludeHiding+import qualified Prelude as P++-- import Test.SmallCheck.Series+import GHC.Generics++import Numeric.MixedTypes.Literals+    ( ConvertibleExactly(..), convertExactly, T(T) )+import Numeric.MixedTypes.Bool+    ( (&&),+      not,+      CanAndOrAsymmetric(..),+      CanNeg(negate),+      CanTestCertainly(..),+      and )++tKleenean :: T Kleenean+tKleenean = T "Kleenean"++data Kleenean = CertainTrue | CertainFalse | TrueOrFalse+  deriving (P.Eq, Show, Generic)++-- instance Serial IO Kleenean++type CanBeKleenean t = ConvertibleExactly t Kleenean+kleenean :: (CanBeKleenean t) => t -> Kleenean+kleenean = convertExactly++instance ConvertibleExactly Kleenean Kleenean where+  safeConvertExactly = Right++instance ConvertibleExactly Bool Kleenean where+  safeConvertExactly True = Right CertainTrue+  safeConvertExactly False = Right CertainFalse++instance CanTestCertainly Kleenean where+  isCertainlyTrue = (P.== CertainTrue)+  isCertainlyFalse = (P.== CertainFalse)++instance CanNeg Kleenean where+  negate CertainTrue = CertainFalse+  negate CertainFalse = CertainTrue+  negate TrueOrFalse = TrueOrFalse++_testNeg1 :: Kleenean+_testNeg1 = not CertainTrue++instance CanAndOrAsymmetric Kleenean Kleenean+  where+  type AndOrType Kleenean Kleenean = Kleenean+  and2 CertainTrue CertainTrue = CertainTrue+  and2 CertainFalse _ = CertainFalse+  and2 _ CertainFalse = CertainFalse+  and2 _ _ = TrueOrFalse+  or2 CertainFalse CertainFalse = CertainFalse+  or2 CertainTrue _ = CertainTrue+  or2 _ CertainTrue = CertainTrue+  or2 _ _ = TrueOrFalse++instance CanAndOrAsymmetric Bool Kleenean+  where+  type AndOrType Bool Kleenean = Kleenean+  and2 b = and2 (kleenean b)+  or2 b = or2 (kleenean b)++instance CanAndOrAsymmetric Kleenean Bool+  where+  type AndOrType Kleenean Bool = Kleenean+  and2 k b = and2 k (kleenean b)+  or2 k b = or2 k (kleenean b)++_testAndOr1 :: Kleenean+_testAndOr1 = TrueOrFalse && False++_testAndOr2 :: Kleenean+_testAndOr2 = and [CertainTrue, TrueOrFalse, CertainFalse]+
src/AERN2/MP.hs view
@@ -12,14 +12,18 @@ -}  module AERN2.MP-( module AERN2.Norm+( +-- * Interval (centre-radius) arithmetic+  MPBall(..), CanBeMPBall, mpBall, CanBeMPBallP, mpBallP+, reducePrecionIfInaccurate+, giveUpIfVeryInaccurate+-- * Supporting concepts+, module AERN2.Kleenean+, module AERN2.Norm , module AERN2.MP.Precision , module AERN2.MP.Accuracy , module AERN2.MP.ErrorBound , module AERN2.MP.Enclosure-, MPBall(..), CanBeMPBall, mpBall, CanBeMPBallP, mpBallP-, reducePrecionIfInaccurate-, giveUpIfVeryInaccurate ) where @@ -27,6 +31,7 @@ -- import qualified Prelude as P -- import Text.Printf +import AERN2.Kleenean import AERN2.Norm import AERN2.MP.Precision import AERN2.MP.Accuracy
src/AERN2/MP/Accuracy.hs view
@@ -35,6 +35,7 @@ import Test.QuickCheck ( Arbitrary(arbitrary), frequency )  import AERN2.Norm+import AERN2.Kleenean import AERN2.MP.Precision  {- example -}
src/AERN2/MP/Ball/Comparisons.hs view
@@ -33,6 +33,7 @@     ( CollectErrors(getMaybeValue), CanBeErrors ) import qualified Numeric.CollectErrors as CN +import AERN2.Kleenean import AERN2.Norm import AERN2.MP.Dyadic (Dyadic) import AERN2.MP.Float (MPFloat)
src/AERN2/MP/Ball/PreludeOps.hs view
@@ -20,6 +20,7 @@ import MixedTypesNumPrelude import qualified Prelude as P +import AERN2.Kleenean import AERN2.MP.Dyadic (dyadic)  import AERN2.MP.Ball.Type
src/AERN2/MP/Ball/Type.hs view
@@ -94,7 +94,7 @@       case displayAC of         Exact -> 1000000000         NoInformation -> 0-        _ -> integer $ ac2prec displayAC+        _ -> round $ (log (double 2)/log (double 10)) * (integer $ ac2prec displayAC)     showAC Exact = ""     showAC NoInformation = "(oo)"     showAC ac = " ~2^(" ++ show (negate $ fromAccuracy ac) ++ ")"
src/AERN2/MP/Enclosure.hs view
@@ -38,6 +38,7 @@  import qualified Numeric.CollectErrors as CN +import AERN2.Kleenean import AERN2.MP.ErrorBound -- import AERN2.MP.Accuracy @@ -313,22 +314,6 @@   where   type UnionType (CN a) (CN b) = UnionType a b   union = CN.lift2CN union---- TODO: move to aern2-real (or aern2-net)--- instance---   (Arrow to, CanUnionAsymmetric e1 e2)---   =>---   CanUnionAsymmetric (to Accuracy e1) (to Accuracy e2)---   -- this instance is important for "parallel if"---   where---   type UnionType (to Accuracy e1) (to Accuracy e2) =---     to Accuracy (UnionType e1 e2)---   union xA yA =---     proc ac ->---       do---       x <- xA -< ac---       y <- yA -< ac---       returnA -< union x y  instance (CanUnionSameType t, CN.CanTakeCNErrors t) =>   HasIfThenElse Kleenean t