diff options
-rw-r--r-- | examples/tests.hs | 16 |
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) | |||
19 | type RM = Matrix Double | 19 | type RM = Matrix Double |
20 | type CM = Matrix (Complex Double) | 20 | type CM = Matrix (Complex Double) |
21 | 21 | ||
22 | -- relative error | ||
22 | dist :: (Normed t, Num t) => t -> t -> Double | 23 | dist :: (Normed t, Num t) => t -> t -> Double |
23 | dist a b = pnorm Infinity (a-b) | 24 | dist 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 | ||
25 | infixl 4 |~| | 33 | infixl 4 |~| |
26 | a |~| b = a :~8~: b | 34 | a |~| b = a :~10~: b |
27 | 35 | ||
28 | data Aprox a = (:~) a Int | 36 | data 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 |