summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-10-31 12:47:19 +0000
committerAlberto Ruiz <aruiz@um.es>2007-10-31 12:47:19 +0000
commitbf838323545fe0878382f8f4d41b0f36714afa43 (patch)
tree296198dfcea483ffa933018471a01482066d96b0 /examples
parentf637161ac988979b35ab7254f753a67df8ec812a (diff)
added general expm described in Golub and Van Loan
Diffstat (limited to 'examples')
-rw-r--r--examples/tests.hs32
1 files changed, 29 insertions, 3 deletions
diff --git a/examples/tests.hs b/examples/tests.hs
index 90437bb..3fea81e 100644
--- a/examples/tests.hs
+++ b/examples/tests.hs
@@ -298,9 +298,34 @@ schurTest2 m = m |~| u <> s <> ctrans u && unitary u && upperHessenberg s -- fix
298 298
299--------------------------------------------------------------------- 299---------------------------------------------------------------------
300 300
301expmTest m = expm (logm m) |~| complex m 301nd1 = (3><3) [ 1/2, 1/4, 1/4
302 , 0/1, 1/2, 1/4
303 , 1/2, 1/4, 1/2 :: Double]
304
305nd2 = (2><2) [1, 0, 1, 1:: Complex Double]
306
307expmTest1 = expm nd1 :~14~: (3><3)
308 [ 1.762110887278176
309 , 0.478085470590435
310 , 0.478085470590435
311 , 0.104719410945666
312 , 1.709751181805343
313 , 0.425725765117601
314 , 0.851451530235203
315 , 0.530445176063267
316 , 1.814470592751009 ]
317
318expmTest2 = expm nd2 :~15~: (2><2)
319 [ 2.718281828459045
320 , 0.000000000000000
321 , 2.718281828459045
322 , 2.718281828459045 ]
323
324expmTestDiag m = expm (logm m) |~| complex m
302 where logm m = matFunc Prelude.log m 325 where logm m = matFunc Prelude.log m
303 326
327
328
304--------------------------------------------------------------------- 329---------------------------------------------------------------------
305 330
306asFortran m = (rows m >|< cols m) $ toList (fdat m) 331asFortran m = (rows m >|< cols m) $ toList (fdat m)
@@ -389,8 +414,9 @@ tests = do
389 else quickCheck (schurTest1 . sqm ::SqM (Complex Double) -> Bool) 414 else quickCheck (schurTest1 . sqm ::SqM (Complex Double) -> Bool)
390 putStrLn "--------- expm --------" 415 putStrLn "--------- expm --------"
391 runTestTT $ TestList 416 runTestTT $ TestList
392 [ test "expmd" (expmTest $ (2><2) [1,2,3,5 :: Double]) 417 [ test "expmd" (expmTestDiag $ (2><2) [1,2,3,5 :: Double])
393 --, test "expmnd" (expmTest $ (2><2) [1,0,1,1 :: Double]) 418 , test "expm1" (expmTest1)
419 , test "expm2" (expmTest2)
394 ] 420 ]
395 putStrLn "--------- nullspace ------" 421 putStrLn "--------- nullspace ------"
396 quickCheck (nullspaceTest :: RM -> Bool) 422 quickCheck (nullspaceTest :: RM -> Bool)