summaryrefslogtreecommitdiff
path: root/examples/tests.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tests.hs')
-rw-r--r--examples/tests.hs23
1 files changed, 21 insertions, 2 deletions
diff --git a/examples/tests.hs b/examples/tests.hs
index e91b9f1..8224255 100644
--- a/examples/tests.hs
+++ b/examples/tests.hs
@@ -193,6 +193,14 @@ unitary m = square m && m <> ctrans m |~| ident (rows m)
193 193
194hermitian m = m |~| ctrans m 194hermitian m = m |~| ctrans m
195 195
196upperTriang m = rows m == 1 || down == z
197 where down = fromList $ concat $ zipWith drop [1..] (toLists (ctrans m))
198 z = constant 0 (dim down)
199
200upperHessenberg m = rows m < 3 || down == z
201 where down = fromList $ concat $ zipWith drop [2..] (toLists (ctrans m))
202 z = constant 0 (dim down)
203
196svdTest svd m = u <> real d <> trans v |~| m 204svdTest svd m = u <> real d <> trans v |~| m
197 && unitary u && unitary v 205 && unitary u && unitary v
198 where (u,d,v) = full svd m 206 where (u,d,v) = full svd m
@@ -274,16 +282,24 @@ cholCTest = chol ((2><2) [1,2,2,9::Complex Double]) == (2><2) [1,2,0,2.236067977
274 282
275--------------------------------------------------------------------- 283---------------------------------------------------------------------
276 284
277qrTest qr m = q <> r |~| m && unitary q 285qrTest qr m = q <> r |~| m && unitary q && upperTriang r
278 where (q,r) = qr m 286 where (q,r) = qr m
279 287
280--------------------------------------------------------------------- 288---------------------------------------------------------------------
281 289
282hessTest m = m |~| p <> h <> ctrans p && unitary p 290hessTest m = m |~| p <> h <> ctrans p && unitary p && upperHessenberg h
283 where (p,h) = hess m 291 where (p,h) = hess m
284 292
285--------------------------------------------------------------------- 293---------------------------------------------------------------------
286 294
295schurTest1 m = m |~| u <> s <> ctrans u && unitary u && upperTriang s
296 where (u,s) = schur m
297
298schurTest2 m = m |~| u <> s <> ctrans u && unitary u && upperHessenberg s -- fixme
299 where (u,s) = schur m
300
301---------------------------------------------------------------------
302
287asFortran m = (rows m >|< cols m) $ toList (fdat m) 303asFortran m = (rows m >|< cols m) $ toList (fdat m)
288asC m = (rows m >< cols m) $ toList (cdat m) 304asC m = (rows m >< cols m) $ toList (cdat m)
289 305
@@ -346,6 +362,9 @@ tests = do
346 putStrLn "--------- hess --------" 362 putStrLn "--------- hess --------"
347 quickCheck (hessTest . sqm ::SqM Double->Bool) 363 quickCheck (hessTest . sqm ::SqM Double->Bool)
348 quickCheck (hessTest . sqm ::SqM (Complex Double) -> Bool) 364 quickCheck (hessTest . sqm ::SqM (Complex Double) -> Bool)
365 putStrLn "--------- schur --------"
366 quickCheck (schurTest2 . sqm ::SqM Double->Bool)
367 quickCheck (schurTest1 . sqm ::SqM (Complex Double) -> Bool)
349 putStrLn "--------- nullspace ------" 368 putStrLn "--------- nullspace ------"
350 quickCheck (nullspaceTest :: RM -> Bool) 369 quickCheck (nullspaceTest :: RM -> Bool)
351 quickCheck (nullspaceTest :: CM -> Bool) 370 quickCheck (nullspaceTest :: CM -> Bool)