packages feed

rounded 0.3 → 1.0

raw patch · 7 files changed

+36/−22 lines, 7 filesdep ~basedep ~ghc-prim

Dependency ranges changed: base, ghc-prim

Files

CHANGELOG.markdown view
@@ -1,12 +1,12 @@ # Revision history for rounded -## 0.3 -- 2020-05-19+## 1.0 -- 2019-08-28 -* Fixed `simplify` with `Nat` precisions by adding kind signatures.+* Require MPFR 4.0 or above.  ## 0.2 -- 2019-08-28 -* Wrapped a lot more of the MPFR API.+* Wrapped a lot more of the MPFR 3.1 API. * Fixed `wrapped_mpfr_set_ld()` FFI binding.  Previously `fromLongDouble`   could corrupt memory or crash due to missing argument. * Removed dependency on `singletons`.
rounded.cabal view
@@ -1,5 +1,5 @@ name:               rounded-version:            0.3+version:            1.0 synopsis:           Correctly-rounded arbitrary-precision floating-point arithmetic homepage:           https://github.com/ekmett/rounded bug-reports:        https://github.com/ekmett/rounded/issues@@ -28,7 +28,7 @@     >>> exp pi :: Rounded TowardZero 512     23.140692632779269005729086367948547380266106242600211993445046409524342350690452783516971997067549219675952704801087773144428044414693835844717445879609842     .-    rounded version 0.x is for MPFR version 3.1 or above.+    rounded version 1.x is for MPFR version 4.0 and above.  extra-source-files: README.markdown CHANGELOG.markdown test.hs test.txt @@ -39,7 +39,7 @@ source-repository this   type: git   location: git://github.com/ekmett/rounded.git-  tag: rounded-0.3+  tag: rounded-1.0  library   exposed-modules:@@ -57,8 +57,8 @@     Numeric.Rounded.Precision    build-depends:-    base             >= 4.8     && < 4.15,-    ghc-prim         >= 0.4     && < 0.7,+    base             >= 4.8     && < 4.14,+    ghc-prim         >= 0.4     && < 0.6,     reflection       >= 2.1.2   && < 2.2,     hgmp             >= 0.1.1   && < 0.2,     long-double      >= 0.1     && < 0.2@@ -67,6 +67,7 @@   build-tools:     hsc2hs    extra-libraries: mpfr gmp+  pkgconfig-depends: mpfr >= 4.0.0    hs-source-dirs:  src   c-sources:       cbits/wrappers.c
src/Numeric/MPFR/Raw/Safe.hs view
@@ -146,6 +146,9 @@ foreign import ccall safe "mpfr_pow" mpfr_pow :: Binary foreign import ccall safe "mpfr_sub" mpfr_sub :: Binary +foreign import ccall safe "mpfr_beta" mpfr_beta :: Binary+foreign import ccall safe "mpfr_gamma_inc" mpfr_gamma_inc :: Binary+ type DualOutput = Ptr MPFR -> Ptr MPFR -> Ptr MPFR -> MPFRRnd -> IO CInt  foreign import ccall safe "mpfr_modf" mpfr_modf :: DualOutput
src/Numeric/MPFR/Raw/Unsafe.hs view
@@ -146,6 +146,9 @@ foreign import ccall unsafe "mpfr_pow" mpfr_pow :: Binary foreign import ccall unsafe "mpfr_sub" mpfr_sub :: Binary +foreign import ccall unsafe "mpfr_beta" mpfr_beta :: Binary+foreign import ccall unsafe "mpfr_gamma_inc" mpfr_gamma_inc :: Binary+ type DualOutput = Ptr MPFR -> Ptr MPFR -> Ptr MPFR -> MPFRRnd -> IO CInt  foreign import ccall unsafe "mpfr_modf" mpfr_modf :: DualOutput
src/Numeric/Rounded.hs view
@@ -110,6 +110,8 @@     , mul_     , pow_     , sub_+    , beta_+    , gamma_inc_     -- ** Dual output     , modf     , sin_cos
src/Numeric/Rounded/Internal.hs view
@@ -244,7 +244,7 @@         f cfr afr bfr (rnd a)   return c -add_, agm_, atan2_, copysign_, dim_, div_, fmod_, hypot_, max_, min_, mul_, pow_, sub_,+add_, agm_, atan2_, copysign_, dim_, div_, fmod_, hypot_, max_, min_, mul_, pow_, sub_, beta_, gamma_inc_,  (!+!), (!-!), (!*!), (!/!), (!**!)   :: (Rounding r, Precision p1, Precision p2, Precision p3)   => Rounded r p1 -> Rounded r p2 -> Rounded r p3@@ -261,6 +261,8 @@ mul_ = binary mpfr_mul pow_ = binary mpfr_pow sub_ = binary mpfr_sub+beta_ = binary mpfr_beta+gamma_inc_ = binary mpfr_gamma_inc (!+!) = add_ (!-!) = sub_ (!*!) = mul_
src/Numeric/Rounded/Simple.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE MagicHash #-}-{-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} ----------------------------------------------------------------------------- -- |@@ -142,6 +141,8 @@   , dim_   , fmod_   , hypot_+  , beta_+  , gamma_inc_   -- * Foreign Function Interface   , withInRounded   , withInOutRounded@@ -176,16 +177,16 @@ precision :: Rounded -> Precision precision = fromIntegral . roundedPrec -reifyRounded :: Rounded -> (forall k (p :: k) . R.Precision p => R.Rounded r p -> a) -> a+reifyRounded :: Rounded -> (forall p . R.Precision p => R.Rounded r p -> a) -> a reifyRounded (Rounded p s e l) f = R.reifyPrecision (fromIntegral p) (\q -> f (g q (R.Rounded p s e l)))   where     g :: R.Precision q => proxy q -> R.Rounded s q -> R.Rounded s q     g _ x = x -simplify :: forall r k (p :: k) . R.Rounded r p -> Rounded+simplify :: R.Rounded r p -> Rounded simplify (R.Rounded p s e l) = Rounded p s e l -constant :: (forall r k (p :: k) . (R.Rounding r, R.Precision p) => R.Rounded r p) -> RoundingMode -> Precision -> Rounded+constant :: (forall r p . (R.Rounding r, R.Precision p) => R.Rounded r p) -> RoundingMode -> Precision -> Rounded constant f r q = R.reifyRounding r (\pr -> R.reifyPrecision q (\pq -> g pr pq f))   where     g :: (R.Rounding r, R.Precision p) => proxy1 r -> proxy2 p -> R.Rounded r p -> Rounded@@ -198,7 +199,7 @@ kEuler = constant R.kEuler kCatalan = constant R.kCatalan -unary :: (forall r kp (p :: kp) kq (q :: kq) . (R.Rounding r, R.Precision p, R.Precision q) => R.Rounded r p -> R.Rounded r q) -> RoundingMode -> Precision -> Rounded -> Rounded+unary :: (forall r p q . (R.Rounding r, R.Precision p, R.Precision q) => R.Rounded r p -> R.Rounded r q) -> RoundingMode -> Precision -> Rounded -> Rounded unary f r q a = R.reifyRounding r (\pr -> R.reifyPrecision q (\pq -> reifyRounded a (\ra -> g pr pq f ra)))   where     g :: (R.Rounding r, R.Precision p, R.Precision q) => proxy1 r -> proxy2 q -> (R.Rounded r p -> R.Rounded r q) -> R.Rounded r p -> Rounded@@ -277,22 +278,22 @@ fromRational' :: RoundingMode -> Precision -> Rational -> Rounded fromRational' = fromX fromRational -fromX :: (forall r k (p :: k) . (R.Rounding r, R.Precision p) => x -> R.Rounded r p) -> RoundingMode -> Precision -> x -> Rounded+fromX :: (forall r p . (R.Rounding r, R.Precision p) => x -> R.Rounded r p) -> RoundingMode -> Precision -> x -> Rounded fromX f r p x = R.reifyRounding r (\pr -> R.reifyPrecision p (\pp -> g pr pp (f x)))   where     g :: (R.Rounding r, R.Precision p) => proxy1 r -> proxy2 p -> R.Rounded r p -> Rounded-    g _ _ y = simplify y+    g _ _ x = simplify x -binary :: (forall r kp (p :: kp) kq (q :: kq) kpq (pq :: kpq) . (R.Rounding r, R.Precision p, R.Precision q, R.Precision pq) => R.Rounded r p -> R.Rounded r q -> R.Rounded r pq) -> RoundingMode -> Precision -> Rounded -> Rounded -> Rounded+binary :: (forall r p q pq . (R.Rounding r, R.Precision p, R.Precision q, R.Precision pq) => R.Rounded r p -> R.Rounded r q -> R.Rounded r pq) -> RoundingMode -> Precision -> Rounded -> Rounded -> Rounded binary f r pq a b = R.reifyRounding r (\pr -> R.reifyPrecision pq (\ppq -> reifyRounded a (\ra -> reifyRounded b (\rb -> g pr ppq f ra rb))))   where     g :: (R.Rounding r, R.Precision p, R.Precision q, R.Precision pq) => proxy1 r -> proxy2 pq -> (R.Rounded r p -> R.Rounded r q -> R.Rounded r pq) -> R.Rounded r p -> R.Rounded r q -> Rounded     g _ _ h x y = simplify (h x y) -binary' :: (forall r kp (p :: kp) kq (q :: kq) kpq (pq :: kpq) . (R.Rounding r, R.Precision p, R.Precision q, R.Precision pq) => R.Rounded r p -> R.Rounded r q -> R.Rounded r pq) -> Rounded -> Rounded -> Rounded+binary' :: (forall r p q pq . (R.Rounding r, R.Precision p, R.Precision q, R.Precision pq) => R.Rounded r p -> R.Rounded r q -> R.Rounded r pq) -> Rounded -> Rounded -> Rounded binary' f a b = binary f R.TowardNearest (precision a `max` precision b) a b -add_, agm_, atan2_, copysign_, dim_, div_, fmod_, hypot_, max_, min_, mul_, pow_, sub_+add_, agm_, atan2_, copysign_, dim_, div_, fmod_, hypot_, max_, min_, mul_, pow_, sub_, beta_, gamma_inc_   :: RoundingMode -> Precision -> Rounded -> Rounded -> Rounded add_ = binary R.add_ agm_ = binary R.agm_@@ -307,14 +308,16 @@ mul_ = binary R.mul_ pow_ = binary R.pow_ sub_ = binary R.sub_+beta_ = binary R.beta_+gamma_inc_ = binary R.gamma_inc_ -unary' :: (forall r k (p :: k) . (R.Rounding r, R.Precision p) => R.Rounded r p -> a) -> RoundingMode -> Rounded -> a+unary' :: (forall r p . (R.Rounding r, R.Precision p) => R.Rounded r p -> a) -> RoundingMode -> Rounded -> a unary' f r a = R.reifyRounding r (\pr -> reifyRounded a (\ra -> g pr f ra))   where     g :: (R.Rounding r, R.Precision p) => proxy r -> (R.Rounded r p -> a) -> R.Rounded r p -> a     g _ h x = h x -unary'' :: (forall r k (p :: k) . (R.Rounding r, R.Precision p) => R.Rounded r p -> a) -> Rounded -> a+unary'' :: (forall r p . (R.Rounding r, R.Precision p) => R.Rounded r p -> a) -> Rounded -> a unary'' f a = unary' f R.TowardNearest a  toDouble :: RoundingMode -> Rounded -> Double@@ -391,7 +394,7 @@  type Comparison = Rounded -> Rounded -> Bool -cmp :: (forall kp (p :: kp) kq (q :: kq) . (R.Precision p, R.Precision q) => R.Rounded R.TowardNearest p -> R.Rounded R.TowardNearest q -> Bool) -> Comparison+cmp :: (forall p q . (R.Precision p, R.Precision q) => R.Rounded R.TowardNearest p -> R.Rounded R.TowardNearest q -> Bool) -> Comparison cmp f a b = reifyRounded a (\ra -> reifyRounded b (\rb -> f ra rb))  instance Eq Rounded where