aern2-mp 0.2.3.0 → 0.2.4.0
raw patch · 5 files changed
+41/−15 lines, 5 filesdep ~mixed-types-numPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: mixed-types-num
API changes (from Hackage documentation)
+ AERN2.MP.Ball.Field: mulBalls :: MPBall -> MPBall -> MPBall
+ AERN2.MP.Ball.Field: mulByEndpoints :: MPBall -> MPBall -> MPBall
Files
- aern2-mp.cabal +4/−4
- changelog.md +2/−0
- src/AERN2/MP/Ball/Elementary.hs +4/−4
- src/AERN2/MP/Ball/Field.hs +29/−5
- src/AERN2/MP/Dyadic.hs +2/−2
aern2-mp.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 3a6ca9d8026d093f51e3a0bb5c6a09c0a4cb008c15b8d398d4fc46d44591a13a+-- hash: 59805057da90f7bf5d2552756df7e049bc228e506b006e1fb8357f26c3efb204 name: aern2-mp-version: 0.2.3.0+version: 0.2.4.0 synopsis: Multi-precision ball (interval) arithmetic description: Please see the README on GitHub at <https://github.com/michalkonecny/aern2/#readme> category: Math@@ -84,7 +84,7 @@ , deepseq , hspec , integer-logarithms- , mixed-types-num >=0.5.4+ , mixed-types-num >=0.5.5 , reflection , regex-tdfa , template-haskell@@ -124,7 +124,7 @@ , deepseq , hspec , integer-logarithms- , mixed-types-num >=0.5.4+ , mixed-types-num >=0.5.5 , reflection , regex-tdfa , template-haskell
changelog.md view
@@ -1,5 +1,7 @@ # Change log for aern2-mp +* v 0.2.4 2021-05-26+ * use endpoint multiplication in integer power to avoid crossing 0 * v 0.2.3 2021-05-22 * make MPBall "Very inaccurate" a *potential* error (important for CReal accuracy queries) * v 0.2.2 2021-05-21
src/AERN2/MP/Ball/Elementary.hs view
@@ -37,7 +37,7 @@ import AERN2.MP.Ball.Type import AERN2.MP.Ball.Conversions () import AERN2.MP.Ball.Comparisons ()-import AERN2.MP.Ball.Field ()+import AERN2.MP.Ball.Field (mulByEndpoints) {- trigonometrics -}@@ -112,13 +112,13 @@ logLip y = errorBound $ (1/y) instance CanPow MPBall MPBall where- pow = powUsingExpLog (mpBall 1)+ pow = powUsingExpLog (mpBall 1) mulByEndpoints recip instance CanPow MPBall Dyadic where- pow b e = powUsingExpLog (mpBall 1) b (mpBall e)+ pow b e = pow b (mpBall e) instance CanPow MPBall Rational where- pow b e = powUsingExpLog (mpBall 1) b (mpBallP (getPrecision b) e)+ pow b e = pow b (mpBallP (getPrecision b) e) instance CanSqrt MPBall where type SqrtType MPBall = MPBall
src/AERN2/MP/Ball/Field.hs view
@@ -15,7 +15,7 @@ Field operations on arbitrary precision dyadic balls -} module AERN2.MP.Ball.Field-()+(mulBalls, mulByEndpoints) where import MixedTypesNumPrelude@@ -124,13 +124,37 @@ {- multiplication -} instance CanMulAsymmetric MPBall MPBall where- mul (MPBall x1 e1) (MPBall x2 e2) =+ mul = mulBalls+ -- mul = mulByEndpoints++mulBalls :: MPBall -> MPBall -> MPBall+mulBalls (MPBall x1 e1) (MPBall x2 e2) = normalize $ MPBall x12C (e12 + e1*(abs x2) + e2*(abs x1) + e1*e2) -- the mixed operations above automatically convert -- MPFloat to ErrorBound, checking non-negativity where (x12C, e12) = MPFloat.ceduCentreErr $ MPFloat.mulCEDU x1 x2 +mulByEndpoints :: MPBall -> MPBall -> MPBall+mulByEndpoints b1 b2 = + fromEndpoints l r+ where+ (l,r) + | 0 <= l1 && 0 <= l2 = (l1*.l2, r1*^r2) -- 0 <= l1 <= r1, 0 <= l2 <= r2+ | r1 <= 0 && r2 <= 0 = (r1*.r2, l1*^l2) -- l1 <= r1 <= 0, l2 <= r2 <= 0+ | 0 <= l1 && r2 <= 0 = (r1*.l2, l1*^r2) -- l2 <= r2 <= 0 <= l1 <= r1+ | r1 <= 0 && 0 <= l2 = (l1*.r2, r1*^l2) -- l1 <= r1 <= 0 <= l2 <= r2+ | l1 < 0 && 0 < r1 && 0 <= l2 = (l1*.r2, r1*^r2) -- l1 < 0 < r1, 0 <= l2 <= r2+ | l1 < 0 && 0 < r1 && r2 <= 0 = (r1*.l2, l1*^l2) -- l1 < 0 < r1, l2 <= r2 <= 0+ | l2 < 0 && 0 < r2 && 0 <= l1 = (l2*.r1, r2*^r1) -- l2 < 0 < r2, 0 <= l1 <= r1+ | l2 < 0 && 0 < r2 && r1 <= 0 = (r2*.l1, l2*^l1) -- l2 < 0 < r2, l1 <= r1 <= 0+ | otherwise = -- l1 < 0 < r1, l2 < 0 < r2+ ((l1 *. r2) `min` (r1 *. l2)+ ,(l1 *^ l2) `max` (r1 *^ r2))+ (l1,r1) = endpoints b1+ (l2,r2) = endpoints b2++ instance CanMulAsymmetric MPBall Int where type MulType MPBall Int = MPBall mul = convertSecond mul@@ -254,11 +278,11 @@ instance CanPow MPBall Int where pow = powUsingMulRecipCutNeg (mpBall 1) -powUsingMulRecipCutNeg :: _ => t -> t -> e -> DivType Integer t+powUsingMulRecipCutNeg :: _ => MPBall -> MPBall -> e -> MPBall powUsingMulRecipCutNeg one x e | even e = - max 0 $ powUsingMulRecip one x e- | otherwise = powUsingMulRecip one x e+ max 0 $ powUsingMulRecip one mulByEndpoints recip x e+ | otherwise = powUsingMulRecip one mulByEndpoints recip x e instance (CanPow MPBall b)
src/AERN2/MP/Dyadic.hs view
@@ -458,9 +458,9 @@ mul = CE.lift1T mul instance CanPow Dyadic Integer where- pow = powUsingMul (dyadic 1)+ pow = powUsingMul (dyadic 1) (*) instance CanPow Dyadic Int where- pow = powUsingMul (dyadic 1)+ pow = powUsingMul (dyadic 1) (*) instance (CanDiv a Dyadic