{-|
    Module      :  Data.Number.ER.Real.TestingDefs
    Description :  definitions useful for testing in ghci
    Copyright   :  (c) 2007-2008 Michal Konecny
    License     :  BSD3

    Maintainer  :  mik@konecny.aow.cz
    Stability   :  experimental
    Portability :  non-portable (requires fenv.h)

    A few definitions useful for testing the enclosures code, eg in ghci.
-}
module Data.Number.ER.RnToRm.TestingDefs where

import Data.Number.ER.RnToRm.DefaultRepr
import Data.Number.ER.Real.DefaultRepr

import qualified Data.Number.ER.RnToRm.Approx as FA
import qualified Data.Number.ER.RnToRm.UnitDom.Approx as UFA
import qualified Data.Number.ER.Real.Approx as RA
import qualified Data.Number.ER.Real.Approx.Elementary as RAEL
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

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
 
fapwUUX0 = (FA.proj (DBox.fromAscList [(0,(-1) RA.\/ 1)]) 0) :: FAPWP
fapwUUX1 = (FA.proj (DBox.fromAscList [(1,(-1) RA.\/ 1)]) 1) :: FAPWP

fapwUX0 = (FA.proj (DBox.fromAscList [(0,(0) RA.\/ 1)]) 0) :: FAPWP
fapwUX1 = (FA.proj (DBox.fromAscList [(1,(0) RA.\/ 1)]) 1) :: FAPWP

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 

testIntegrE = 
    FA.integrateMeasureImprovement 1 (FA.setMaxDegree 0 fapeUConst13InitPt) 0 (DBox.noinfo) 0 fapeUConst13InitPt

testIntegrP = 
    FA.integrateMeasureImprovement 1 (FA.setMaxDegree 0 fapwUConst13InitPt) 0 (DBox.unary $ 0 RA.\/ 0.5) 0 fapwUConst13InitPt

x = 
--    FA.bisectUnbisectDepth 1 $
    FA.setMaxDegree 4 
    fapwUUX0
    
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!