aern2-mp 0.1.1.0 → 0.1.2.0
raw patch · 6 files changed
+68/−52 lines, 6 filesdep ~QuickCheckdep ~convertibledep ~hspec
Dependency ranges changed: QuickCheck, convertible, hspec, integer-logarithms, lens, mixed-types-num, regex-tdfa
Files
- aern2-mp.cabal +12/−12
- changelog.md +2/−0
- src/AERN2/MP/UseMPFR/Float/Arithmetic.hs +9/−9
- src/AERN2/MP/UseMPFR/Float/Conversions.hs +9/−9
- src/AERN2/MP/UseMPFR/Float/RoundedAdaptor.hs +33/−19
- src/AERN2/MP/UseMPFR/Float/Type.hs +3/−3
aern2-mp.cabal view
@@ -1,5 +1,5 @@ name: aern2-mp-version: 0.1.1.0+version: 0.1.2.0 cabal-version: >= 1.9.2 build-type: Simple homepage: https://github.com/michalkonecny/aern2@@ -51,15 +51,15 @@ hs-source-dirs: src build-depends: base == 4.*- , integer-logarithms >= 1.0 && < 1.1- , convertible >= 1.1.1.0 && < 1.2- , regex-tdfa >= 1.2.1 && < 1.3- , hspec >= 2.1 && < 2.5- -- , hspec-smallcheck >= 0.3 && < 0.5- , QuickCheck >= 2.7 && < 2.10- , lens >= 4.13 && < 4.16+ , integer-logarithms+ , convertible+ , regex-tdfa+ , hspec+ -- , hspec-smallcheck >= 0.3+ , QuickCheck+ , lens , template-haskell- , mixed-types-num >= 0.3.1 && < 0.4+ , mixed-types-num if flag(MPFR) cpp-options: -DUSEMPFR if impl(ghc >= 7.10)@@ -149,6 +149,6 @@ base == 4.* -- , mixed-types-num >= 0.3.1 && < 0.4 , aern2-mp- , hspec >= 2.1 && < 2.5- -- , hspec-smallcheck >= 0.3 && < 0.5- , QuickCheck >= 2.7 && < 2.10+ , hspec >= 2.1+ -- , hspec-smallcheck >= 0.3+ , QuickCheck >= 2.7
changelog.md view
@@ -1,3 +1,5 @@+* v 0.1.2.0 2017-11-14+ * fix compilation with haskell-mpfr * v 0.1.1.0 2017-11-14 * using Claude Heiland-Allen's Numeric.Rounded.Simple * v 0.1.0.1 2017-09-12
src/AERN2/MP/UseMPFR/Float/Arithmetic.hs view
@@ -37,7 +37,7 @@ import qualified Data.Approximate.MPFRLowLevel as MPLow one :: MPFloat-one = MPLow.fromInt MPLow.TowardInf (P.fromInteger 10) (int 1)+one = MPLow.fromInt MPLow.Up (P.fromInteger 10) (int 1) #endif @@ -93,11 +93,11 @@ piUp :: Precision -> MPFloat piUp p =- MPLow.pi MPLow.TowardInf (p2mpfrPrec p)+ MPLow.pi MPLow.Up (p2mpfrPrec p) piDown :: Precision -> MPFloat piDown p =- MPLow.pi MPLow.TowardNegInf (p2mpfrPrec p)+ MPLow.pi MPLow.Down (p2mpfrPrec p) cosUp :: MPFloat -> MPFloat cosUp = unaryUp MPLow.cos@@ -134,16 +134,16 @@ unaryUp :: (MPLow.RoundMode -> MPLow.Precision -> MPFloat -> MPFloat) -> (MPFloat -> MPFloat)-unaryUp opRP x = opRP MPLow.TowardInf p x+unaryUp opRP x = opRP MPLow.Up p x where- p = MPLow.precision x+ p = MPLow.getPrec x unaryDown :: (MPLow.RoundMode -> MPLow.Precision -> MPFloat -> MPFloat) -> (MPFloat -> MPFloat)-unaryDown opRP x = opRP MPLow.TowardNegInf p x+unaryDown opRP x = opRP MPLow.Down p x where- p = MPLow.precision x+ p = MPLow.getPrec x binaryUp :: Bool ->@@ -166,5 +166,5 @@ where pMax = (getPrecision x) `max` (getPrecision y) withPrec p- | isUp = opRP MPLow.TowardInf (p2mpfrPrec p) x y- | otherwise = opRP MPLow.TowardNegInf (p2mpfrPrec p) x y+ | isUp = opRP MPLow.Up (p2mpfrPrec p) x y+ | otherwise = opRP MPLow.Down (p2mpfrPrec p) x y
src/AERN2/MP/UseMPFR/Float/Conversions.hs view
@@ -91,8 +91,8 @@ where (divDir, dirOpp) = case dir of- MPLow.TowardNegInf -> (divDown, MPLow.TowardInf)- MPLow.TowardInf -> (divUp, MPLow.TowardNegInf)+ MPLow.Down -> (divDown, MPLow.Up)+ MPLow.Up -> (divUp, MPLow.Down) _ -> error "in mpFromRationalA" #endif@@ -100,7 +100,7 @@ instance HasNorm MPFloat where getNormLog x | x == 0 = NormZero- | otherwise = NormBits (P.toInteger $ MPLow.exponent' x)+ | otherwise = NormBits (P.toInteger $ MPLow.getExp x) {- conversions -} @@ -115,16 +115,16 @@ safeConvertExactly = Right . mpToRational toDoubleUp :: MPFloat -> Double-toDoubleUp = mpToDouble MPLow.TowardInf+toDoubleUp = mpToDouble MPLow.Up toDoubleDown :: MPFloat -> Double-toDoubleDown = mpToDouble MPLow.TowardNegInf+toDoubleDown = mpToDouble MPLow.Down fromIntegerUp :: Precision -> Integer -> MPFloat-fromIntegerUp p i = MPLow.fromIntegerA MPLow.TowardInf (p2mpfrPrec p) i+fromIntegerUp p i = MPLow.fromIntegerA MPLow.Up (p2mpfrPrec p) i fromIntegerDown :: Precision -> Integer -> MPFloat-fromIntegerDown p i = MPLow.fromIntegerA MPLow.TowardNegInf (p2mpfrPrec p) i+fromIntegerDown p i = MPLow.fromIntegerA MPLow.Down (p2mpfrPrec p) i type CanBeMPFloat t = ConvertibleExactly t MPFloat mpFloat :: (CanBeMPFloat t) => t -> MPFloat@@ -150,11 +150,11 @@ fromRationalUp :: Precision -> Rational -> MPFloat fromRationalUp p x =- mpFromRationalA MPLow.TowardInf (p2mpfrPrec p) x+ mpFromRationalA MPLow.Up (p2mpfrPrec p) x fromRationalDown :: Precision -> Rational -> MPFloat fromRationalDown p x =- mpFromRationalA MPLow.TowardNegInf (p2mpfrPrec p) x+ mpFromRationalA MPLow.Down (p2mpfrPrec p) x instance Convertible MPFloat Double where safeConvert x
src/AERN2/MP/UseMPFR/Float/RoundedAdaptor.hs view
@@ -32,45 +32,59 @@ instance Show Rounded where show = show' -type RoundMode = RoundingMode+getPrec :: Rounded -> Int+getPrec = precision +getExp :: Rounded -> Int+getExp = exponent'++data RoundMode = Up | Down++withRoundMode :: (RoundingMode -> t) -> (RoundMode -> t)+withRoundMode op Up = op TowardInf+withRoundMode op Down = op TowardNegInf+{-# INLINE withRoundMode #-}++set :: RoundMode -> Precision -> Rounded -> Rounded+set = withRoundMode precRound+ defaultPrecision :: Precision defaultPrecision = 10 pi :: RoundMode -> Precision -> Rounded-pi = kPi+pi = withRoundMode kPi fromIntegerA :: RoundMode -> Precision -> Integer -> Rounded-fromIntegerA = fromInteger'+fromIntegerA = withRoundMode fromInteger' zero, one :: Rounded-zero = fromIntegerA TowardNearest defaultPrecision 0-one = fromIntegerA TowardNearest defaultPrecision 1+zero = fromIntegerA Up defaultPrecision 0+one = fromIntegerA Up defaultPrecision 1 toDoubleA :: RoundMode -> Rounded -> Double-toDoubleA = toDouble+toDoubleA = withRoundMode toDouble fromRationalA :: RoundMode -> Precision -> Rational -> Rounded-fromRationalA = fromRational'+fromRationalA = withRoundMode fromRational' toRationalA :: Rounded -> Rational toRationalA = toRational' TowardNearest add, sub, mul, div, atan2 :: RoundMode -> Precision -> Rounded -> Rounded -> Rounded-add = add_-sub = sub_-mul = mul_-div = div_-atan2 = atan2_+add = withRoundMode add_+sub = withRoundMode sub_+mul = withRoundMode mul_+div = withRoundMode div_+atan2 = withRoundMode atan2_ neg, abs, sqrt, exp, log, sin, cos :: RoundMode -> Precision -> Rounded -> Rounded-neg = negate_-abs = abs_-sqrt = sqrt_-exp = exp_-log = log_-sin = sin_-cos = cos_+neg = withRoundMode negate_+abs = withRoundMode abs_+sqrt = withRoundMode sqrt_+exp = withRoundMode exp_+log = withRoundMode log_+sin = withRoundMode sin_+cos = withRoundMode cos_ -- TODO: add more ops #endif
src/AERN2/MP/UseMPFR/Float/Type.hs view
@@ -79,13 +79,13 @@ #endif instance HasPrecision MPFloat where- getPrecision x = prec (P.toInteger $ MPLow.precision x)+ getPrecision x = prec (P.toInteger $ MPLow.getPrec x) instance CanSetPrecision MPFloat where setPrecision = setPrecisionUp setPrecisionUp :: Precision -> MPFloat -> MPFloat-setPrecisionUp p = MPLow.precRound MPLow.TowardInf (p2mpfrPrec p)+setPrecisionUp p = MPLow.set MPLow.Up (p2mpfrPrec p) setPrecisionDown :: Precision -> MPFloat -> MPFloat-setPrecisionDown p = MPLow.precRound MPLow.TowardNegInf (p2mpfrPrec p)+setPrecisionDown p = MPLow.set MPLow.Down (p2mpfrPrec p)