packages feed

hmpfr 0.1.3 → 0.2

raw patch · 17 files changed

+492/−307 lines, 17 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Number.MPFR.Arithmetic: addd :: RoundMode -> Precision -> MPFR -> Double -> MPFR
+ Data.Number.MPFR.Arithmetic: addd_ :: RoundMode -> Precision -> MPFR -> Double -> (MPFR, Int)
+ Data.Number.MPFR.Arithmetic: ddiv :: RoundMode -> Precision -> Double -> MPFR -> MPFR
+ Data.Number.MPFR.Arithmetic: ddiv_ :: RoundMode -> Precision -> Double -> MPFR -> (MPFR, Int)
+ Data.Number.MPFR.Arithmetic: divd :: RoundMode -> Precision -> MPFR -> Double -> MPFR
+ Data.Number.MPFR.Arithmetic: divd_ :: RoundMode -> Precision -> MPFR -> Double -> (MPFR, Int)
+ Data.Number.MPFR.Arithmetic: dsub :: RoundMode -> Precision -> Double -> MPFR -> MPFR
+ Data.Number.MPFR.Arithmetic: dsub_ :: RoundMode -> Precision -> Double -> MPFR -> (MPFR, Int)
+ Data.Number.MPFR.Arithmetic: muld :: RoundMode -> Precision -> MPFR -> Double -> MPFR
+ Data.Number.MPFR.Arithmetic: muld_ :: RoundMode -> Precision -> MPFR -> Double -> (MPFR, Int)
+ Data.Number.MPFR.Arithmetic: recSqrt :: RoundMode -> Precision -> MPFR -> MPFR
+ Data.Number.MPFR.Arithmetic: recSqrt_ :: RoundMode -> Precision -> MPFR -> (MPFR, Int)
+ Data.Number.MPFR.Arithmetic: subd :: RoundMode -> Precision -> MPFR -> Double -> MPFR
+ Data.Number.MPFR.Arithmetic: subd_ :: RoundMode -> Precision -> MPFR -> Double -> (MPFR, Int)
+ Data.Number.MPFR.Integer: fmod :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR
+ Data.Number.MPFR.Integer: fmod_ :: RoundMode -> Precision -> MPFR -> MPFR -> (MPFR, Int)
+ Data.Number.MPFR.Integer: modf :: RoundMode -> Precision -> Precision -> MPFR -> (MPFR, MPFR)
+ Data.Number.MPFR.Integer: modf_ :: RoundMode -> Precision -> Precision -> MPFR -> (MPFR, MPFR, Int)
+ Data.Number.MPFR.Special: li2 :: RoundMode -> Precision -> MPFR -> MPFR
+ Data.Number.MPFR.Special: li2_ :: RoundMode -> Precision -> MPFR -> (MPFR, Int)
+ Data.Number.MPFR.Special: sinhcosh :: RoundMode -> Precision -> Precision -> MPFR -> (MPFR, MPFR)
+ Data.Number.MPFR.Special: sinhcosh_ :: RoundMode -> Precision -> Precision -> MPFR -> (MPFR, MPFR, Int)

Files

