hmpfr 0.3 → 0.3.1
raw patch · 10 files changed
+68/−32 lines, 10 filesdep +integer-gmpPVP ok
version bump matches the API change (PVP)
Dependencies added: integer-gmp
API changes (from Hackage documentation)
Files
- cbits/chsmpfr.c +16/−0
- cbits/chsmpfr.h +9/−0
- hmpfr.cabal +4/−2
- src/Data/Number/MPFR/Conversion.hs +4/−5
- src/Data/Number/MPFR/FFIhelper.hsc +4/−4
- src/Data/Number/MPFR/Instances/Down.hs +7/−6
- src/Data/Number/MPFR/Instances/Near.hs +7/−4
- src/Data/Number/MPFR/Instances/Up.hs +7/−4
- src/Data/Number/MPFR/Instances/Zero.hs +7/−4
- src/Data/Number/MPFR/Special.hs +3/−3
cbits/chsmpfr.c view
@@ -120,6 +120,22 @@ void mpfr_custom_move_wrap (mpfr_ptr p1, void *p2 ) { mpfr_custom_move(p1, p2); }++int mpfr_const_pi_wrap (mpfr_ptr p1, int p2) {+ return mpfr_const_pi(p1,p2);+}++int mpfr_const_log2_wrap (mpfr_ptr p1, int p2) {+ return mpfr_const_log2(p1,p2);+}++int mpfr_const_euler_wrap (mpfr_ptr p1, int p2) {+ return mpfr_const_euler(p1,p2);+}+int mpfr_const_catalan_wrap (mpfr_ptr p1, int p2) {+ return mpfr_const_catalan(p1,p2);+}+ /* intmax_t mpfr_get_sj_wrap (mpfr_ptr p1, mp_rnd_t p2) { return mpfr_get_sj(p1, p2);
cbits/chsmpfr.h view
@@ -71,3 +71,12 @@ mp_exp_t mpfr_custom_get_exp_wrap(const mpfr_ptr ) ; void mpfr_custom_move_wrap (const mpfr_ptr , void * ) ;++int mpfr_const_pi_wrap (const mpfr_ptr , int );+++int mpfr_const_log2_wrap (const mpfr_ptr , int );++int mpfr_const_euler_wrap (const mpfr_ptr , int );++int mpfr_const_catalan__wrap (const mpfr_ptr , int );
hmpfr.cabal view
@@ -1,5 +1,5 @@ name: hmpfr-version: 0.3+version: 0.3.1 synopsis: Haskell binding to MPFR library description: Haskell binding to MPFR library. This version is compatible only with 2.4.* and will not work with previous releases@@ -30,8 +30,10 @@ Library build-Depends: base > 3 && < 5- if impl(ghc >= 6.10)+ if impl(ghc >= 6.10) && impl(ghc < 6.12) build-Depends: base >= 4, integer+ if impl(ghc >= 6.12)+ build-Depends: integer-gmp Other-modules: Data.Number.MPFR.FFIhelper Data.Number.MPFR.Internal
src/Data/Number/MPFR/Conversion.hs view
@@ -102,15 +102,14 @@ else '.' : bt else head ss : '.' : let bt = (backtrim . tail) ss - in if null bt - then "0"- else bt ++ "e" ++ show (pred e)+ in (if null bt then "0" else bt) + ++ "e" ++ show (pred e) | otherwise = - head ss : '.' : + s ++ (head ss : '.' : (let bt = (backtrim . tail) ss in if null bt then "0" else bt )- ++ "e" ++ show (pred e)+ ++ "e" ++ show (pred e)) where (str, e') = mpfrToString Near n 10 d e = fromIntegral e' n = max dec 5
src/Data/Number/MPFR/FFIhelper.hsc view
@@ -571,16 +571,16 @@ mpfr_hypot :: Ptr MPFR -> Ptr MPFR -> Ptr MPFR -> CRoundMode -> IO CInt -- constants-foreign import ccall unsafe "mpfr_const_log2"+foreign import ccall unsafe "mpfr_const_log2_wrap" mpfr_const_log2 :: Ptr MPFR -> CRoundMode -> IO CInt -foreign import ccall unsafe "mpfr_const_pi"+foreign import ccall unsafe "mpfr_const_pi_wrap" mpfr_const_pi :: Ptr MPFR -> CRoundMode -> IO CInt -foreign import ccall unsafe "mpfr_const_euler"+foreign import ccall unsafe "mpfr_const_euler_wrap" mpfr_const_euler :: Ptr MPFR -> CRoundMode -> IO CInt -foreign import ccall unsafe "mpfr_const_catalan"+foreign import ccall unsafe "mpfr_const_catalan_wrap" mpfr_const_catalan :: Ptr MPFR -> CRoundMode -> IO CInt foreign import ccall unsafe "mpfr_free_cache"
src/Data/Number/MPFR/Instances/Down.hs view
@@ -34,13 +34,14 @@ import Data.Ratio -#if __GLASGOW_HASKELL__ >= 610++#if (__GLASGOW_HASKELL__ >= 610) && (__GLASGOW_HASKELL__ < 612) import GHC.Integer.Internals-import GHC.Exts hiding (Down)-#else -import GHC.Exts+#elif __GLASGOW_HASKELL__ >= 612+import GHC.Integer.GMP.Internals #endif +import qualified GHC.Exts as E instance Num MPFR where d + d' = A.add Down (maxPrec d d') d d'@@ -49,8 +50,8 @@ negate d = A.neg Down (getPrec d) d abs d = A.absD Down (getPrec d) d signum = fromInt Down minPrec . fromMaybe (-1) .sgn- fromInteger (S# i) = fromInt Down minPrec (I# i)- fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral . abs $ I# n * bitsPerIntegerLimb) i + fromInteger (S# i) = fromInt Down minPrec (E.I# i)+ fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral . abs $ E.I# n * bitsPerIntegerLimb) i instance Real MPFR where toRational d = n % 2 ^ e
src/Data/Number/MPFR/Instances/Near.hs view
@@ -34,11 +34,14 @@ import Data.Ratio -#if __GLASGOW_HASKELL__ >= 610+#if (__GLASGOW_HASKELL__ >= 610) && (__GLASGOW_HASKELL__ < 612) import GHC.Integer.Internals+#elif __GLASGOW_HASKELL__ >= 612+import GHC.Integer.GMP.Internals #endif-import GHC.Exts +import qualified GHC.Exts as E+ instance Num MPFR where d + d' = A.add Near (maxPrec d d') d d' d - d' = A.sub Near (maxPrec d d') d d'@@ -46,8 +49,8 @@ negate d = A.neg Near (getPrec d) d abs d = A.absD Near (getPrec d) d signum = fromInt Near minPrec . fromMaybe (-1) . sgn- fromInteger (S# i) = fromInt Near minPrec (I# i)- fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral . abs $ I# n * bitsPerIntegerLimb) i + fromInteger (S# i) = fromInt Near minPrec (E.I# i)+ fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral . abs $ E.I# n * bitsPerIntegerLimb) i instance Real MPFR where toRational d = n % 2 ^ e
src/Data/Number/MPFR/Instances/Up.hs view
@@ -35,11 +35,14 @@ import Data.Ratio -#if __GLASGOW_HASKELL__ >= 610+#if (__GLASGOW_HASKELL__ >= 610) && (__GLASGOW_HASKELL__ < 612) import GHC.Integer.Internals+#elif __GLASGOW_HASKELL__ >= 612+import GHC.Integer.GMP.Internals #endif-import GHC.Exts +import qualified GHC.Exts as E+ instance Num MPFR where d + d' = A.add Up (maxPrec d d') d d' d - d' = A.sub Up (maxPrec d d') d d'@@ -47,8 +50,8 @@ negate d = A.neg Up (getPrec d) d abs d = A.absD Up (getPrec d) d signum = fromInt Up minPrec . fromMaybe (-1) . sgn- fromInteger (S# i) = fromInt Up minPrec (I# i)- fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral . abs $ I# n * bitsPerIntegerLimb) i + fromInteger (S# i) = fromInt Up minPrec (E.I# i)+ fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral . abs $ E.I# n * bitsPerIntegerLimb) i instance Real MPFR where toRational d = n % 2 ^ e
src/Data/Number/MPFR/Instances/Zero.hs view
@@ -34,11 +34,14 @@ import Data.Ratio -#if __GLASGOW_HASKELL__ >= 610+#if (__GLASGOW_HASKELL__ >= 610) && (__GLASGOW_HASKELL__ < 612) import GHC.Integer.Internals+#elif __GLASGOW_HASKELL__ >= 612+import GHC.Integer.GMP.Internals #endif-import GHC.Exts +import qualified GHC.Exts as E+ instance Num MPFR where d + d' = A.add Zero (maxPrec d d') d d' d - d' = A.sub Zero (maxPrec d d') d d'@@ -46,8 +49,8 @@ negate d = A.neg Zero (getPrec d) d abs d = A.absD Zero (getPrec d) d signum = fromInt Zero minPrec . fromMaybe (-1) . sgn- fromInteger (S# i) = fromInt Zero minPrec (I# i)- fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral . abs $ I# n * bitsPerIntegerLimb) i + fromInteger (S# i) = fromInt Zero minPrec (E.I# i)+ fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral . abs $ E.I# n * bitsPerIntegerLimb) i instance Real MPFR where toRational d = n % 2 ^ e
src/Data/Number/MPFR/Special.hs view
@@ -180,13 +180,13 @@ pi r = fst . pi_ r log2c :: RoundMode -> Precision -> MPFR-log2c r = fst . pi_ r+log2c r = fst . log2c_ r euler :: RoundMode -> Precision -> MPFR-euler r = fst . pi_ r+euler r = fst . euler_ r catalan :: RoundMode -> Precision -> MPFR-catalan r = fst . pi_ r+catalan r = fst . catalan_ r log_ :: RoundMode -> Precision -> MPFR -> (MPFR, Int)