summaryrefslogtreecommitdiff
path: root/examples/oldtests.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-09-14 18:23:20 +0000
committerAlberto Ruiz <aruiz@um.es>2007-09-14 18:23:20 +0000
commitd14515a4a50d5b5335f9c1525432b68ab67fa7c8 (patch)
treefb07b2e27b4b5cebc32a3c7ee064ef376344d7e7 /examples/oldtests.hs
parent9e2f7fb0ca902665b430a96f77959522976a97f9 (diff)
more refactoring
Diffstat (limited to 'examples/oldtests.hs')
-rw-r--r--examples/oldtests.hs20
1 files changed, 10 insertions, 10 deletions
diff --git a/examples/oldtests.hs b/examples/oldtests.hs
index b01675f..f60f4e2 100644
--- a/examples/oldtests.hs
+++ b/examples/oldtests.hs
@@ -5,14 +5,14 @@ import System.Random(randomRs,mkStdGen)
5realMatrix = fromLists :: [[Double]] -> Matrix Double 5realMatrix = fromLists :: [[Double]] -> Matrix Double
6realVector = fromList :: [Double] -> Vector Double 6realVector = fromList :: [Double] -> Vector Double
7 7
8toComplexM = uncurry $ liftMatrix2 (curry toComplex) 8
9 9
10infixl 2 =~= 10infixl 2 =~=
11a =~= b = pnorm 1 (flatten (a - b)) < 1E-6 11a =~= b = pnorm 1 (flatten (a - b)) < 1E-6
12 12
13randomMatrix seed (n,m) = reshape m $ realVector $ take (n*m) $ randomRs (-100,100) $ mkStdGen seed 13randomMatrix seed (n,m) = reshape m $ realVector $ take (n*m) $ randomRs (-100,100) $ mkStdGen seed
14 14
15randomMatrixC seed (n,m) = toComplexM (randomMatrix seed (n,m), randomMatrix (seed+1) (n,m)) 15randomMatrixC seed (n,m) = toComplex (randomMatrix seed (n,m), randomMatrix (seed+1) (n,m))
16 16
17besselTest = do 17besselTest = do
18 let (r,e) = bessel_J0_e 5.0 18 let (r,e) = bessel_J0_e 5.0
@@ -31,7 +31,7 @@ ms = realMatrix [[1,2,3]
31 31
32ms' = randomMatrix 27 (50,100) 32ms' = randomMatrix 27 (50,100)
33 33
34ms'' = toComplexM (randomMatrix 100 (50,100),randomMatrix 101 (50,100)) 34ms'' = toComplex (randomMatrix 100 (50,100),randomMatrix 101 (50,100))
35 35
36fullsvdTest method mat msg = do 36fullsvdTest method mat msg = do
37 let (u,s,vt) = method mat 37 let (u,s,vt) = method mat
@@ -43,7 +43,7 @@ full_svd_Rd = svdRdd
43 43
44-------------------------------------------------------------------- 44--------------------------------------------------------------------
45 45
46mcu = toComplexM (randomMatrix 33 (20,20),randomMatrix 34 (20,20)) 46mcu = toComplex (randomMatrix 33 (20,20),randomMatrix 34 (20,20))
47 47
48mcur = randomMatrix 35 (40,40) 48mcur = randomMatrix 35 (40,40)
49 49
@@ -53,7 +53,7 @@ eigTest method m msg = do
53 assertBool msg $ m <> v =~= v <> diag s 53 assertBool msg $ m <> v =~= v <> diag s
54 54
55bigmat = m + trans m where m = randomMatrix 18 (1000,1000) 55bigmat = m + trans m where m = randomMatrix 18 (1000,1000)
56bigmatc = mc + conjTrans mc where mc = toComplexM(m,m) 56bigmatc = mc + conjTrans mc where mc = toComplex(m,m)
57 m = randomMatrix 19 (1000,1000) 57 m = randomMatrix 19 (1000,1000)
58 58
59-------------------------------------------------------------------- 59--------------------------------------------------------------------
@@ -62,22 +62,22 @@ invTest msg m = do
62 assertBool msg $ m <> inv m =~= ident (rows m) 62 assertBool msg $ m <> inv m =~= ident (rows m)
63 63
64invComplexTest msg m = do 64invComplexTest msg m = do
65 assertBool msg $ m <> invC m =~= ident (rows m) 65 assertBool msg $ m <> invC m =~= identC (rows m)
66 66
67invC m = linearSolveC m (ident (rows m)) 67invC m = linearSolveC m (identC (rows m))
68 68
69--identC n = toComplexM(ident n, (0::Double) <>ident n) 69identC = comp . ident
70 70
71-------------------------------------------------------------------- 71--------------------------------------------------------------------
72 72
73pinvTest f msg m = do 73pinvTest f msg m = do
74 assertBool msg $ m <> f m <> m =~= m 74 assertBool msg $ m <> f m <> m =~= m
75 75
76pinvC m = linearSolveLSC m (ident (rows m)) 76pinvC m = linearSolveLSC m (identC (rows m))
77 77
78pinvSVDR m = linearSolveSVDR Nothing m (ident (rows m)) 78pinvSVDR m = linearSolveSVDR Nothing m (ident (rows m))
79 79
80pinvSVDC m = linearSolveSVDC Nothing m (ident (rows m)) 80pinvSVDC m = linearSolveSVDC Nothing m (identC (rows m))
81 81
82-------------------------------------------------------------------- 82--------------------------------------------------------------------
83 83