Data/Number/MPFR.hs view
@@ -95,7 +95,7 @@     d * d'        = mul Zero (getPrec d + getPrec d') d d'     negate d      = neg Zero (getPrec d) d     abs d         = absD Zero (getPrec d) d-    signum d      = fromInt Zero minPrec (fromMaybe (-1) (sgn d))+    signum        = fromInt Zero minPrec . fromMaybe (-1) . sgn     fromInteger (S# i) = fromInt Zero minPrec (I# i)     fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral $ I# n * bitsPerIntegerLimb) i  
Data/Number/MPFR/Arithmetic.hs view
@@ -20,104 +20,125 @@  import Prelude hiding(isNaN) -add           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-add r p d1 d2 = fst $ add_ r p d1 d2+add        :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+add r p d1 = fst . add_ r p d1       -addw          :: RoundMode -> Precision -> MPFR -> Word -> MPFR-addw r p d1 d = fst $ addw_ r p d1 d +addw        :: RoundMode -> Precision -> MPFR -> Word -> MPFR+addw r p d1 = fst . addw_ r p d1 -addi          :: RoundMode -> Precision -> MPFR -> Int -> MPFR-addi r p d1 d = fst $ addi_ r p d1 d -      -sub           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-sub r p d1 d2 = fst $ sub_ r p d1 d2+addi        :: RoundMode -> Precision -> MPFR -> Int -> MPFR+addi r p d1 = fst . addi_ r p d1++addd        :: RoundMode -> Precision -> MPFR -> Double -> MPFR+addd r p d1 = fst . addd_ r p d1++sub        :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+sub r p d1 = fst . sub_ r p d1       -subw          :: RoundMode -> Precision -> MPFR -> Word -> MPFR-subw r p d1 d = fst $ subw_ r p d1 d +subw        :: RoundMode -> Precision -> MPFR -> Word -> MPFR+subw r p d1 = fst . subw_ r p d1       -subi          :: RoundMode -> Precision -> MPFR -> Int -> MPFR-subi r p d1 d = fst $ subi_ r p d1 d +subi        :: RoundMode -> Precision -> MPFR -> Int -> MPFR+subi r p d1 = fst . subi_ r p d1++subd        :: RoundMode -> Precision -> MPFR -> Double -> MPFR+subd r p d1 = fst . subd_ r p d1       -wsub          :: RoundMode -> Precision -> Word -> MPFR -> MPFR-wsub r p d d1 = fst $ wsub_ r p d d1 +wsub       :: RoundMode -> Precision -> Word -> MPFR -> MPFR+wsub r p d = fst . wsub_ r p d       -isub          :: RoundMode -> Precision -> Int -> MPFR -> MPFR-isub r p d d1 = fst $ isub_ r p d d1 +isub       :: RoundMode -> Precision -> Int -> MPFR -> MPFR+isub r p d = fst . isub_ r p d++dsub       :: RoundMode -> Precision -> Double -> MPFR -> MPFR+dsub r p d = fst . dsub_ r p d       -mul           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-mul r p d1 d2 = fst $ mul_ r p d1 d2+mul        :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+mul r p d1 = fst . mul_ r p d1 -mulw          :: RoundMode -> Precision -> MPFR -> Word -> MPFR-mulw r p d1 d = fst $ mulw_ r p d1 d +mulw        :: RoundMode -> Precision -> MPFR -> Word -> MPFR+mulw r p d1 = fst . mulw_ r p d1       -muli          :: RoundMode -> Precision -> MPFR -> Int -> MPFR-muli r p d1 d = fst $ muli_ r p d1 d +muli        :: RoundMode -> Precision -> MPFR -> Int -> MPFR+muli r p d1 = fst . muli_ r p d1++muld        :: RoundMode -> Precision -> MPFR -> Double -> MPFR+muld r p d1 = fst . muld_ r p d1       -sqr       :: RoundMode -> Precision -> MPFR -> MPFR -sqr r p d = fst $ sqr_ r p d+sqr     :: RoundMode -> Precision -> MPFR -> MPFR +sqr r p = fst . sqr_ r p       -div           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-div r p d1 d2 = fst $ div_ r p d1 d2+div        :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+div r p d1 = fst . div_ r p d1       -divw          :: RoundMode -> Precision -> MPFR -> Word -> MPFR-divw r p d1 d = fst $ divw_ r p d1 d +divw        :: RoundMode -> Precision -> MPFR -> Word -> MPFR+divw r p d1 = fst . divw_ r p d1       -divi          :: RoundMode -> Precision -> MPFR -> Int -> MPFR-divi r p d1 d = fst $ divi_ r p d1 d +divi        :: RoundMode -> Precision -> MPFR -> Int -> MPFR+divi r p d1 = fst . divi_ r p d1++divd        :: RoundMode -> Precision -> MPFR -> Double -> MPFR+divd r p d1 = fst . divd_ r p d1       -wdiv          :: RoundMode -> Precision -> Word -> MPFR -> MPFR-wdiv r p d d1 = fst $ wdiv_ r p d d1 +wdiv       :: RoundMode -> Precision -> Word -> MPFR -> MPFR+wdiv r p d = fst . wdiv_ r p d       -idiv          :: RoundMode -> Precision -> Int -> MPFR -> MPFR-idiv r p d d1 = fst $ idiv_ r p d d1 +idiv       :: RoundMode -> Precision -> Int -> MPFR -> MPFR+idiv r p d = fst . idiv_ r p d++ddiv       :: RoundMode -> Precision -> Double -> MPFR -> MPFR+ddiv r p d = fst . ddiv_ r p d       -sqrt       :: RoundMode -> Precision -> MPFR -> MPFR-sqrt r p d = fst $ sqrt_ r p d+sqrt     :: RoundMode -> Precision -> MPFR -> MPFR+sqrt r p = fst . sqrt_ r p       -sqrtw       :: RoundMode -> Precision -> Word -> MPFR-sqrtw r p d = fst $ sqrtw_ r p d+sqrtw     :: RoundMode -> Precision -> Word -> MPFR+sqrtw r p = fst . sqrtw_ r p++recSqrt     :: RoundMode -> Precision -> MPFR -> MPFR+recSqrt r p = fst . recSqrt_ r p       -cbrt       :: RoundMode -> Precision -> MPFR -> MPFR-cbrt r p d = fst $ cbrt_ r p d+cbrt     :: RoundMode -> Precision -> MPFR -> MPFR+cbrt r p = fst . cbrt_ r p       -root         :: RoundMode -> Precision -> MPFR -> Word -> MPFR-root r p d n = fst $ root_ r p d n+root       :: RoundMode -> Precision -> MPFR -> Word -> MPFR+root r p d = fst . root_ r p d       -pow           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-pow r p d1 d2 = fst $ pow_ r p d1 d2 +pow        :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+pow r p d1 = fst . pow_ r p d1       -poww           :: RoundMode -> Precision -> MPFR -> Word -> MPFR -poww r p d1 d2 = fst $ poww_ r p d1 d2+poww        :: RoundMode -> Precision -> MPFR -> Word -> MPFR +poww r p d1 = fst . poww_ r p d1       -powi           :: RoundMode -> Precision -> MPFR -> Int -> MPFR -powi r p d1 d2 = fst $ powi_ r p d1 d2+powi        :: RoundMode -> Precision -> MPFR -> Int -> MPFR +powi r p d1 = fst . powi_ r p d1       -wpoww           :: RoundMode -> Precision -> Word -> Word -> MPFR -wpoww r p d1 d2 = fst $ wpoww_ r p d1 d2+wpoww       :: RoundMode -> Precision -> Word -> Word -> MPFR +wpoww r p d = fst . wpoww_ r p d       -wpow           :: RoundMode -> Precision -> Word -> MPFR -> MPFR -wpow r p d1 d2 = fst $ wpow_ r p d1 d2+wpow        :: RoundMode -> Precision -> Word -> MPFR -> MPFR +wpow r p d1 = fst . wpow_ r p d1       -neg       :: RoundMode -> Precision -> MPFR -> MPFR-neg r p d = fst $ neg_ r p d+neg     :: RoundMode -> Precision -> MPFR -> MPFR+neg r p = fst . neg_ r p       -absD      :: RoundMode -> Precision -> MPFR -> MPFR -absD r p d = fst $ absD_ r p d+absD     :: RoundMode -> Precision -> MPFR -> MPFR +absD r p = fst . absD_ r p       -dim           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-dim r p d1 d2 = fst $ dim_ r p d1 d2 +dim        :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+dim r p d1 = fst . dim_ r p d1        -mul2w           :: RoundMode -> Precision -> MPFR -> Word -> MPFR-mul2w r p d1 d2 = fst $ mul2w_ r p d1 d2+mul2w        :: RoundMode -> Precision -> MPFR -> Word -> MPFR+mul2w r p d1 = fst . mul2w_ r p d1       -mul2i          :: RoundMode -> Precision -> MPFR -> Int -> MPFR-mul2i r p d1 d2 = fst $ mul2i_ r p d1 d2+mul2i        :: RoundMode -> Precision -> MPFR -> Int -> MPFR+mul2i r p d1 = fst . mul2i_ r p d1       -div2w          :: RoundMode -> Precision -> MPFR -> Word -> MPFR-div2w r p d1 d2 = fst $ div2w_ r p d1 d2+div2w        :: RoundMode -> Precision -> MPFR -> Word -> MPFR+div2w r p d1 = fst . div2w_ r p d1       -div2i          :: RoundMode -> Precision -> MPFR -> Int -> MPFR-div2i r p d1 d2 = fst $ div2i_ r p d1 d2+div2i        :: RoundMode -> Precision -> MPFR -> Int -> MPFR+div2i r p d1 = fst . div2i_ r p d1        add_           :: RoundMode -> Precision -> MPFR -> MPFR -> (MPFR,Int) add_ r p d1 d2 =  withMPFRsBA r p d1 d2 mpfr_add@@ -127,6 +148,9 @@  addi_          :: RoundMode -> Precision -> MPFR -> Int -> (MPFR, Int) addi_ r p d1 d = withMPFRBAsi r p d1 (fromIntegral d) mpfr_add_si++addd_          :: RoundMode -> Precision -> MPFR -> Double -> (MPFR, Int)+addd_ r p d1 d = withMPFRBAd r p d1 (realToFrac d) mpfr_add_d        sub_           :: RoundMode -> Precision -> MPFR -> MPFR -> (MPFR,Int) sub_ r p d1 d2 =  withMPFRsBA r p d1 d2 mpfr_sub@@ -136,6 +160,9 @@        subi_          :: RoundMode -> Precision -> MPFR -> Int -> (MPFR, Int) subi_ r p d1 d = withMPFRBAsi r p d1 (fromIntegral d) mpfr_sub_si++subd_          :: RoundMode -> Precision -> MPFR -> Double -> (MPFR, Int)+subd_ r p d1 d = withMPFRBAd r p d1 (realToFrac d) mpfr_sub_d        wsub_          :: RoundMode -> Precision -> Word -> MPFR -> (MPFR, Int) wsub_ r p d d1 = withMPFRBAiu r p (fromIntegral d) d1 mpfr_ui_sub@@ -143,6 +170,10 @@ isub_          :: RoundMode -> Precision -> Int -> MPFR -> (MPFR, Int) isub_ r p d d1 = withMPFRBAis r p (fromIntegral d) d1 mpfr_si_sub +dsub_          :: RoundMode -> Precision -> Double -> MPFR -> (MPFR, Int)+dsub_ r p d d1 = withMPFRBAd' r p (realToFrac d) d1 mpfr_d_sub++ mul_           :: RoundMode -> Precision -> MPFR -> MPFR -> (MPFR,Int) mul_ r p d1 d2 =  withMPFRsBA r p d1 d2 mpfr_mul       @@ -151,6 +182,9 @@        muli_          :: RoundMode -> Precision -> MPFR -> Int -> (MPFR, Int) muli_ r p d1 d = withMPFRBAsi r p d1 (fromIntegral d) mpfr_mul_si++muld_          :: RoundMode -> Precision -> MPFR -> Double -> (MPFR, Int)+muld_ r p d1 d = withMPFRBAd r p d1 (realToFrac d) mpfr_mul_d        sqr_       :: RoundMode -> Precision -> MPFR -> (MPFR, Int) sqr_ r p d = withMPFR r p d mpfr_sqr@@ -163,18 +197,27 @@        divi_          :: RoundMode -> Precision -> MPFR -> Int -> (MPFR, Int) divi_ r p d1 d = withMPFRBAsi r p d1 (fromIntegral d) mpfr_div_si++divd_          :: RoundMode -> Precision -> MPFR -> Double -> (MPFR, Int)+divd_ r p d1 d = withMPFRBAd r p d1 (realToFrac d) mpfr_div_d        wdiv_          :: RoundMode -> Precision -> Word -> MPFR -> (MPFR, Int) wdiv_ r p d d1 = withMPFRBAiu r p (fromIntegral d) d1 mpfr_ui_div        idiv_          :: RoundMode -> Precision -> Int -> MPFR -> (MPFR, Int) idiv_ r p d d1 = withMPFRBAis r p (fromIntegral d) d1 mpfr_si_div++ddiv_          :: RoundMode -> Precision -> Double -> MPFR -> (MPFR, Int)+ddiv_ r p d d1 = withMPFRBAd' r p (realToFrac d) d1 mpfr_d_div        sqrt_       :: RoundMode -> Precision -> MPFR -> (MPFR, Int) sqrt_ r p d = withMPFR r p d mpfr_sqrt        sqrtw_       :: RoundMode -> Precision -> Word -> (MPFR, Int) sqrtw_ r p d = withMPFRUI r p d mpfr_sqrt_ui++recSqrt_       :: RoundMode -> Precision -> MPFR -> (MPFR, Int)+recSqrt_ r p d = withMPFR r p d mpfr_rec_sqrt        cbrt_       :: RoundMode -> Precision -> MPFR -> (MPFR, Int) cbrt_ r p d = withMPFR r p d mpfr_cbrt@@ -193,7 +236,7 @@        wpoww_          :: RoundMode -> Precision -> Word -> Word -> (MPFR , Int) wpoww_ r p d1 d2 = unsafePerformIO go-    where go = do withDummy p $ \p1 -> do +    where go = withDummy p $ \p1 ->                      mpfr_ui_pow_ui p1 (fromIntegral d1) (fromIntegral d2) ((fromIntegral . fromEnum) r)          wpow_           :: RoundMode -> Precision -> Word -> MPFR -> (MPFR , Int)
Data/Number/MPFR/Assignment.hs view
@@ -21,68 +21,68 @@  import Data.Number.MPFR.Arithmetic -set           :: RoundMode -> Precision -> MPFR -> MPFR-set r p d = fst $ set_ r p d+set     :: RoundMode -> Precision -> MPFR -> MPFR+set r p = fst . set_ r p  set_         :: RoundMode -> Precision -> MPFR -> (MPFR, Int) set_ r p mp1 = unsafePerformIO go-    where go = do withDummy p $ \p1 -> do-                    with mp1 $ \p2 -> do -                      mpfr_set p1 p2 ((fromIntegral . fromEnum) r) +    where go = withDummy p $ \p1 ->+                 with mp1 $ \p2 -> +                   mpfr_set p1 p2 ((fromIntegral . fromEnum) r)  -fromWord       :: RoundMode -> Precision -> Word -> MPFR-fromWord r p d = fst $ fromWord_ r p d+fromWord     :: RoundMode -> Precision -> Word -> MPFR+fromWord r p = fst . fromWord_ r p -fromInt       :: RoundMode -> Precision -> Int -> MPFR-fromInt r p d = fst $ fromInt_ r p d+fromInt     :: RoundMode -> Precision -> Int -> MPFR+fromInt r p = fst . fromInt_ r p -fromDouble       :: RoundMode -> Precision -> Double -> MPFR-fromDouble r p d = fst $ fromDouble_ r p d+fromDouble     :: RoundMode -> Precision -> Double -> MPFR+fromDouble r p = fst . fromDouble_ r p  fromWord_       :: RoundMode -> Precision -> Word -> (MPFR, Int) fromWord_ r p d = unsafePerformIO go-    where go = do withDummy p $ \p1 -> do -                    mpfr_set_ui p1 (fromIntegral d) ((fromIntegral . fromEnum) r)+    where go = withDummy p $ \p1 ->+                   mpfr_set_ui p1 (fromIntegral d) ((fromIntegral . fromEnum) r)  fromInt_       :: RoundMode -> Precision -> Int -> (MPFR, Int) fromInt_ r p d = unsafePerformIO go-    where go = do withDummy p $ \p1 -> do-                    mpfr_set_si p1 (fromIntegral d) ((fromIntegral . fromEnum) r)+    where go = withDummy p $ \p1 ->+                   mpfr_set_si p1 (fromIntegral d) ((fromIntegral . fromEnum) r)                      fromDouble_       :: RoundMode -> Precision -> Double -> (MPFR, Int) fromDouble_ r p d = unsafePerformIO go-    where go = do withDummy p $ \p1 -> do -                    mpfr_set_d p1 (realToFrac d) ((fromIntegral . fromEnum) r)+    where go = withDummy p $ \p1 ->+                   mpfr_set_d p1 (realToFrac d) ((fromIntegral . fromEnum) r)                        -- x * 2 ^ y int2w         :: RoundMode -> Precision -> Word -> Int -> MPFR-int2w r p i e = fst $ int2w_ r p i e+int2w r p i = fst . int2w_ r p i  int2i         :: RoundMode -> Precision -> Int -> Int -> MPFR-int2i r p i e = fst $ int2i_ r p i e+int2i r p i = fst . int2i_ r p i  int2w_         :: RoundMode -> Precision -> Word -> Int -> (MPFR, Int) int2w_ r p i e = unsafePerformIO go-    where go = do withDummy p $ \p1 -> do-                    mpfr_set_ui_2exp p1 (fromIntegral i) (fromIntegral e) ((fromIntegral . fromEnum) r)+    where go = withDummy p $ \p1 -> +                   mpfr_set_ui_2exp p1 (fromIntegral i) (fromIntegral e) ((fromIntegral . fromEnum) r)                      int2i_         :: RoundMode -> Precision -> Int -> Int -> (MPFR, Int) int2i_ r p i e = unsafePerformIO go-    where go = do withDummy p $ \p1 -> do-                    mpfr_set_si_2exp p1 (fromIntegral i) (fromIntegral e) ((fromIntegral . fromEnum) r)+    where go = withDummy p $ \p1 ->+                   mpfr_set_si_2exp p1 (fromIntegral i) (fromIntegral e) ((fromIntegral . fromEnum) r)                     -stringToMPFR         :: RoundMode -> Precision -                       -> Word -- ^ Base -                       -> String -> MPFR-stringToMPFR r p b d = fst $ stringToMPFR_ r p b d+stringToMPFR       :: RoundMode -> Precision +                     -> Word -- ^ Base +                     -> String -> MPFR+stringToMPFR r p b = fst . stringToMPFR_ r p b  stringToMPFR_         :: RoundMode -> Precision                         -> Word -- ^ Base                         -> String -> (MPFR, Int) stringToMPFR_ r p b d = unsafePerformIO go-    where go = do withDummy p $ \p1 -> do -                    withCString d $ \p2 -> do -                      mpfr_set_str p1 p2 (fromIntegral b) ((fromIntegral . fromEnum) r) +    where go = withDummy p $ \p1 ->+                   withCString d $ \p2 ->+                       mpfr_set_str p1 p2 (fromIntegral b) ((fromIntegral . fromEnum) r)   strtofr         :: RoundMode -> Precision                 -> Word -- ^ base@@ -98,7 +98,7 @@                   fp <- mallocForeignPtrBytes (fromIntegral ls)                   alloca $ \p1 -> do                      pokeDummy p1 fp p-                    withCString d $ \p2 -> do+                    withCString d $ \p2 ->                       alloca $ \p3 -> do                         r3 <- mpfr_strtofr p1 p2 p3 (fromIntegral b) ((fromIntegral . fromEnum) r)                         p3' <- peek p3@@ -125,8 +125,8 @@                     mpfr_set_nan p1                     peekP p1 fp -fromIntegerA       :: RoundMode -> Precision -> Integer -> MPFR-fromIntegerA r p d = stringToMPFR r p 10 (show d)+fromIntegerA     :: RoundMode -> Precision -> Integer -> MPFR+fromIntegerA r p = stringToMPFR r p 10 . show   compose             :: RoundMode -> Precision -> (Integer, Int) -> MPFR  compose r p (i, ii) = div2i r p (fromIntegerA r p i) ii
Data/Number/MPFR/Comparison.hs view
@@ -113,24 +113,24 @@             Just x -> Just (pred . fromEnum $ x) -} -- TODO Maybe Bool????-greater       :: MPFR -> MPFR -> Bool-greater d1 d2 = maybe False (== GT) (cmp d1 d2) --withMPFRBB d1 d2 mpfr_greater_p /= 0+greater    :: MPFR -> MPFR -> Bool+greater d1 = maybe False (== GT) . cmp d1 --withMPFRBB d1 d2 mpfr_greater_p /= 0 -greatereq       :: MPFR -> MPFR -> Bool-greatereq d1 d2 = maybe False (/= LT) (cmp d1 d2) --withMPFRBB d1 d2 mpfr_greaterequal_p /= 0+greatereq    :: MPFR -> MPFR -> Bool+greatereq d1 = maybe False (/= LT) . cmp d1 --withMPFRBB d1 d2 mpfr_greaterequal_p /= 0 -less       :: MPFR -> MPFR -> Bool-less d1 d2 = maybe False (== LT) (cmp d1 d2) --withMPFRBB d1 d2 mpfr_less_p /= 0+less    :: MPFR -> MPFR -> Bool+less d1 = maybe False (== LT) . cmp d1 --withMPFRBB d1 d2 mpfr_less_p /= 0 -lesseq       :: MPFR -> MPFR -> Bool-lesseq d1 d2 = maybe False (/= GT) (cmp d1 d2) --withMPFRBB d1 d2 mpfr_lessequal_p /= 0+lesseq    :: MPFR -> MPFR -> Bool+lesseq d1 = maybe False (/= GT) . cmp d1  --withMPFRBB d1 d2 mpfr_lessequal_p /= 0  lessgreater       :: MPFR -> MPFR -> Maybe Bool lessgreater d1 d2 = if isNaN d1 || isNaN d2 then Nothing                        else Just (withMPFRBB d1 d2 mpfr_lessgreater_p /= 0) -equal       :: MPFR -> MPFR -> Bool-equal d1 d2 = maybe False (== EQ) (cmp d1 d2) --withMPFRBB d1 d2 mpfr_equal_p /= 0+equal    :: MPFR -> MPFR -> Bool+equal d1 = maybe False (== EQ) . cmp d1 --withMPFRBB d1 d2 mpfr_equal_p /= 0  unordered       :: MPFR -> MPFR -> Maybe Bool unordered d1 d2 = if isNaN d1 || isNaN d2 then Nothing @@ -141,11 +141,11 @@     (==) = equal  instance Ord MPFR where-    compare d d' = fromMaybe GT (cmp d d')-    (<)          = less-    (<=)         = lesseq-    (>)          = greater-    (>=)         = greatereq+    compare d = fromMaybe GT . cmp d+    (<)       = less+    (<=)      = lesseq+    (>)       = greater+    (>=)      = greatereq --    max d d'     = maxD Zero (maxPrec d d') d d' --    min d d'     = minD Zero (maxPrec d d') d d'                     
Data/Number/MPFR/Conversion.hs view
@@ -28,11 +28,11 @@  toDouble2exp     :: RoundMode -> MPFR -> (Double, Int) toDouble2exp r mp1 = unsafePerformIO go -    where go = do with mp1 $ \p1 -> do-                    alloca $ \p2 -> do-                      r1 <- mpfr_get_d_2exp p2 p1 ((fromIntegral . fromEnum) r)-                      r2 <- peek p2-                      return (realToFrac r1, fromIntegral r2)+    where go = with mp1 $ \p1 ->+                   alloca $ \p2 -> do+                       r1 <- mpfr_get_d_2exp p2 p1 ((fromIntegral . fromEnum) r)+                       r2 <- peek p2+                       return (realToFrac r1, fromIntegral r2)                        toInt     :: RoundMode -> MPFR -> Int toInt r mp1 = (fromIntegral . unsafePerformIO) go@@ -48,7 +48,7 @@                    -> Word -- ^ base                    -> MPFR -> (String, Exp) mpfrToString r n b mp1 = unsafePerformIO go -    where go = with mp1 $ \p1 -> do+    where go = with mp1 $ \p1 ->                  alloca $ \p2 -> do                      p3 <- mpfr_get_str nullPtr p2 (fromIntegral b) (fromIntegral n) p1 ((fromIntegral . fromEnum) r)                      r1 <- peekCString p3 @@ -86,18 +86,24 @@ -- | Output a string in base 10 rounded to Near in exponential form. toStringExp       :: Word -- ^ number of digits                   -> MPFR -> String-toStringExp dec d = -    if isInfixOf "NaN" ss then "NaN"-       else if isInfixOf "Inf" ss then s ++ "Infinity"-               else s ++ case e > 0 of-                           True  -> case Prelude.floor (logBase 10 2 * fromIntegral (getExp d) :: Double) > dec  of-                                      False -> take e ss ++ let bt = backtrim (drop e ss) in if null bt then "" else "." ++ bt-                                      True  -> head ss : "." ++ let bt = (backtrim . tail) ss in if null bt then "0"-                                                                                                   else bt ++ "e" ++ show (pred e)-                           False -> head ss : "." ++ (let bt = (backtrim . tail) ss in-                                                     if null bt then "0" -                                                       else bt )-                                                  ++ "e" ++ show (pred e)+toStringExp dec d | isInfixOf "NaN" ss = "NaN"+                  | isInfixOf "Inf" ss = s ++ "Infinity"+                  | otherwise          = +                      s ++ case e > 0 of+                             True  -> case Prelude.floor prec > dec  of+                                        False -> take e ss ++ +                                                 let bt = backtrim (drop e ss)+                                                 in if null bt then "" +                                                    else '.' : bt+                                        True  -> head ss : '.' :+                                                 let bt = (backtrim . tail) ss +                                                 in if null bt then "0"+                                                    else bt ++ "e" ++ show (pred e)+                             False -> head ss : '.' : +                                      (let bt = (backtrim . tail) ss in+                                       if null bt then "0" +                                       else bt )+                                      ++ "e" ++ show (pred e)                     where (str, e') = mpfrToString Near n 10 d                           e = fromIntegral e'                           n        = max dec 5@@ -105,20 +111,27 @@                                       '-' -> ("-", tail str)                                       _   -> ("" , str)                           backtrim = reverse . dropWhile (== '0') . reverse +                          prec = logBase 10 2 * fromIntegral (getExp d) :: Double  -- | Output a string in base 10 rounded to Near. The difference from @toStringExp@ is that -- it won't output in exponential form if it is sensible to do so. toString       :: Word -> MPFR -> String-toString dec d =-    if isInfixOf "NaN" ss then "NaN"-       else if isInfixOf "Inf" ss then s ++ "Infinity"-             else s ++ case compare 0 e of-                         LT -> take e ss ++ (let bt = all (== '0') (drop e ss) in if bt then "" else '.' : (drop e ss))-                               ++ (if fromIntegral n - e < 0 then "e" ++ show (e - fromIntegral n) else "")-                         GT -> let ee = fromIntegral dec + e in -                               if ee <= 0 then "0" else -                                   head ss : "." ++ (backtrim . tail . take ee) ss ++ "e" ++ show (pred e)-                         EQ -> "0." ++ let bt = all (== '0') ss in if bt then "0" else ss+toString dec d | isInfixOf "NaN" ss = "NaN"+               | isInfixOf "Inf" ss = s ++ "Infinity"+               | otherwise          = +                   s ++ case compare 0 e of+                          LT -> take e ss ++ +                                (let bt = all (== '0') (drop e ss) +                                 in if bt then "" else '.' : drop e ss)+                                ++ (if fromIntegral n - e < 0 +                                    then 'e' : show (e - fromIntegral n) +                                    else "")+                          GT -> let ee = fromIntegral dec + e in +                                if ee <= 0 then "0" else +                                   head ss : '.' : (backtrim . tail . take ee) ss+                                            ++ "e" ++ show (pred e)+                          EQ -> "0." ++ let bt = all (== '0') ss +                                        in if bt then "0" else ss                   where (str, e') = mpfrToString Near n 10 d                         n        = max dec 5                         e = fromIntegral e'
Data/Number/MPFR/Down.hs view
@@ -45,7 +45,7 @@     d * d'        = mul Down (maxPrec d d') d d'     negate d      = neg Down (getPrec d) d     abs d         = absD Down (getPrec d) d-    signum d      = fromInt Down minPrec (fromMaybe (-1) (sgn d))+    signum        = fromInt Down minPrec . fromMaybe (-1) .sgn     fromInteger (S# i) = fromInt Down minPrec (I# i)     fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral $ I# n * bitsPerIntegerLimb) i  @@ -57,7 +57,7 @@  instance Fractional MPFR where     d / d'         = Data.Number.MPFR.Base.div Down (maxPrec d d') d d'-    fromRational r = (fromInteger n) / (fromInteger d)+    fromRational r = fromInteger n / fromInteger d         where n = numerator r               d = denominator r     recip d        = one / d
Data/Number/MPFR/FFIhelper.hsc view
@@ -44,7 +44,7 @@  instance Storable MPFR where     sizeOf _ = #size __mpfr_struct-    alignment _ = (undefined :: Int)+    alignment _ = alignment (undefined :: #{type mpfr_prec_t})     peek = error "MPFR.peek: Not needed and not applicable"     poke p (MP prec s e fp) = do #{poke __mpfr_struct, _mpfr_prec} p prec                                  #{poke __mpfr_struct, _mpfr_sign} p s @@ -238,6 +238,9 @@ foreign import ccall unsafe "mpfr_add_si"         mpfr_add_si :: Ptr MPFR -> Ptr MPFR -> CLong -> CRoundMode -> IO CInt +foreign import ccall unsafe "mpfr_add_d"+        mpfr_add_d :: Ptr MPFR -> Ptr MPFR -> CDouble -> CRoundMode -> IO CInt+ -- TODO add_z, add_q  foreign import ccall unsafe "mpfr_sub"@@ -255,6 +258,12 @@ foreign import ccall unsafe "mpfr_sub_si"         mpfr_sub_si :: Ptr MPFR -> Ptr MPFR -> CLong -> CRoundMode -> IO CInt +foreign import ccall unsafe "mpfr_sub_d"+        mpfr_sub_d :: Ptr MPFR -> Ptr MPFR -> CDouble -> CRoundMode -> IO CInt++foreign import ccall unsafe "mpfr_d_sub"+        mpfr_d_sub :: Ptr MPFR -> CDouble -> Ptr MPFR -> CRoundMode -> IO CInt+ --TODO sub_z, sub_q  foreign import ccall unsafe "mpfr_mul"@@ -266,6 +275,9 @@ foreign import ccall unsafe "mpfr_mul_si"         mpfr_mul_si :: Ptr MPFR -> Ptr MPFR -> CLong -> CRoundMode -> IO CInt +foreign import ccall unsafe "mpfr_mul_d"+        mpfr_mul_d:: Ptr MPFR -> Ptr MPFR -> CDouble -> CRoundMode -> IO CInt+ --TODO mul_z, mul_q  foreign import ccall unsafe "mpfr_sqr"@@ -286,6 +298,13 @@ foreign import ccall unsafe "mpfr_div_si"         mpfr_div_si :: Ptr MPFR -> Ptr MPFR -> CLong -> CRoundMode -> IO CInt +foreign import ccall unsafe "mpfr_div_d"+        mpfr_div_d :: Ptr MPFR -> Ptr MPFR -> CDouble -> CRoundMode -> IO CInt++foreign import ccall unsafe "mpfr_d_div"+        mpfr_d_div :: Ptr MPFR -> CDouble -> Ptr MPFR -> CRoundMode -> IO CInt++ -- TODO div_z, div_q  foreign import ccall unsafe "mpfr_sqrt"@@ -294,6 +313,9 @@ foreign import ccall unsafe "mpfr_sqrt_ui"         mpfr_sqrt_ui :: Ptr MPFR -> CULong -> CRoundMode -> IO CInt +foreign import ccall unsafe "mpfr_rec_sqrt"+        mpfr_rec_sqrt :: Ptr MPFR -> Ptr MPFR -> CRoundMode -> IO CInt+ foreign import ccall unsafe "mpfr_cbrt"         mpfr_cbrt :: Ptr MPFR -> Ptr MPFR -> CRoundMode -> IO CInt @@ -467,6 +489,8 @@ foreign import ccall unsafe "mpfr_tanh"         mpfr_tanh :: Ptr MPFR -> Ptr MPFR ->  CRoundMode -> IO CInt +foreign import ccall unsafe "mpfr_sinh_cosh"+        mpfr_sinh_cosh :: Ptr MPFR -> Ptr MPFR -> Ptr MPFR -> CRoundMode -> IO CInt  foreign import ccall unsafe "mpfr_sech"         mpfr_sech :: Ptr MPFR -> Ptr MPFR ->  CRoundMode -> IO CInt@@ -495,6 +519,9 @@ foreign import ccall unsafe "mpfr_expm1"         mpfr_expm1 :: Ptr MPFR -> Ptr MPFR ->  CRoundMode -> IO CInt +foreign import ccall unsafe "mpfr_li2"+        mpfr_li2 :: Ptr MPFR -> Ptr MPFR ->  CRoundMode -> IO CInt+ foreign import ccall unsafe "mpfr_eint"         mpfr_eint :: Ptr MPFR -> Ptr MPFR ->  CRoundMode -> IO CInt @@ -602,6 +629,12 @@  foreign import ccall unsafe "mpfr_frac"         mpfr_frac :: Ptr MPFR -> Ptr MPFR -> CRoundMode -> IO CInt++foreign import ccall unsafe "mpfr_modf"+        mpfr_modf :: Ptr MPFR -> Ptr MPFR -> Ptr MPFR -> CRoundMode -> IO CInt++foreign import ccall unsafe "mpfr_fmod"+        mpfr_fmod :: Ptr MPFR -> Ptr MPFR -> Ptr MPFR -> CRoundMode -> IO CInt  foreign import ccall unsafe "mpfr_remainder"          mpfr_remainder :: Ptr MPFR -> Ptr MPFR -> Ptr MPFR -> CRoundMode -> IO CInt
Data/Number/MPFR/Integer.hs view
@@ -18,39 +18,50 @@  import Data.Number.MPFR.Internal -rint       :: RoundMode -> Precision -> MPFR -> MPFR-rint r p d = fst $ rint_ r p d+rint     :: RoundMode -> Precision -> MPFR -> MPFR+rint r p = fst . rint_ r p -ceil     :: Precision -> MPFR -> MPFR-ceil p d = fst $ ceil_ p d+ceil   :: Precision -> MPFR -> MPFR+ceil p = fst . ceil_ p -floor     :: Precision -> MPFR -> MPFR-floor p d = fst $ floor_ p d+floor   :: Precision -> MPFR -> MPFR+floor p = fst . floor_ p -round     :: Precision -> MPFR -> MPFR-round p d = fst $ round_ p d+round   :: Precision -> MPFR -> MPFR+round p = fst . round_ p -trunc     :: Precision -> MPFR -> MPFR-trunc p d = fst $ trunc_ p d+trunc   :: Precision -> MPFR -> MPFR+trunc p = fst . trunc_ p -rintCeil :: RoundMode -> Precision -> MPFR -> MPFR-rintCeil r p d = fst $ rintCeil_ r p d+rintCeil     :: RoundMode -> Precision -> MPFR -> MPFR+rintCeil r p = fst . rintCeil_ r p -rintFloor :: RoundMode -> Precision -> MPFR -> MPFR-rintFloor r p d = fst $ rintFloor_ r p d+rintFloor     :: RoundMode -> Precision -> MPFR -> MPFR+rintFloor r p = fst . rintFloor_ r p -rintRound :: RoundMode -> Precision -> MPFR -> MPFR-rintRound r p d = fst $ rintRound_ r p d+rintRound     :: RoundMode -> Precision -> MPFR -> MPFR+rintRound r p = fst . rintRound_ r p -rintTrunc :: RoundMode -> Precision -> MPFR -> MPFR-rintTrunc r p d = fst $ rintTrunc_ r p d+rintTrunc     :: RoundMode -> Precision -> MPFR -> MPFR+rintTrunc r p = fst . rintTrunc_ r p -frac :: RoundMode -> Precision -> MPFR -> MPFR-frac r p d = fst $ frac_ r p d+modf          :: RoundMode+              -> Precision -- ^ precision to integral part+              -> Precision -- ^ precision to fractional part+              -> MPFR+              -> (MPFR, MPFR) -- ^ return (integral part, fractional part)+modf r p p' d = case modf_ r p p' d of+                    (a, b, _) -> (a, b) -remainder          :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-remainder r p d d' = fst $ remainder_ r p d d'+frac     :: RoundMode -> Precision -> MPFR -> MPFR+frac r p = fst . frac_ r p +fmod       :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+fmod r p d = fst . fmod_ r p d++remainder       :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+remainder r p d = fst . remainder_ r p d+ remquo          :: RoundMode -> Precision -> MPFR -> MPFR -> (MPFR, Int) remquo r p d d' = case remquo_ r p d d' of                      (a, b, _) -> (a, b)@@ -82,9 +93,32 @@ rintTrunc_ :: RoundMode -> Precision -> MPFR -> (MPFR, Int) rintTrunc_ r p d = withMPFR r p d mpfr_rint_trunc +modf_          :: RoundMode+               -> Precision -- ^ precision to compute integral part+               -> Precision -- ^ precision to compute fractional part +               -> MPFR+               -> (MPFR, MPFR, Int)+modf_ r p p' d = unsafePerformIO go +    where go = do ls <- mpfr_custom_get_size (fromIntegral p)+                  fp <- mallocForeignPtrBytes (fromIntegral ls)+                  ls' <- mpfr_custom_get_size (fromIntegral p')+                  fp' <- mallocForeignPtrBytes (fromIntegral ls')+                  alloca $ \p1 -> do +                    pokeDummy p1 fp (fromIntegral ls)+                    alloca $ \p2 -> do +                      pokeDummy p2 fp' (fromIntegral ls')+                      with d $ \p3 -> do+                        r3 <- mpfr_modf p1 p2 p3 ((fromIntegral . fromEnum) r)+                        r1 <- peekP p1 fp+                        r2 <- peekP p2 fp'+                        return (r1, r2, fromIntegral r3)+ frac_ :: RoundMode -> Precision -> MPFR -> (MPFR, Int) frac_ r p d = withMPFR r p d mpfr_frac +fmod_          :: RoundMode -> Precision -> MPFR -> MPFR -> (MPFR,Int)+fmod_ r p d d' = withMPFRsBA r p d d' mpfr_fmod+ remainder_          :: RoundMode -> Precision -> MPFR -> MPFR -> (MPFR,Int) remainder_ r p d d' = withMPFRsBA r p d d' mpfr_remainder @@ -94,8 +128,8 @@                   fp <- mallocForeignPtrBytes (fromIntegral ls)                   alloca $ \p1 -> do                     pokeDummy p1 fp p-                    with d $ \p2 -> do-                      with d' $ \p3 -> do+                    with d $ \p2 -> +                      with d' $ \p3 ->                          alloca $ \p4 -> do                           r3 <- mpfr_remquo p1 p4 p2 p3 ((fromIntegral . fromEnum) r)                           r1 <- peekP p1 fp
Data/Number/MPFR/Internal.hs view
@@ -4,7 +4,8 @@  module Data.Number.MPFR.Internal (        module FFIhelper, -       withMPFRsBA, withMPFRBAui, withMPFRBAiu, withMPFRBAsi, withMPFRBAis, +       withMPFRsBA, withMPFRBAui, withMPFRBAiu, withMPFRBAd,+       withMPFRBAsi, withMPFRBAis,  withMPFRBAd',         withMPFRB, withMPFRP, withMPFR, withMPFRBB, withMPFRC,         withMPFRF, withMPFRUI, withMPFRR, checkPrec, getMantissa', binprec,        unsafePerformIO, peek, Ptr, nullPtr, mallocForeignPtrBytes, with,@@ -17,7 +18,7 @@  import Data.Number.MPFR.FFIhelper as FFIhelper -import Foreign.C(CInt, CLong, CULong, withCString, peekCString)+import Foreign.C(CInt, CLong, CULong, CDouble, withCString, peekCString) import Foreign.Marshal(alloca, peekArray) import Foreign(unsafePerformIO, peek, Ptr, nullPtr, mallocForeignPtrBytes, with, withForeignPtr) import Foreign.Storable(sizeOf)@@ -76,6 +77,24 @@     where go = do withDummy p $ \p1 -> do                     with mp1 $ \p2 -> do                       f p1 d p2 ((fromIntegral . fromEnum) r)+{-# INLINE withMPFRBAd #-}+withMPFRBAd              :: RoundMode -> Precision -> MPFR -> CDouble+                               -> (Ptr MPFR -> Ptr MPFR -> CDouble -> CRoundMode -> IO CInt)+                               -> (MPFR, Int)+withMPFRBAd r p !mp1 d f = unsafePerformIO go +    where go = do withDummy p $ \ p1 -> do+                    with mp1 $ \ p2 -> do+                      f p1 p2 d ((fromIntegral . fromEnum) r)+                                  +{-# INLINE withMPFRBAd' #-}+withMPFRBAd'              :: RoundMode -> Precision -> CDouble -> MPFR+                               -> (Ptr MPFR -> CDouble -> Ptr MPFR -> CRoundMode -> IO CInt)+                               -> (MPFR, Int) +withMPFRBAd' r p d !mp1 f = unsafePerformIO go +    where go = do withDummy p $ \p1 -> do+                    with mp1 $ \p2 -> do+                      f p1 d p2 ((fromIntegral . fromEnum) r)+                       {-# INLINE withMPFRB #-} withMPFRB       :: MPFR -> (Ptr MPFR -> IO CInt) -> CInt 
Data/Number/MPFR/Misc.hs view
@@ -30,7 +30,7 @@                   fp <- mallocForeignPtrBytes (fromIntegral ls)                   alloca $ \p1 -> do                       pokeDummy p1 fp p-                      with mp1 $ \p2 -> do +                      with mp1 $ \p2 ->                         with mp2 $ \p3 -> do                           _ <- mpfr_set p1 p2 ((fromIntegral . fromEnum) Near)                            mpfr_nexttoward p1 p3 @@ -61,11 +61,11 @@                         mpfr_nextbelow p1                          peekP p1 fp -maxD           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-maxD r p d1 d2 = fst $ maxD_ r p d1 d2+maxD        :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+maxD r p d1 = fst . maxD_ r p d1 -minD           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-minD r p d1 d2 = fst $ minD_ r p d1 d2+minD        :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+minD r p d1 = fst . minD_ r p d1  random2       :: Precision -> MpSize -> Exp -> IO MPFR random2 p m e = do ls <- mpfr_custom_get_size (fromIntegral p)@@ -124,7 +124,7 @@ getMantissa d@(MP _ s e _) | e /= expInf && e /= expNaN && e /= expZero = toInteger s * h                            | otherwise                                  = 0     where (h, _) = foldl' (\(a,b) c ->-                               (a + (toInteger c) `shiftL` b, b + bitsPerMPLimb))+                               (a + toInteger c `shiftL` b, b + bitsPerMPLimb))                    (0,0) (getMantissa' d)   one :: MPFR
Data/Number/MPFR/Near.hs view
@@ -43,7 +43,7 @@     d * d'        = mul Near (maxPrec d d') d d'     negate d      = neg Near (getPrec d) d     abs d         = absD Near (getPrec d) d-    signum d      = fromInt Near minPrec (fromMaybe (-1) (sgn d))+    signum        = fromInt Near minPrec . fromMaybe (-1) . sgn     fromInteger (S# i) = fromInt Near minPrec (I# i)     fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral $ I# n * bitsPerIntegerLimb) i  @@ -55,7 +55,7 @@  instance Fractional MPFR where     d / d'         = Data.Number.MPFR.Base.div Up (maxPrec d d') d d'-    fromRational r = (fromInteger n) / (fromInteger d)+    fromRational r = fromInteger n / fromInteger d         where n = numerator r               d = denominator r     recip d        = one / d
Data/Number/MPFR/Special.hs view
@@ -17,164 +17,175 @@  import Data.Number.MPFR.Internal -log       :: RoundMode -> Precision -> MPFR -> MPFR-log r p d = fst $ log_ r p d+log     :: RoundMode -> Precision -> MPFR -> MPFR+log r p = fst . log_ r p -log2       :: RoundMode -> Precision -> MPFR -> MPFR-log2 r p d = fst $ log2_ r p d+log2     :: RoundMode -> Precision -> MPFR -> MPFR+log2 r p = fst . log2_ r p -log10       :: RoundMode -> Precision -> MPFR -> MPFR-log10 r p d = fst $ log10_ r p d+log10     :: RoundMode -> Precision -> MPFR -> MPFR+log10 r p = fst . log10_ r p -exp       :: RoundMode -> Precision -> MPFR -> MPFR-exp r p d = fst $ exp_ r p d+exp     :: RoundMode -> Precision -> MPFR -> MPFR+exp r p = fst . exp_ r p -exp2       :: RoundMode -> Precision -> MPFR -> MPFR-exp2 r p d = fst $ exp2_ r p d+exp2     :: RoundMode -> Precision -> MPFR -> MPFR+exp2 r p = fst . exp2_ r p -exp10       :: RoundMode -> Precision -> MPFR -> MPFR-exp10 r p d = fst $ exp10_ r p d+exp10     :: RoundMode -> Precision -> MPFR -> MPFR+exp10 r p = fst . exp10_ r p -sin       :: RoundMode -> Precision -> MPFR -> MPFR-sin r p d = fst $ sin_ r p d+sin     :: RoundMode -> Precision -> MPFR -> MPFR+sin r p = fst . sin_ r p -cos       :: RoundMode -> Precision -> MPFR -> MPFR-cos r p d = fst $ cos_ r p d+cos     :: RoundMode -> Precision -> MPFR -> MPFR+cos r p = fst . cos_ r p -tan       :: RoundMode -> Precision -> MPFR -> MPFR-tan r p d = fst $ tan_ r p d +tan     :: RoundMode -> Precision -> MPFR -> MPFR+tan r p = fst . tan_ r p -sec       :: RoundMode -> Precision -> MPFR -> MPFR-sec r p d = fst $ sec_ r p d+sec     :: RoundMode -> Precision -> MPFR -> MPFR+sec r p = fst . sec_ r p -csc       :: RoundMode -> Precision -> MPFR -> MPFR-csc r p d = fst $ csc_ r p d+csc     :: RoundMode -> Precision -> MPFR -> MPFR+csc r p = fst . csc_ r p -cot       :: RoundMode -> Precision -> MPFR -> MPFR-cot r p d = fst $ cot_ r p d +cot     :: RoundMode -> Precision -> MPFR -> MPFR+cot r p = fst . cot_ r p -sincos :: RoundMode-       -> Precision -- ^ precision to compute sin-       -> Precision -- ^ precision to compute cos -       -> MPFR-       -> (MPFR, MPFR) -- ^ return (sin x, cos x)+sincos          :: RoundMode+                -> Precision -- ^ precision to compute sin+                -> Precision -- ^ precision to compute cos +                -> MPFR+                -> (MPFR, MPFR) -- ^ return (sin x, cos x) sincos r p p' d = case sincos_ r p p' d of                     (a, b, _) -> (a, b) -asin       :: RoundMode -> Precision -> MPFR -> MPFR-asin r p d = fst $ asin_ r p d+asin     :: RoundMode -> Precision -> MPFR -> MPFR+asin r p = fst . asin_ r p -acos       :: RoundMode -> Precision -> MPFR -> MPFR-acos r p d = fst $ acos_ r p d+acos     :: RoundMode -> Precision -> MPFR -> MPFR+acos r p = fst . acos_ r p -atan       :: RoundMode -> Precision -> MPFR -> MPFR-atan r p d = fst $ atan_ r p d +atan     :: RoundMode -> Precision -> MPFR -> MPFR+atan r p = fst . atan_ r p -atan2          :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-atan2 r p d d' = fst $ atan2_ r p d d'+atan2       :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+atan2 r p d = fst . atan2_ r p d -sinh       :: RoundMode -> Precision -> MPFR -> MPFR-sinh r p d = fst $ sinh_ r p d+sinh     :: RoundMode -> Precision -> MPFR -> MPFR+sinh r p = fst . sinh_ r p -cosh       :: RoundMode -> Precision -> MPFR -> MPFR-cosh r p d = fst $ cosh_ r p d+cosh     :: RoundMode -> Precision -> MPFR -> MPFR+cosh r p = fst . cosh_ r p -tanh       :: RoundMode -> Precision -> MPFR -> MPFR-tanh r p d = fst $ tanh_ r p d +tanh     :: RoundMode -> Precision -> MPFR -> MPFR+tanh r p = fst . tanh_ r p -sech       :: RoundMode -> Precision -> MPFR -> MPFR-sech r p d = fst $ sech_ r p d+sinhcosh          :: RoundMode+                  -> Precision -- ^ precision to compute sin+                  -> Precision -- ^ precision to compute cos +                  -> MPFR+                  -> (MPFR, MPFR) -- ^ return (sin x, cos x)+sinhcosh r p p' d = case sinhcosh_ r p p' d of+                    (a, b, _) -> (a, b) -csch       :: RoundMode -> Precision -> MPFR -> MPFR-csch r p d = fst $ csch_ r p d+sech     :: RoundMode -> Precision -> MPFR -> MPFR+sech r p = fst . sech_ r p -coth       :: RoundMode -> Precision -> MPFR -> MPFR-coth r p d = fst $ coth_ r p d +csch     :: RoundMode -> Precision -> MPFR -> MPFR+csch r p = fst . csch_ r p -acosh       :: RoundMode -> Precision -> MPFR -> MPFR-acosh r p d = fst $ acosh_ r p d+coth     :: RoundMode -> Precision -> MPFR -> MPFR+coth r p = fst . coth_ r p -asinh       :: RoundMode -> Precision -> MPFR -> MPFR-asinh r p d = fst $ asinh_ r p d+acosh     :: RoundMode -> Precision -> MPFR -> MPFR+acosh r p = fst . acosh_ r p -atanh       :: RoundMode -> Precision -> MPFR -> MPFR-atanh r p d = fst $ atanh_ r p d +asinh     :: RoundMode -> Precision -> MPFR -> MPFR+asinh r p = fst . asinh_ r p -facw       :: RoundMode -> Precision -> Word -> MPFR-facw r p d = fst $ facw_ r p d+atanh     :: RoundMode -> Precision -> MPFR -> MPFR+atanh r p = fst . atanh_ r p -log1p       :: RoundMode -> Precision -> MPFR -> MPFR-log1p r p d = fst $ log1p_ r p d+facw     :: RoundMode -> Precision -> Word -> MPFR+facw r p = fst . facw_ r p -expm1       :: RoundMode -> Precision -> MPFR -> MPFR-expm1 r p d = fst $ expm1_ r p d+log1p     :: RoundMode -> Precision -> MPFR -> MPFR+log1p r p = fst . log1p_ r p -eint       :: RoundMode -> Precision -> MPFR -> MPFR-eint r p d = fst $ eint_ r p d+expm1     :: RoundMode -> Precision -> MPFR -> MPFR+expm1 r p = fst . expm1_ r p -gamma       :: RoundMode -> Precision -> MPFR -> MPFR-gamma r p d = fst $ gamma_ r p d+eint     :: RoundMode -> Precision -> MPFR -> MPFR+eint r p = fst . eint_ r p -lngamma       :: RoundMode -> Precision -> MPFR -> MPFR-lngamma r p d = fst $ lngamma_ r p d+li2     :: RoundMode -> Precision -> MPFR -> MPFR+li2 r p = fst . li2_ r p +gamma     :: RoundMode -> Precision -> MPFR -> MPFR+gamma r p = fst . gamma_ r p++lngamma     :: RoundMode -> Precision -> MPFR -> MPFR+lngamma r p = fst . lngamma_ r p+ lgamma       :: RoundMode -> Precision -> MPFR -> (MPFR, Int) lgamma r p d = case lgamma_ r p d of                   (a, b, _) -> (a,b) -zeta       :: RoundMode -> Precision -> MPFR -> MPFR-zeta r p d = fst $ zeta_ r p d+zeta     :: RoundMode -> Precision -> MPFR -> MPFR+zeta r p = fst . zeta_ r p -zetaw       :: RoundMode -> Precision -> Word -> MPFR-zetaw r p d = fst $ zetaw_ r p d+zetaw     :: RoundMode -> Precision -> Word -> MPFR+zetaw r p = fst . zetaw_ r p -erf       :: RoundMode -> Precision -> MPFR -> MPFR-erf r p d = fst $ erf_ r p d+erf     :: RoundMode -> Precision -> MPFR -> MPFR+erf r p = fst . erf_ r p -erfc       :: RoundMode -> Precision -> MPFR -> MPFR-erfc r p d = fst $ erfc_ r p d+erfc     :: RoundMode -> Precision -> MPFR -> MPFR+erfc r p = fst . erfc_ r p -j0       :: RoundMode -> Precision -> MPFR -> MPFR-j0 r p d = fst $ j0_ r p d+j0     :: RoundMode -> Precision -> MPFR -> MPFR+j0 r p = fst . j0_ r p -j1       :: RoundMode -> Precision -> MPFR -> MPFR-j1 r p d = fst $ j1_ r p d+j1     :: RoundMode -> Precision -> MPFR -> MPFR+j1 r p = fst . j1_ r p -jn         :: RoundMode -> Precision -> Int -> MPFR -> MPFR-jn r p w d = fst $ jn_ r p w d+jn       :: RoundMode -> Precision -> Int -> MPFR -> MPFR+jn r p w = fst . jn_ r p w -y0       :: RoundMode -> Precision -> MPFR -> MPFR-y0 r p d = fst $ y0_ r p d+y0     :: RoundMode -> Precision -> MPFR -> MPFR+y0 r p = fst . y0_ r p -y1       :: RoundMode -> Precision -> MPFR -> MPFR-y1 r p d = fst $ y1_ r p d+y1     :: RoundMode -> Precision -> MPFR -> MPFR+y1 r p = fst . y1_ r p -yn         :: RoundMode -> Precision -> Int -> MPFR -> MPFR-yn r p w d = fst $ yn_ r p w d+yn       :: RoundMode -> Precision -> Int -> MPFR -> MPFR+yn r p w = fst . yn_ r p w -fma              :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR -> MPFR-fma r p d1 d2 d3 = fst $ fma_ r p d1 d2 d3+fma           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR -> MPFR+fma r p d1 d2 = fst . fma_ r p d1 d2 -fms              :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR -> MPFR-fms r p d1 d2 d3 = fst $ fms_ r p d1 d2 d3+fms           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR -> MPFR+fms r p d1 d2 = fst . fms_ r p d1 d2 -agm           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-agm r p d1 d2 = fst $ agm_ r p d1 d2+agm        :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+agm r p d1 = fst . agm_ r p d1 -hypot           :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR-hypot r p d1 d2 = fst $ hypot_ r p d1 d2+hypot        :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR+hypot r p d1 = fst . hypot_ r p d1 -pi :: RoundMode -> Precision -> MPFR-pi r p = fst $ pi_ r p+pi   :: RoundMode -> Precision -> MPFR+pi r = fst . pi_ r -log2c     :: RoundMode -> Precision -> MPFR-log2c r p = fst $ pi_ r p+log2c   :: RoundMode -> Precision -> MPFR+log2c r = fst . pi_ r -euler     :: RoundMode -> Precision -> MPFR-euler r p = fst $ pi_ r p+euler   :: RoundMode -> Precision -> MPFR+euler r = fst . pi_ r -catalan     :: RoundMode -> Precision -> MPFR-catalan r p = fst $ pi_ r p+catalan   :: RoundMode -> Precision -> MPFR+catalan r = fst . pi_ r   log_       :: RoundMode -> Precision -> MPFR -> (MPFR, Int)@@ -255,6 +266,26 @@ tanh_       :: RoundMode -> Precision -> MPFR -> (MPFR, Int) tanh_ r p d = withMPFR r p d mpfr_tanh +sinhcosh_          :: RoundMode+                   -> Precision -- ^ precision to compute sinh+                   -> Precision -- ^ precision to compute cosh +                   -> MPFR+                   -> (MPFR, MPFR, Int)+sinhcosh_ r p p' d = unsafePerformIO go +    where go = do ls <- mpfr_custom_get_size (fromIntegral p)+                  fp <- mallocForeignPtrBytes (fromIntegral ls)+                  ls' <- mpfr_custom_get_size (fromIntegral p')+                  fp' <- mallocForeignPtrBytes (fromIntegral ls')+                  alloca $ \p1 -> do +                    pokeDummy p1 fp (fromIntegral ls)+                    alloca $ \p2 -> do +                      pokeDummy p2 fp' (fromIntegral ls')+                      with d $ \p3 -> do+                        r3 <- mpfr_sinh_cosh p1 p2 p3 ((fromIntegral . fromEnum) r)+                        r1 <- peekP p1 fp+                        r2 <- peekP p2 fp'+                        return (r1, r2, fromIntegral r3)+ sech_       :: RoundMode -> Precision -> MPFR -> (MPFR, Int) sech_ r p d = withMPFR r p d mpfr_sech @@ -285,6 +316,9 @@ eint_       :: RoundMode -> Precision -> MPFR -> (MPFR, Int) eint_ r p d = withMPFR r p d mpfr_eint +li2_       :: RoundMode -> Precision -> MPFR -> (MPFR, Int)+li2_ r p d = withMPFR r p d mpfr_li2+ gamma_       :: RoundMode -> Precision -> MPFR -> (MPFR, Int) gamma_ r p d = withMPFR r p d mpfr_gamma @@ -297,7 +331,7 @@                   fp <- mallocForeignPtrBytes (fromIntegral ls)                   alloca $ \p1 -> do                     pokeDummy p1 fp (fromIntegral ls)-                    with d $ \p2 -> do+                    with d $ \p2 ->                       alloca $ \p3 -> do                         r3 <- mpfr_lgamma p1 p3 p2 ((fromIntegral . fromEnum) r)                         r2 <- peek p3@@ -336,19 +370,19 @@  fma_                 :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR -> (MPFR, Int) fma_ r p mp1 mp2 mp3 = unsafePerformIO go-    where go = do withDummy p $ \p1 -> do-                    with mp1 $ \p2 -> do -                      with mp2 $ \p3 -> do -                        with mp3 $ \p4 -> do -                          mpfr_fma p1 p2 p3 p4 ((fromIntegral . fromEnum) r) +    where go = withDummy p $ \p1 -> +                 with mp1 $ \p2 -> +                   with mp2 $ \p3 ->+                     with mp3 $ \p4 ->+                       mpfr_fma p1 p2 p3 p4 ((fromIntegral . fromEnum) r)   fms_                 :: RoundMode -> Precision -> MPFR -> MPFR -> MPFR -> (MPFR, Int) fms_ r p mp1 mp2 mp3 = unsafePerformIO go-    where go = do withDummy p $ \p1 -> do-                    with mp1 $ \p2 -> do -                      with mp2 $ \p3 -> do -                        with mp3 $ \p4 -> do -                          mpfr_fms p1 p2 p3 p4 ((fromIntegral . fromEnum) r) +    where go = withDummy p $ \p1 ->+                 with mp1 $ \p2 -> +                   with mp2 $ \p3 ->+                     with mp3 $ \p4 ->+                       mpfr_fms p1 p2 p3 p4 ((fromIntegral . fromEnum) r)   agm_           :: RoundMode -> Precision -> MPFR -> MPFR -> (MPFR,Int) agm_ r p d1 d2 =  withMPFRsBA r p d1 d2 mpfr_agm
Data/Number/MPFR/Up.hs view
@@ -44,7 +44,7 @@     d * d'        = mul Up (maxPrec d d') d d'     negate d      = neg Up (getPrec d) d     abs d         = absD Up (getPrec d) d-    signum d      = fromInt Up minPrec (fromMaybe (-1) (sgn d))+    signum        = fromInt Up minPrec . fromMaybe (-1) . sgn     fromInteger (S# i) = fromInt Up minPrec (I# i)     fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral $ I# n * bitsPerIntegerLimb) i  @@ -56,7 +56,7 @@  instance Fractional MPFR where     d / d'         = Data.Number.MPFR.Base.div Up (maxPrec d d') d d'-    fromRational r = (fromInteger n) / (fromInteger d)+    fromRational r = fromInteger n / fromInteger d         where n = numerator r               d = denominator r     recip d        = one / d
Data/Number/MPFR/Zero.hs view
@@ -44,7 +44,7 @@     d * d'        = mul Zero (maxPrec d d') d d'     negate d      = neg Zero (getPrec d) d     abs d         = absD Zero (getPrec d) d-    signum d      = fromInt Zero minPrec (fromMaybe (-1) (sgn d))+    signum        = fromInt Zero minPrec . fromMaybe (-1) . sgn     fromInteger (S# i) = fromInt Zero minPrec (I# i)     fromInteger i@(J# n _) = fromIntegerA Zero (fromIntegral $ I# n * bitsPerIntegerLimb) i  @@ -56,7 +56,7 @@  instance Fractional MPFR where     d / d'         = Data.Number.MPFR.Base.div Zero (maxPrec d d') d d'-    fromRational r = (fromInteger n) / (fromInteger d)+    fromRational r = fromInteger n / fromInteger d         where n = numerator r               d = denominator r     recip d        = one / d
README view
@@ -1,7 +1,3 @@ Haskell MPFR binding. -It was successfully tested with MPFR versions 2.3.1 and 2.3.2 and with-GHC versions 6.8.3 and 6.8.2 on (Ubuntu) Linux and on Windows (MPFR was built with -MSYS).- If you find bugs or have any questions please write to <ales.bizjak0@gmail.com>.
dict.txt view
@@ -26,22 +26,29 @@ mpfr_add : add mpfr_add_ui : addw mpfr_add_si : addi+mpfr_add_d : addd mpfr_sub : sub mpfr_ui_sub  : wsub  mpfr_sub_ui : subw mpfr_si_sub  : isub mpfr_sub_si : subi+mpfr_sub_d : subd+mpfr_d_sub : dsub mpfr_mul : mul mpfr_mul_ui : mulw mpfr_mul_si : muli+mpfr_mul_d : muld mpfr_sqr : sqr mpfr_div : div mpfr_ui_div : wdiv mpfr_div_ui : divw mpfr_si_div : idiv mpfr_div_si : divi+mpfr_div_d : divd+mpfr_d_div : ddiv mpfr_sqrt : sqrt mpfr_sqrt_ui : sqrtw+mpfr_rec_sqrt : recSqrt mpfr_cbrt : cbrt mpfr_root : root mpfr_pow : pow@@ -102,6 +109,7 @@ mpfr_sech : sech mpfr_csch : csch mpfr_coth : coth+mpfr_sinh_cosh : sinhcosh mpfr_asinh : asinh mpfr_acosh : acosh mpfr_atanh : atanh@@ -109,6 +117,7 @@ mpfr_log1p : log1p mpfr_expm1 : expm1 mpfr_eint : eint+mpfr_li2 : li2 mpfr_gamma : gamma mpfr_lngamma : lngamma mpfr_lgamma : lgamma@@ -137,6 +146,8 @@ mpfr_floor : floor mpfr_round : round mpfr_trunc : trunc+mpfr_modf : modf+mpfr_fmod : fmod mpfr_rint_ceil : rintCeil mpfr_rint_floor : rintFloor mpfr_rint_round : rintRound
hmpfr.cabal view
@@ -1,13 +1,15 @@ name:                hmpfr-version:             0.1.3+version:             0.2 synopsis:            Haskell binding to MPFR library-description:         Haskell binding to MPFR library. Tested with 2.3.2.+description:         Haskell binding to MPFR library. This version is compatible+		     only with 2.4.* and will not work with previous releases+		     of the MPFR library.                      Some simple examples of usage can be found in test/Demo.hs. category:            Data, Math license:             BSD3 license-file:        LICENSE Stability:           experimental-tested-with:         GHC == 6.8.3+tested-with:         GHC == 6.10.2 author:              Aleš Bizjak maintainer:          Aleš Bizjak <ales.bizjak0@gmail.com> Homepage:            http://code.haskell.org/hmpfr/