summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichalKonecny <>2017-11-14 15:05:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-11-14 15:05:00 (GMT)
commit8f9dc561a2c32380fd146a28f1f08399926b178e (patch)
treec7df9d3bed689d8583c5f22bc97bdc42e988df90
parent7fc98fb63c7815ca9dd03325c8bfab51e8f4f30e (diff)
version 0.1.1.00.1.1.0
-rw-r--r--aern2-mp.cabal2
-rw-r--r--changelog.md2
-rw-r--r--src/AERN2/MP/UseMPFR/Float/Arithmetic.hs18
-rw-r--r--src/AERN2/MP/UseMPFR/Float/Conversions.hs18
-rw-r--r--src/AERN2/MP/UseMPFR/Float/RoundedAdaptor.hs13
-rw-r--r--src/AERN2/MP/UseMPFR/Float/Type.hs6
6 files changed, 32 insertions, 27 deletions
diff --git a/aern2-mp.cabal b/aern2-mp.cabal
index d8f02ac..4a560f4 100644
--- a/aern2-mp.cabal
+++ b/aern2-mp.cabal
@@ -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
diff --git a/changelog.md b/changelog.md
index 7363fb2..17fbff8 100644
--- a/changelog.md
+++ b/changelog.md
@@ -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
diff --git a/src/AERN2/MP/UseMPFR/Float/Arithmetic.hs b/src/AERN2/MP/UseMPFR/Float/Arithmetic.hs
index 10f351d..45bebda 100644
--- a/src/AERN2/MP/UseMPFR/Float/Arithmetic.hs
+++ b/src/AERN2/MP/UseMPFR/Float/Arithmetic.hs
@@ -37,7 +37,7 @@ import AERN2.MP.UseMPFR.Float.Type
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 @@ recipDown x = divDown one x
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 @@ logDown = unaryDown MPLow.log
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 @@ binaryApprox isUp _canBeExact opRP x y =
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
diff --git a/src/AERN2/MP/UseMPFR/Float/Conversions.hs b/src/AERN2/MP/UseMPFR/Float/Conversions.hs
index 5b4499d..8db685f 100644
--- a/src/AERN2/MP/UseMPFR/Float/Conversions.hs
+++ b/src/AERN2/MP/UseMPFR/Float/Conversions.hs
@@ -91,8 +91,8 @@ mpFromRationalA dir p q
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 @@ mpFromRationalA dir p q
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 @@ instance ConvertibleExactly MPFloat Rational where
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 @@ instance ConvertibleExactly Int MPFloat where
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
diff --git a/src/AERN2/MP/UseMPFR/Float/RoundedAdaptor.hs b/src/AERN2/MP/UseMPFR/Float/RoundedAdaptor.hs
index e09a7db..74ee250 100644
--- a/src/AERN2/MP/UseMPFR/Float/RoundedAdaptor.hs
+++ b/src/AERN2/MP/UseMPFR/Float/RoundedAdaptor.hs
@@ -19,16 +19,19 @@ module AERN2.MP.UseMPFR.Float.RoundedAdaptor
#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 :: RoundMode -> Precision -> Integer -> Rounded
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 :: RoundMode -> Precision -> Rational -> Rounded
fromRationalA = fromRational'
toRationalA :: Rounded -> Rational
-toRationalA = toRational'
+toRationalA = toRational' TowardNearest
add, sub, mul, div, atan2 :: RoundMode -> Precision -> Rounded -> Rounded -> Rounded
add = add_
diff --git a/src/AERN2/MP/UseMPFR/Float/Type.hs b/src/AERN2/MP/UseMPFR/Float/Type.hs
index 884f235..8fd7b1e 100644
--- a/src/AERN2/MP/UseMPFR/Float/Type.hs
+++ b/src/AERN2/MP/UseMPFR/Float/Type.hs
@@ -79,13 +79,13 @@ p2mpfrPrec = P.fromInteger . integer
#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)