summaryrefslogtreecommitdiff
path: root/examples/tests.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-12-03 10:43:52 +0000
committerAlberto Ruiz <aruiz@um.es>2007-12-03 10:43:52 +0000
commitc520939e33cc895febed271d5c3218457317bba9 (patch)
tree8661410a5cb946a3ae40e0c0fbacccccd0fd5ada /examples/tests.hs
parentd7d3b731c037fca41bd9128c3da2a582189cb4d9 (diff)
lapack lu
Diffstat (limited to 'examples/tests.hs')
-rw-r--r--examples/tests.hs27
1 files changed, 25 insertions, 2 deletions
diff --git a/examples/tests.hs b/examples/tests.hs
index 60bef8f..e20f871 100644
--- a/examples/tests.hs
+++ b/examples/tests.hs
@@ -187,7 +187,22 @@ bf = (3>|<4) [7,11,15,8,12,16,9,13,17,10,14,18::Double]
187 187
188------------------------------------------------------- 188-------------------------------------------------------
189 189
190detTest = det m == 26 && det mc == 38 :+ (-3) 190feye n = flipud (ident n) :: Matrix Double
191
192
193luTest1 m = m |~| p <> l <> u
194 where (l,u,p,_) = lu m
195
196detTest1 = det m == 26
197 && det mc == 38 :+ (-3)
198 && det (feye 2) == -1
199
200detTest2 m = s d1 |~| s d2
201 where d1 = det m
202 d2 = det' m * det q
203 det' m = product $ toList $ takeDiag r
204 (q,r) = qr m
205 s x = fromList [x]
191 206
192invTest m = degenerate m || m <> inv m |~| ident (rows m) 207invTest m = degenerate m || m <> inv m |~| ident (rows m)
193 208
@@ -394,6 +409,14 @@ tests = do
394 quickCheck $ \(PairM m1 m2) -> mulC m1 m2 == trans (mulF (trans m2) (trans m1 :: CM)) 409 quickCheck $ \(PairM m1 m2) -> mulC m1 m2 == trans (mulF (trans m2) (trans m1 :: CM))
395 quickCheck $ \(PairM m1 m2) -> mulC m1 m2 == multiplyG m1 (m2 :: RM) 410 quickCheck $ \(PairM m1 m2) -> mulC m1 m2 == multiplyG m1 (m2 :: RM)
396 quickCheck $ \(PairM m1 m2) -> mulC m1 m2 == multiplyG m1 (m2 :: CM) 411 quickCheck $ \(PairM m1 m2) -> mulC m1 m2 == multiplyG m1 (m2 :: CM)
412 putStrLn "--------- lu ---------"
413 quickCheck (luTest1 :: RM->Bool)
414 quickCheck (luTest1 :: CM->Bool)
415 quickCheck (detTest2 . sqm :: SqM Double -> Bool)
416 quickCheck (detTest2 . sqm :: SqM (Complex Double) -> Bool)
417 runTestTT $ TestList
418 [ test "det1" detTest1
419 ]
397 putStrLn "--------- svd ---------" 420 putStrLn "--------- svd ---------"
398 quickCheck (svdTest svdR) 421 quickCheck (svdTest svdR)
399 quickCheck (svdTest svdRdd) 422 quickCheck (svdTest svdRdd)
@@ -462,7 +485,6 @@ tests = do
462 , exponentialTest 485 , exponentialTest
463 , integrateTest 486 , integrateTest
464 , polySolveTest 487 , polySolveTest
465 , test "det" detTest
466 ] 488 ]
467 489
468bigtests = do 490bigtests = do
@@ -472,6 +494,7 @@ bigtests = do
472 , test "eigH" $ eigTestSH bigmatc 494 , test "eigH" $ eigTestSH bigmatc
473 , test "eigR" $ eigTest bigmat 495 , test "eigR" $ eigTest bigmat
474 , test "eigC" $ eigTest bigmatc 496 , test "eigC" $ eigTest bigmatc
497 , test "det" $ det (feye 1000) == 1 && det (feye 1002) == -1
475 ] 498 ]
476 499
477main = do 500main = do