summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichalKonecny <>2008-09-30 12:21:18 (GMT)
committerLuite Stegeman <luite@luite.com>2008-09-30 12:21:18 (GMT)
commit41e99376b779ad918d1569a3747c34bf0e1b9b08 (patch)
tree96d2c5d49e5a0d87d736a01c6702ab85e19df24c
parentc8332b5c28876c7de09677eae9feaa3ef559dbd7 (diff)
version 0.4.10.4.1
-rw-r--r--AERN-RnToRm.cabal8
-rw-r--r--ChangeLog2
-rw-r--r--src/Data/Number/ER/RnToRm/Approx/DomEdges.hs3
-rw-r--r--src/Data/Number/ER/RnToRm/Approx/DomTransl.hs3
-rw-r--r--src/Data/Number/ER/RnToRm/Approx/PieceWise.hs4
-rw-r--r--src/Data/Number/ER/RnToRm/Approx/Tuple.hs3
-rw-r--r--src/Data/Number/ER/RnToRm/DefaultRepr.hs12
-rw-r--r--src/Data/Number/ER/RnToRm/TestingDefs.hs67
-rw-r--r--src/Data/Number/ER/RnToRm/UnitDom/Approx/Interval.hs4
-rw-r--r--src/Data/Number/ER/RnToRm/UnitDom/Base.hs4
-rw-r--r--tests/Demo.hs9
-rw-r--r--tests/ISin3.hs47
12 files changed, 122 insertions, 44 deletions
diff --git a/AERN-RnToRm.cabal b/AERN-RnToRm.cabal
index f58e4ea..a4c84d8 100644
--- a/AERN-RnToRm.cabal
+++ b/AERN-RnToRm.cabal
@@ -1,5 +1,5 @@
Name: AERN-RnToRm
-Version: 0.4
+Version: 0.4.1
Cabal-Version: >= 1.2
Build-Type: Simple
License: BSD3
@@ -34,7 +34,7 @@ Description:
.
Simple examples of usage can be found in module @Demo.hs@ in folder @tests@.
Extra-source-files:
- ChangeLog tests/Demo.hs
+ ChangeLog tests/Demo.hs tests/ISin3.hs
Flag containers-in-base
Default: False
@@ -43,10 +43,10 @@ Library
hs-source-dirs: src
if flag(containers-in-base)
Build-Depends:
- base < 3, binary >= 0.4, AERN-Real >= 0.9.6
+ base < 3, binary >= 0.4, AERN-Real >= 0.9.7
else
Build-Depends:
- base >= 3, containers, binary >= 0.4, AERN-Real >= 0.9.6
+ base >= 3, containers, binary >= 0.4, AERN-Real >= 0.9.7
Exposed-modules:
Data.Number.ER.RnToRm,
Data.Number.ER.RnToRm.BisectionTree.Path,
diff --git a/ChangeLog b/ChangeLog
index 0280297..2118449 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+0.4.1: 30 September 2008
+ * updated to work with AERN-Real 0.9.7
0.4: 20 August 2008
* fixed several serious bugs in sin and cos
* added arctan
diff --git a/src/Data/Number/ER/RnToRm/Approx/DomEdges.hs b/src/Data/Number/ER/RnToRm/Approx/DomEdges.hs
index 15a5fb5..88e395d 100644
--- a/src/Data/Number/ER/RnToRm/Approx/DomEdges.hs
+++ b/src/Data/Number/ER/RnToRm/Approx/DomEdges.hs
@@ -3,6 +3,7 @@
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ScopedTypeVariables #-}
{-|
Module : Data.Number.ER.RnToRm.Approx.DomEdges
Description : separate approximations per domain-box hyper-edge
@@ -185,6 +186,8 @@ instance
(FA.ERFnDomApprox box varid domra ranra fa, VariableID varid) =>
RA.ERApprox (ERFnDomEdgesApprox varid fa)
where
+ initialiseBaseArithmetic _ =
+ RA.initialiseBaseArithmetic (0 :: fa)
getGranularity (ERFnDomEdgesApprox mainEncl edges) =
RA.getGranularity mainEncl
setGranularity gran = edgesLift1 (RA.setGranularity gran)
diff --git a/src/Data/Number/ER/RnToRm/Approx/DomTransl.hs b/src/Data/Number/ER/RnToRm/Approx/DomTransl.hs
index 02ea605..a14ddf2 100644
--- a/src/Data/Number/ER/RnToRm/Approx/DomTransl.hs
+++ b/src/Data/Number/ER/RnToRm/Approx/DomTransl.hs
@@ -5,6 +5,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ScopedTypeVariables #-}
{-|
Module : Data.Number.ER.RnToRm.Approx.DomTransl
Description : enclosures translated from [-1,1]^n to another domain
@@ -260,6 +261,8 @@ instance
, DomainBoxMappable dtrbox box varid (DomTransl domra) domra, Eq dtrbox) =>
RA.ERApprox (ERFnDomTranslApprox dtrbox varid ufa domra)
where
+ initialiseBaseArithmetic _ =
+ RA.initialiseBaseArithmetic (0 :: ufa)
getGranularity (ERFnDomTranslApprox ufa dtrB) =
RA.getGranularity ufa
setGranularity gran (ERFnDomTranslApprox ufa dtrB) =
diff --git a/src/Data/Number/ER/RnToRm/Approx/PieceWise.hs b/src/Data/Number/ER/RnToRm/Approx/PieceWise.hs
index dce8881..6eec389 100644
--- a/src/Data/Number/ER/RnToRm/Approx/PieceWise.hs
+++ b/src/Data/Number/ER/RnToRm/Approx/PieceWise.hs
@@ -3,7 +3,7 @@
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DeriveDataTypeable #-}
-
+{-# LANGUAGE ScopedTypeVariables #-}
{-|
Module : Data.Number.ER.RnToRm.Approx.PieceWise
Description : arbitrary precision piece-wise-something function enclosures
@@ -169,6 +169,8 @@ instance
(FA.ERFnDomApprox box varid domra ranra fa, VariableID varid) =>
RA.ERApprox (ERFnPiecewise box varid domra fa)
where
+ initialiseBaseArithmetic _ =
+ RA.initialiseBaseArithmetic (0 :: fa)
getGranularity (ERFnPiecewise bistr) =
foldl max 10 $ map RA.getGranularity $ BISTR.collectValues bistr
setGranularity gran = pwLift1 (RA.setGranularity gran)
diff --git a/src/Data/Number/ER/RnToRm/Approx/Tuple.hs b/src/Data/Number/ER/RnToRm/Approx/Tuple.hs
index be2e88d..9a43105 100644
--- a/src/Data/Number/ER/RnToRm/Approx/Tuple.hs
+++ b/src/Data/Number/ER/RnToRm/Approx/Tuple.hs
@@ -3,6 +3,7 @@
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ScopedTypeVariables #-}
{-|
Module : Data.Number.ER.RnToRm.Approx.Tuples
Description : a list of approximations over the same domain
@@ -151,6 +152,8 @@ instance
(FA.ERFnDomApprox box varid domra ranra fa) =>
RA.ERApprox (ERFnTuple fa)
where
+ initialiseBaseArithmetic _ =
+ RA.initialiseBaseArithmetic (0 :: fa)
getGranularity (ERFnTuple fas) =
foldl max 10 $ map RA.getGranularity fas
setGranularity gran = tuplesLift1 (RA.setGranularity gran)
diff --git a/src/Data/Number/ER/RnToRm/DefaultRepr.hs b/src/Data/Number/ER/RnToRm/DefaultRepr.hs
index ff33ada..0aa2f23 100644
--- a/src/Data/Number/ER/RnToRm/DefaultRepr.hs
+++ b/src/Data/Number/ER/RnToRm/DefaultRepr.hs
@@ -53,12 +53,12 @@ import Data.Number.ER.RnToRm.Approx.PieceWise
import qualified Data.Map as Map
-type FAPU = ERFnInterval (ERChebPoly (Box Int) B) IRA
-type FAPD = ERFnDomTranslApprox (Box (DomTransl IRA)) VarID FAPU IRA
-type FAPT = ERFnTuple FAPD
-type FAPE = ERFnDomEdgesApprox VarID FAPT
-type FAPWP = ERFnPiecewise (Box IRA) VarID IRA FAPE
+type FAPU b = ERFnInterval (ERChebPoly (Box Int) b) (IRA b)
+type FAPD b = ERFnDomTranslApprox (Box (DomTransl (IRA b))) VarID (FAPU b) (IRA b)
+type FAPT b = ERFnTuple (FAPD b)
+type FAPE b = ERFnDomEdgesApprox VarID (FAPT b)
+type FAPWP b = ERFnPiecewise (Box (IRA b)) VarID (IRA b) (FAPE b)
--type FA = FAPWL
-type FA = FAPWP
+type FA = FAPWP B
diff --git a/src/Data/Number/ER/RnToRm/TestingDefs.hs b/src/Data/Number/ER/RnToRm/TestingDefs.hs
index 58b0784..b9b8469 100644
--- a/src/Data/Number/ER/RnToRm/TestingDefs.hs
+++ b/src/Data/Number/ER/RnToRm/TestingDefs.hs
@@ -23,43 +23,46 @@ import qualified Data.Number.ER.Real.DomainBox as DBox
import qualified Data.Map as Map
-fapuConst1 = (UFA.const [1]) :: FAPU
-
-fapdConst1 = (FA.const DBox.noinfo [1]) :: FAPD
-fapdConstU = (FA.const DBox.noinfo [(-1) RA.\/ 1]) :: FAPD
-fapdConst01 = (FA.const DBox.noinfo [0 RA.\/ 1]) :: FAPD
-fapd04X0 = (FA.proj (DBox.fromAscList [(0,0 RA.\/ 4)]) 0) :: FAPD
-fapd13X0 = (FA.proj (DBox.fromAscList [(0,1 RA.\/ 3)]) 0) :: FAPD
-fapd12X1 = (FA.proj (DBox.fromAscList [(1,1 RA.\/ 2)]) 1) :: FAPD
-fapdUX0 = (FA.proj (DBox.fromAscList [(0,(-1) RA.\/ 1)]) 0) :: FAPD
-fapdUX1 = (FA.proj (DBox.fromAscList [(1,(-1) RA.\/ 1)]) 1) :: FAPD
-
-fapeConst1 = (FA.const DBox.noinfo [1]) :: FAPE
-fapeConstU = (FA.const DBox.noinfo [(-1) RA.\/ 1]) :: FAPE
-fapeConst01 = (FA.const DBox.noinfo [0 RA.\/ 1]) :: FAPE
-
-fape13X0 = (FA.proj (DBox.fromAscList [(0,1 RA.\/ 3)]) 0) :: FAPE
-fape12X1 = (FA.proj (DBox.fromAscList [(1,1 RA.\/ 2)]) 1) :: FAPE
-fapeUX0 = (FA.proj (DBox.fromAscList [(0,(-1) RA.\/ 1)]) 0) :: FAPE
-fapeUX1 = (FA.proj (DBox.fromAscList [(1,(-1) RA.\/ 1)]) 1) :: FAPE
+fapuConst1 = (UFA.const [1]) :: (FAPU B)
+
+fapdConst1 = (FA.const DBox.noinfo [1]) :: (FAPD B)
+fapdConstU = (FA.const DBox.noinfo [(-1) RA.\/ 1]) :: (FAPD B)
+fapdConst01 = (FA.const DBox.noinfo [0 RA.\/ 1]) :: (FAPD B)
+fapd04X0 = (FA.proj (DBox.fromAscList [(0,0 RA.\/ 4)]) 0) :: (FAPD B)
+fapd13X0 = (FA.proj (DBox.fromAscList [(0,1 RA.\/ 3)]) 0) :: (FAPD B)
+fapd12X1 = (FA.proj (DBox.fromAscList [(1,1 RA.\/ 2)]) 1) :: (FAPD B)
+fapdUX0 = (FA.proj (DBox.fromAscList [(0,(-1) RA.\/ 1)]) 0) :: (FAPD B)
+fapdUX1 = (FA.proj (DBox.fromAscList [(1,(-1) RA.\/ 1)]) 1) :: (FAPD B)
+
+fapeConst1 = (FA.const DBox.noinfo [1]) :: (FAPE B)
+fapeConstU = (FA.const DBox.noinfo [(-1) RA.\/ 1]) :: (FAPE B)
+fapeConst01 = (FA.const DBox.noinfo [0 RA.\/ 1]) :: (FAPE B)
+
+fape13X0 = (FA.proj (DBox.fromAscList [(0,1 RA.\/ 3)]) 0) :: (FAPE B)
+fape12X1 = (FA.proj (DBox.fromAscList [(1,1 RA.\/ 2)]) 1) :: (FAPE B)
+fapeUX0 = (FA.proj (DBox.fromAscList [(0,(-1) RA.\/ 1)]) 0) :: (FAPE B)
+fapeUX1 = (FA.proj (DBox.fromAscList [(1,(-1) RA.\/ 1)]) 1) :: (FAPE B)
fapeTestMult = (fapeUX0 + (FA.setMaxDegree 3 fapeConst01)) * (fapeConstU)
fapeMultiVar = (fapeUX0 + fapeUX1 * fapeUX0 + fapeUX1 * fapeUX1)
fapeTestPEval = FA.partialEval (DBox.fromList [(1,2 RA.\/ 3)]) fapeMultiVar
-fapeUConst1 = (FA.const (DBox.unary $ (0)RA.\/1) [1]) :: FAPE
-fapeUConst13 = (FA.const (DBox.unary $ (0)RA.\/1) [1 RA.\/ 3]) :: FAPE
-fapeUConst13InitPt = FA.partialIntersect 1 (DBox.unary 0) fapeUConst13 fapeUConst1
+fapeUConst1 = (FA.const (DBox.unary $ (0)RA.\/1) [1]) :: (FAPE B)
+fapeUConst13 = (FA.const (DBox.unary $ (0)RA.\/1) [1 RA.\/ 3]) :: (FAPE B)
+fapeUConst13InitPt = FA.partialIntersect 1 (DBox.unary 0) fapeUConst1 fapeUConst13
-fapwUUX0 = (FA.proj (DBox.fromAscList [(0,(-1) RA.\/ 1)]) 0) :: FAPWP
-fapwUUX1 = (FA.proj (DBox.fromAscList [(1,(-1) RA.\/ 1)]) 1) :: FAPWP
+fapwUUX0 = (FA.proj (DBox.fromAscList [(0,(-1) RA.\/ 1)]) 0) :: (FAPWP B)
+fapwUUX1 = (FA.proj (DBox.fromAscList [(1,(-1) RA.\/ 1)]) 1) :: (FAPWP B)
-fapwUX0 = (FA.proj (DBox.fromAscList [(0,(0) RA.\/ 1)]) 0) :: FAPWP
-fapwUX1 = (FA.proj (DBox.fromAscList [(1,(0) RA.\/ 1)]) 1) :: FAPWP
+fapwUPX0 = (FA.proj (DBox.fromAscList [(0,(0) RA.\/ 1)]) 0) :: (FAPWP B)
+fapwUPX1 = (FA.proj (DBox.fromAscList [(1,(0) RA.\/ 1)]) 1) :: (FAPWP B)
-fapwUConst1 = (FA.const (DBox.noinfo) [1]) :: FAPWP
-fapwUConst13 = (FA.const (DBox.unary $ (0)RA.\/1) [1 RA.\/ 3]) :: FAPWP
-fapwUConst13InitPt = FA.partialIntersect 1 (DBox.unary 0) fapwUConst13 fapwUConst1
+fapwUMX0 = (FA.proj (DBox.fromAscList [(0,(-1) RA.\/ 0)]) 0) :: (FAPWP B)
+fapwUMX1 = (FA.proj (DBox.fromAscList [(1,(-1) RA.\/ 0)]) 1) :: (FAPWP B)
+
+fapwUConst1 = (FA.const (DBox.noinfo) [1]) :: (FAPWP B)
+fapwUConst13 = (FA.const (DBox.unary $ (0)RA.\/1) [1 RA.\/ 3]) :: (FAPWP B)
+fapwUConst13InitPt = FA.partialIntersect 1 (DBox.unary 0) fapwUConst1 fapwUConst13
testIntegrE =
FA.integrateMeasureImprovement 1 (FA.setMaxDegree 0 fapeUConst13InitPt) 0 (DBox.noinfo) 0 fapeUConst13InitPt
@@ -72,9 +75,15 @@ x =
FA.setMaxDegree 4
fapwUUX0
+y =
+-- FA.bisectUnbisectDepth 1 $
+ FA.setMaxDegree 4
+ fapwUUX1
+
xLR =
snd $ FA.bisect 0 Nothing $ fst $ FA.bisect 0 Nothing $ x
fn1 = (1 + x) RA.\/ (1 + 3*x)
fn2 = FA.integrateUnary 0 fn1 0 (0 RA.\/ 1) [1]
fn3 = FA.integrateUnary 0 fn2 0 (0 RA.\/ 1) [1] -- this seems wrong!
+
diff --git a/src/Data/Number/ER/RnToRm/UnitDom/Approx/Interval.hs b/src/Data/Number/ER/RnToRm/UnitDom/Approx/Interval.hs
index 4e62932..160b17e 100644
--- a/src/Data/Number/ER/RnToRm/UnitDom/Approx/Interval.hs
+++ b/src/Data/Number/ER/RnToRm/UnitDom/Approx/Interval.hs
@@ -3,7 +3,7 @@
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DeriveDataTypeable #-}
-
+{-# LANGUAGE ScopedTypeVariables #-}
{-|
Module : Data.Number.ER.RnToRm.UnitDom.Approx.Interval
Description : arbitrary precision function enclosures on @[-1,1]^n@
@@ -216,6 +216,8 @@ instance
(UFB.ERUnitFnBase boxb boxra varid b ra fb) =>
RA.ERApprox (ERFnInterval fb ra)
where
+ initialiseBaseArithmetic _ =
+ UFB.initialiseBaseArithmetic (0 :: fb)
getGranularity (ERFnIntervalAny ctxt) = erfnCoeffGranularity ctxt
getGranularity (ERFnInterval h ln ctxt gl) =
max (erfnCoeffGranularity ctxt) $
diff --git a/src/Data/Number/ER/RnToRm/UnitDom/Base.hs b/src/Data/Number/ER/RnToRm/UnitDom/Base.hs
index d3dfd40..293c2d1 100644
--- a/src/Data/Number/ER/RnToRm/UnitDom/Base.hs
+++ b/src/Data/Number/ER/RnToRm/UnitDom/Base.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
+{-# LANGUAGE ScopedTypeVariables #-}
{-|
Module : Data.Number.ER.RnToRm.UnitDom.Base
Description : class abstracting imprecise function arithmetic on [-1,1]^n
@@ -36,6 +37,9 @@ class
ERUnitFnBase boxb boxra varid b ra ufb
| ufb -> boxb boxra varid b ra
where
+ initialiseBaseArithmetic :: ufb -> IO ()
+ initialiseBaseArithmetic _ =
+ B.initialiseBaseArithmetic (0 :: b)
{-|
Check internal consistency of the function and report problem if any.
-}
diff --git a/tests/Demo.hs b/tests/Demo.hs
index 97f483b..52619f7 100644
--- a/tests/Demo.hs
+++ b/tests/Demo.hs
@@ -13,14 +13,17 @@
module Main where
import qualified Data.Number.ER.RnToRm as AERNFunc
-import Data.Number.ER.RnToRm (FAPWP)
import qualified Data.Number.ER.Real.DomainBox as DBox
import qualified Data.Number.ER.Real as AERN
-import Data.Number.ER.Real (IRA)
import Data.Number.ER.Misc
+type B = AERN.BM -- use machine double as a basis
+type RA = AERN.RA B
+type IRA = AERN.IRA B
+type FAPWP = AERNFunc.FAPWP B
+
-- function f(x) = x for x in [0,1]:
x :: FAPWP
x =
@@ -80,7 +83,7 @@ fn5 =
main =
do
- AERN.initMachineDouble
+ AERN.initialiseBaseArithmetic (0 :: RA)
putStrLn "****************************************"
putStrLn "Testing polynomial enclosure arithmetic:"
putStrLn "****************************************"
diff --git a/tests/ISin3.hs b/tests/ISin3.hs
new file mode 100644
index 0000000..2413708
--- /dev/null
+++ b/tests/ISin3.hs
@@ -0,0 +1,47 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE UndecidableInstances #-}
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+module Main
+
+where
+
+import qualified Data.Number.ER.Real as AERN
+import qualified Data.Number.ER.RnToRm as AERNFunc
+import Data.Number.ER.BasicTypes
+import Data.Number.ER.Misc
+import Data.Number.ER.RnToRm.TestingDefs
+
+import Data.Maybe
+import qualified Data.List as List
+import qualified Data.Map as Map
+
+#ifdef USE_MPFR
+type B = AERN.BMPFR -- use MPFR floats
+#else
+type B = AERN.BAP -- use pure Haskell floats
+--type B = AERN.BMAP -- use combination of double and pure Haskell floats
+#endif
+type RA = AERN.RA B
+type IRA = AERN.IRA B
+
+main =
+ do
+ AERN.initialiseBaseArithmetic (0 :: RA)
+ putStrLn $ "integ(sin(sin(sin(x)))dx = " ++ show result
+ putStrLn $ " precision = " ++ show (AERN.getPrecision result)
+ where
+ result =
+ head $
+ AERNFunc.eval (AERNFunc.unary 1) $
+ AERNFunc.integrateUnary 0
+ (sin3 60 0 21 60)
+ 0 (0 AERN.\/ 1) [0]
+ sin3 ix depth deg gran =
+ AERN.sin ix $
+ AERN.sin ix $
+ AERN.sin ix $
+ AERNFunc.bisectUnbisectDepth depth $
+ AERN.setMinGranularity gran $
+ AERNFunc.setMaxDegree deg fapwUPX0
+