From e5387206db024f55c19a62e7b1d324364c5f2d23 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Thu, 21 Feb 2008 19:00:22 +0000 Subject: working on tests --- lib/Numeric/LinearAlgebra/Tests.hs | 67 +++++++++++++++++++++++++++ lib/Numeric/LinearAlgebra/Tests/Properties.hs | 5 ++ 2 files changed, 72 insertions(+) create mode 100644 lib/Numeric/LinearAlgebra/Tests.hs (limited to 'lib/Numeric') diff --git a/lib/Numeric/LinearAlgebra/Tests.hs b/lib/Numeric/LinearAlgebra/Tests.hs new file mode 100644 index 0000000..534eb04 --- /dev/null +++ b/lib/Numeric/LinearAlgebra/Tests.hs @@ -0,0 +1,67 @@ +----------------------------------------------------------------------------- +{- | +Module : Numeric.LinearAlgebra.Tests +Copyright : (c) Alberto Ruiz 2007 +License : GPL-style + +Maintainer : Alberto Ruiz (aruiz at um dot es) +Stability : provisional +Portability : portable + +Some tests. + +-} + +module Numeric.LinearAlgebra.Tests( + module Numeric.LinearAlgebra.Tests.Instances, + module Numeric.LinearAlgebra.Tests.Properties, + qCheck,RM,CM, rM,cM, rHer,cHer,rRot,cRot,rSq,cSq, + runTests +--, runBigTests +) where + +import Numeric.LinearAlgebra +import Numeric.LinearAlgebra.Tests.Instances +import Numeric.LinearAlgebra.Tests.Properties +import Test.QuickCheck +import Debug.Trace + +qCheck n = check defaultConfig {configSize = const n} + +debug x = trace (show x) x + +type RM = Matrix Double +type CM = Matrix (Complex Double) + +rM m = m :: RM +cM m = m :: CM + +rHer (Her m) = m :: RM +cHer (Her m) = m :: CM + +rRot (Rot m) = m :: RM +cRot (Rot m) = m :: CM + +rSq (Sq m) = m :: RM +cSq (Sq m) = m :: CM + +rWC (WC m) = m :: RM +cWC (WC m) = m :: CM + +-- | It runs all the tests. +runTests :: Int -- ^ maximum dimension + -> IO () +runTests n = do + qCheck n (hermitian . rHer) + qCheck n (hermitian . cHer) + qCheck n (unitary . rRot) + qCheck n (unitary . cRot) + qCheck n (wellCond . rWC) + qCheck n (wellCond . cWC) + -------------------------------- + qCheck n (luTest . rM) + qCheck n (luTest . cM) + +-- | Some additional tests on big matrices. They take a few minutes. +runBigTests :: IO () +runBigTests = undefined diff --git a/lib/Numeric/LinearAlgebra/Tests/Properties.hs b/lib/Numeric/LinearAlgebra/Tests/Properties.hs index 6686b97..351615b 100644 --- a/lib/Numeric/LinearAlgebra/Tests/Properties.hs +++ b/lib/Numeric/LinearAlgebra/Tests/Properties.hs @@ -52,3 +52,8 @@ hermitian m = square m && m |~| ctrans m degenerate m = rank m < min (rows m) (cols m) wellCond m = rcond m > 1/100 + +----------------------------------------------------- + +luTest m = m |~| p <> l <> u && det p == s + where (l,u,p,s) = lu m -- cgit v1.2.3