summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/Tests/Properties.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2008-02-03 12:52:17 +0000
committerAlberto Ruiz <aruiz@um.es>2008-02-03 12:52:17 +0000
commit2747c2ba403dafcc52bac09d2fd51b6d66fa5e9e (patch)
tree8115445612f0c43f67649e9ed701e1d483bda9da /lib/Numeric/LinearAlgebra/Tests/Properties.hs
parentbac0db0bb1a25aa8be87a79492517aa8098670e6 (diff)
test modules reorganized
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Tests/Properties.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/Tests/Properties.hs50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/Numeric/LinearAlgebra/Tests/Properties.hs b/lib/Numeric/LinearAlgebra/Tests/Properties.hs
new file mode 100644
index 0000000..ad31454
--- /dev/null
+++ b/lib/Numeric/LinearAlgebra/Tests/Properties.hs
@@ -0,0 +1,50 @@
1{-# OPTIONS #-}
2-----------------------------------------------------------------------------
3{- |
4Module : Numeric.LinearAlgebra.Tests.Properties
5Copyright : (c) Alberto Ruiz 2008
6License : GPL-style
7
8Maintainer : Alberto Ruiz (aruiz at um dot es)
9Stability : provisional
10Portability : portable
11
12Arbitrary instances for vectors, matrices.
13
14-}
15
16module Numeric.LinearAlgebra.Tests.Properties
17
18where
19
20import Numeric.LinearAlgebra
21import Numeric.LinearAlgebra.Tests.Instances(Sq(..),Her(..),Rot(..))
22
23-- relative error
24dist :: (Normed t, Num t) => t -> t -> Double
25dist a b = r
26 where norm = pnorm Infinity
27 na = norm a
28 nb = norm b
29 nab = norm (a-b)
30 mx = max na nb
31 mn = min na nb
32 r = if mn < eps
33 then mx
34 else nab/mx
35
36infixl 4 |~|
37--a |~| b = a :~10~: b
38a |~| b = dist a b < 10^^(-10)
39
40--data Aprox a = (:~) a Int
41--(~:) :: (Normed a, Num a) => Aprox a -> a -> Bool
42--a :~n~: b = dist a b < 10^^(-n)
43
44------------------------------------------------------
45
46square m = rows m == cols m
47
48unitary m = square m && m <> ctrans m |~| ident (rows m)
49
50hermitian m = square m && m |~| ctrans m