summaryrefslogtreecommitdiff
path: root/examples/tests.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2008-01-22 11:13:38 +0000
committerAlberto Ruiz <aruiz@um.es>2008-01-22 11:13:38 +0000
commite92696514c8861e7bed7abb434ca24527861c05c (patch)
tree9a01571a13d4b95f37da3229055d92afce93b6a5 /examples/tests.hs
parent1bdc3af98f098f45e97e9c1a3225c5dcb64e3119 (diff)
improved relative error in the tests
Diffstat (limited to 'examples/tests.hs')
-rw-r--r--examples/tests.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/tests.hs b/examples/tests.hs
index e20f871..6bc1922 100644
--- a/examples/tests.hs
+++ b/examples/tests.hs
@@ -21,14 +21,16 @@ type CM = Matrix (Complex Double)
21 21
22-- relative error 22-- relative error
23dist :: (Normed t, Num t) => t -> t -> Double 23dist :: (Normed t, Num t) => t -> t -> Double
24dist a b = f nab na nb 24dist a b = r
25 where norm = pnorm Infinity 25 where norm = pnorm Infinity
26 na = norm a 26 na = norm a
27 nb = norm b 27 nb = norm b
28 nab = norm (a-b) 28 nab = norm (a-b)
29 f _ a 0 = a 29 mx = max na nb
30 f _ 0 b = b 30 mn = min na nb
31 f d a b = d / max a b 31 r = if mn < eps
32 then mx
33 else nab/mx
32 34
33infixl 4 |~| 35infixl 4 |~|
34a |~| b = a :~10~: b 36a |~| b = a :~10~: b