aern2-mp 0.1.0.1 → 0.1.1.0
raw patch · 6 files changed
+32/−27 lines, 6 files
Files
- aern2-mp.cabal +1/−1
- 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 +8/−5
- src/AERN2/MP/UseMPFR/Float/Type.hs +3/−3
aern2-mp.cabal view
@@ -1,5 +1,5 @@ name: aern2-mp-version: 0.1.0.1+version: 0.1.1.0 cabal-version: >= 1.9.2 build-type: Simple homepage: https://github.com/michalkonecny/aern2
changelog.md view
@@ -1,3 +1,5 @@+* v 0.1.1.0 2017-11-14+ * using Claude Heiland-Allen's Numeric.Rounded.Simple * v 0.1.0.1 2017-09-12 * first release on Hackage * backends: hmpfr and (tweaked) rounded
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.Up (P.fromInteger 10) (int 1)+one = MPLow.fromInt MPLow.TowardInf (P.fromInteger 10) (int 1) #endif @@ -93,11 +93,11 @@ piUp :: Precision -> MPFloat piUp p =- MPLow.pi MPLow.Up (p2mpfrPrec p)+ MPLow.pi MPLow.TowardInf (p2mpfrPrec p) piDown :: Precision -> MPFloat piDown p =- MPLow.pi MPLow.Down (p2mpfrPrec p)+ MPLow.pi MPLow.TowardNegInf (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.Up p x+unaryUp opRP x = opRP MPLow.TowardInf p x where- p = MPLow.getPrec x+ p = MPLow.precision x unaryDown :: (MPLow.RoundMode -> MPLow.Precision -> MPFloat -> MPFloat) -> (MPFloat -> MPFloat)-unaryDown opRP x = opRP MPLow.Down p x+unaryDown opRP x = opRP MPLow.TowardNegInf p x where- p = MPLow.getPrec x+ p = MPLow.precision x binaryUp :: Bool ->@@ -166,5 +166,5 @@ where pMax = (getPrecision x) `max` (getPrecision y) withPrec p- | isUp = opRP MPLow.Up (p2mpfrPrec p) x y- | otherwise = opRP MPLow.Down (p2mpfrPrec p) x y+ | isUp = opRP MPLow.TowardInf (p2mpfrPrec p) x y+ | otherwise = opRP MPLow.TowardNegInf (p2mpfrPrec p) x y
src/AERN2/MP/UseMPFR/Float/Conversions.hs view
@@ -91,8 +91,8 @@ where (divDir, dirOpp) = case dir of- MPLow.Down -> (divDown, MPLow.Up)- MPLow.Up -> (divUp, MPLow.Down)+ MPLow.TowardNegInf -> (divDown, MPLow.TowardInf)+ MPLow.TowardInf -> (divUp, MPLow.TowardNegInf) _ -> error "in mpFromRationalA" #endif@@ -100,7 +100,7 @@ instance HasNorm MPFloat where getNormLog x | x == 0 = NormZero- | otherwise = NormBits (P.toInteger $ MPLow.getExp x)+ | otherwise = NormBits (P.toInteger $ MPLow.exponent' x) {- conversions -} @@ -115,16 +115,16 @@ safeConvertExactly = Right . mpToRational toDoubleUp :: MPFloat -> Double-toDoubleUp = mpToDouble MPLow.Up+toDoubleUp = mpToDouble MPLow.TowardInf toDoubleDown :: MPFloat -> Double-toDoubleDown = mpToDouble MPLow.Down+toDoubleDown = mpToDouble MPLow.TowardNegInf fromIntegerUp :: Precision -> Integer -> MPFloat-fromIntegerUp p i = MPLow.fromIntegerA MPLow.Up (p2mpfrPrec p) i+fromIntegerUp p i = MPLow.fromIntegerA MPLow.TowardInf (p2mpfrPrec p) i fromIntegerDown :: Precision -> Integer -> MPFloat-fromIntegerDown p i = MPLow.fromIntegerA MPLow.Down (p2mpfrPrec p) i+fromIntegerDown p i = MPLow.fromIntegerA MPLow.TowardNegInf (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.Up (p2mpfrPrec p) x+ mpFromRationalA MPLow.TowardInf (p2mpfrPrec p) x fromRationalDown :: Precision -> Rational -> MPFloat fromRationalDown p x =- mpFromRationalA MPLow.Down (p2mpfrPrec p) x+ mpFromRationalA MPLow.TowardNegInf (p2mpfrPrec p) x instance Convertible MPFloat Double where safeConvert x
src/AERN2/MP/UseMPFR/Float/RoundedAdaptor.hs view
@@ -19,16 +19,19 @@ #else ( module AERN2.MP.UseMPFR.Float.RoundedAdaptor-, module Numeric.RoundedSimple+, module Numeric.Rounded.Simple ) where import Prelude hiding (div, pi) -- import qualified Prelude as P -import Numeric.RoundedSimple hiding (prec)+import Numeric.Rounded.Simple -- import qualified Numeric.RoundedSimple as R +instance Show Rounded where+ show = show'+ type RoundMode = RoundingMode defaultPrecision :: Precision@@ -41,8 +44,8 @@ fromIntegerA = fromInteger' zero, one :: Rounded-zero = fromIntegerA Up defaultPrecision 0-one = fromIntegerA Up defaultPrecision 1+zero = fromIntegerA TowardNearest defaultPrecision 0+one = fromIntegerA TowardNearest defaultPrecision 1 toDoubleA :: RoundMode -> Rounded -> Double toDoubleA = toDouble@@ -51,7 +54,7 @@ fromRationalA = fromRational' toRationalA :: Rounded -> Rational-toRationalA = toRational'+toRationalA = toRational' TowardNearest add, sub, mul, div, atan2 :: RoundMode -> Precision -> Rounded -> Rounded -> Rounded add = add_
src/AERN2/MP/UseMPFR/Float/Type.hs view
@@ -79,13 +79,13 @@ #endif instance HasPrecision MPFloat where- getPrecision x = prec (P.toInteger $ MPLow.getPrec x)+ getPrecision x = prec (P.toInteger $ MPLow.precision x) instance CanSetPrecision MPFloat where setPrecision = setPrecisionUp setPrecisionUp :: Precision -> MPFloat -> MPFloat-setPrecisionUp p = MPLow.set MPLow.Up (p2mpfrPrec p)+setPrecisionUp p = MPLow.precRound MPLow.TowardInf (p2mpfrPrec p) setPrecisionDown :: Precision -> MPFloat -> MPFloat-setPrecisionDown p = MPLow.set MPLow.Down (p2mpfrPrec p)+setPrecisionDown p = MPLow.precRound MPLow.TowardNegInf (p2mpfrPrec p)