{-|
    Module      :  Data.Number.ER.RnToRm.UnitDom.ChebyshevBase.Polynom.Tests.Elementary
    Description :  (testing) properties of enclosure elementary operations
    Copyright   :  (c) 2007-2008 Michal Konecny
    License     :  BSD3

    Maintainer  :  mik@konecny.aow.cz
    Stability   :  experimental
    Portability :  portable
    
    Quickcheck properties of some elementary operations on primitive polynomial
    enclosures.
-}
module Data.Number.ER.RnToRm.UnitDom.ChebyshevBase.Polynom.Tests.Elementary
where

import Data.Number.ER.RnToRm.UnitDom.ChebyshevBase.Polynom.Elementary
import Data.Number.ER.RnToRm.UnitDom.ChebyshevBase.Polynom.Enclosure
--import Data.Number.ER.RnToRm.UnitDom.ChebyshevBase.Polynom.Basic
import Data.Number.ER.RnToRm.UnitDom.ChebyshevBase.Polynom.Tests.Generate

import qualified Data.Number.ER.Real.Approx as RA
import Data.Number.ER.Real.Approx.Interval
import Data.Number.ER.Real.Arithmetic.Elementary

import Data.Number.ER.BasicTypes

import Test.QuickCheck

prop_enclExp_ThickEncl_consistent =
    encl_op_ThickEncl_consistent enclExp erExp_IR_Inner noDomainRestriction

prop_enclExp_ParalEncl_consistent =
    encl_op_ParalEncl_consistent enclExp erExp_IR_Inner noDomainRestriction
    
prop_enclExp_ThinEncl_consistent =
    encl_op_ThinEncl_consistent enclExp erExp_IR_Inner noDomainRestriction
    
prop_enclSine_ThickEncl_consistent =
    encl_op_ThickEncl_consistent enclSine erSine_IR_Inner sincosDomain

prop_enclSine_ParalEncl_consistent =
    encl_op_ParalEncl_consistent enclSine erSine_IR_Inner sincosDomain
    
prop_enclSine_ThinEncl_consistent =
    encl_op_ThinEncl_consistent enclSine erSine_IR_Inner sincosDomain
    
prop_enclCosine_ThickEncl_consistent =
    encl_op_ThickEncl_consistent enclCosine erCosine_IR_Inner sincosDomain

prop_enclCosine_ParalEncl_consistent =
    encl_op_ParalEncl_consistent enclCosine erCosine_IR_Inner sincosDomain
    
prop_enclCosine_ThinEncl_consistent =
    encl_op_ThinEncl_consistent enclCosine erCosine_IR_Inner sincosDomain
    
prop_enclAtan_ThickEncl_consistent =
    encl_op_ThickEncl_consistent enclAtan erATan_IR_Inner noDomainRestriction

prop_enclAtan_ParalEncl_consistent =
    encl_op_ParalEncl_consistent enclAtan erATan_IR_Inner noDomainRestriction
    
prop_enclAtan_ThinEncl_consistent =
    encl_op_ThinEncl_consistent enclAtan erATan_IR_Inner noDomainRestriction

sincosDomain = (Just (-1.57), Just 1.57) -- almost (-pi/2, pi/2)
noDomainRestriction = (Nothing, Nothing)
    
encl_op_ThickEncl_consistent
        opEncl opInner rangeRestriction
        reportFileName
        (Deg20Size20 maxDegree maxSize,
         (Int20 ixInt),
         (PSize30 (n1,p1), PSize30 (n2, p2))) =
    enclAtKeyPointsPointwiseUnaryDownUpConsistent
        reportFileName
        ((maxDegree, maxSize), ixInt, (n1, n2)) 
        (opInner ix) 
        pEncl resEncl
    where
    (succeeded, pEncl) = 
        enclRestrictRange ix rangeRestriction $ makeThickEncl maxDegree maxSize p1 p2 
    resEncl = opEncl maxDegree maxSize ix pEncl
    ix = int2effIx ixInt
    
encl_op_ParalEncl_consistent
        opEncl opInner rangeRestriction
        reportFileName
        (Deg20Size20 maxDegree maxSize,
         (Int20 ixInt),
         (SmallRatio wNum wDenom, PSize30 (n, p))) =
    enclAtKeyPointsPointwiseUnaryDownUpConsistent 
        reportFileName
        ((maxDegree, maxSize), ixInt, ((wNum, wDenom), n)) 
        (opInner ix) 
        pEncl resEncl
    where
    (succeeded, pEncl) = 
        enclRestrictRange ix rangeRestriction $ makeParalEncl p wNum wDenom 
    resEncl = opEncl maxDegree maxSize ix pEncl
    ix = int2effIx ixInt
    
encl_op_ThinEncl_consistent
        opEncl opInner rangeRestriction
        reportFileName
        (Deg20Size20 maxDegree maxSize,
         (Int20 ixInt),
         (PSize30 (n, p))) =
    enclAtKeyPointsPointwiseUnaryDownUpConsistent 
        reportFileName
        ((maxDegree, maxSize), ixInt, n) 
        (opInner ix)
        pEncl resEncl
    where
    (succeeded, pEncl) = 
        enclRestrictRange ix rangeRestriction $ enclThin p 
    resEncl = opEncl maxDegree maxSize ix pEncl
    ix = int2effIx ixInt