summaryrefslogtreecommitdiff
path: root/examples/tests.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-11-26 08:47:42 +0000
committerAlberto Ruiz <aruiz@um.es>2007-11-26 08:47:42 +0000
commit975d3730a923387f9d1a0be4f7d11b01b27a09df (patch)
tree90a9d6e64eb36e60dfcdf6e0486f7ae9474a3808 /examples/tests.hs
parentb90ee438d08b31f71db10dcf6ab5ac6b41383302 (diff)
improved tests
Diffstat (limited to 'examples/tests.hs')
-rw-r--r--examples/tests.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/examples/tests.hs b/examples/tests.hs
index c15a750..2d6b7e9 100644
--- a/examples/tests.hs
+++ b/examples/tests.hs
@@ -19,11 +19,19 @@ import System(getArgs)
19type RM = Matrix Double 19type RM = Matrix Double
20type CM = Matrix (Complex Double) 20type CM = Matrix (Complex Double)
21 21
22-- relative error
22dist :: (Normed t, Num t) => t -> t -> Double 23dist :: (Normed t, Num t) => t -> t -> Double
23dist a b = pnorm Infinity (a-b) 24dist a b = f nab na nb
25 where norm = pnorm Infinity
26 na = norm a
27 nb = norm b
28 nab = norm (a-b)
29 f _ a 0 = a
30 f _ 0 b = b
31 f d a b = d / max a b
24 32
25infixl 4 |~| 33infixl 4 |~|
26a |~| b = a :~8~: b 34a |~| b = a :~10~: b
27 35
28data Aprox a = (:~) a Int 36data Aprox a = (:~) a Int
29 37
@@ -391,10 +399,10 @@ tests = do
391 quickCheck (invTest . sqm :: SqM Double -> Bool) 399 quickCheck (invTest . sqm :: SqM Double -> Bool)
392 quickCheck (invTest . sqm :: SqM (Complex Double) -> Bool) 400 quickCheck (invTest . sqm :: SqM (Complex Double) -> Bool)
393 putStrLn "--------- pinv ------" 401 putStrLn "--------- pinv ------"
394 quickCheck (pinvTest . sqm :: SqM Double -> Bool) 402 quickCheck (pinvTest ::RM->Bool)
395 if os == "mingw32" 403 if os == "mingw32"
396 then putStrLn "complex pinvTest skipped in this OS" 404 then putStrLn "complex pinvTest skipped in this OS"
397 else quickCheck (pinvTest . sqm :: SqM (Complex Double) -> Bool) 405 else quickCheck (pinvTest ::CM->Bool)
398 putStrLn "--------- chol ------" 406 putStrLn "--------- chol ------"
399 runTestTT $ TestList 407 runTestTT $ TestList
400 [ test "cholR" cholRTest 408 [ test "cholR" cholRTest