{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-} module Test.MathObj.Gaussian.Variance where import qualified MathObj.Gaussian.Variance as G -- import qualified Algebra.Ring as Ring import qualified Algebra.Laws as Laws import Test.NumericPrelude.Utility (testUnit) import Test.QuickCheck (Testable, quickCheck, (==>)) import qualified Test.HUnit as HUnit import Data.Function.HT (nest, ) import PreludeBase as P import NumericPrelude as NP simple :: (Testable t) => (G.T Rational -> t) -> IO () simple f = quickCheck (\x -> f (x :: G.T Rational)) tests :: HUnit.Test tests = HUnit.TestLabel "polynomial" \$ HUnit.TestList \$ map testUnit \$ {- ("convolution, dirac", simple \$ Laws.identity (+) zero) : -} ("convolution, commutative", simple \$ Laws.commutative G.convolve) : ("convolution, associative", simple \$ Laws.associative G.convolve) : ("multiplication, one", simple \$ Laws.identity G.multiply G.constant) : ("multiplication, commutative", simple \$ Laws.commutative G.multiply) : ("multiplication, associative", simple \$ Laws.associative G.multiply) : ("convolution via fourier", simple \$ \x y -> G.fourier (G.convolve x y) == G.multiply (G.fourier x) (G.fourier y)) : ("fourier identity", simple \$ \x -> nest 4 G.fourier x == x) : ("dilate multiplicative", simple \$ \x a b -> a>0 && b>0 ==> G.dilate a (G.dilate b x) == G.dilate (a*b) x) : ("dilate by shrink", simple \$ \x a -> a>0 ==> G.shrink a x == G.dilate (recip a) x) : ("fourier dilate", simple \$ \x a -> a>0 ==> G.fourier (G.dilate a x) == G.shrink a (G.fourier x)) : []