diff options
Diffstat (limited to 'examples/tests.hs')
-rw-r--r-- | examples/tests.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/examples/tests.hs b/examples/tests.hs index 9388671..e91b9f1 100644 --- a/examples/tests.hs +++ b/examples/tests.hs | |||
@@ -189,12 +189,12 @@ pinvTest m = m <> p <> m |~| m | |||
189 | 189 | ||
190 | square m = rows m == cols m | 190 | square m = rows m == cols m |
191 | 191 | ||
192 | orthonormal m = square m && m <> ctrans m |~| ident (rows m) | 192 | unitary m = square m && m <> ctrans m |~| ident (rows m) |
193 | 193 | ||
194 | hermitian m = m |~| ctrans m | 194 | hermitian m = m |~| ctrans m |
195 | 195 | ||
196 | svdTest svd m = u <> real d <> trans v |~| m | 196 | svdTest svd m = u <> real d <> trans v |~| m |
197 | && orthonormal u && orthonormal v | 197 | && unitary u && unitary v |
198 | where (u,d,v) = full svd m | 198 | where (u,d,v) = full svd m |
199 | 199 | ||
200 | svdTest' svd m = m |~| 0 || u <> real (diag s) <> trans v |~| m | 200 | svdTest' svd m = m |~| 0 || u <> real (diag s) <> trans v |~| m |
@@ -204,7 +204,7 @@ eigTest m = complex m <> v |~| v <> diag s | |||
204 | where (s, v) = eig m | 204 | where (s, v) = eig m |
205 | 205 | ||
206 | eigTestSH m = m <> v |~| v <> real (diag s) | 206 | eigTestSH m = m <> v |~| v <> real (diag s) |
207 | && orthonormal v | 207 | && unitary v |
208 | && m |~| v <> real (diag s) <> ctrans v | 208 | && m |~| v <> real (diag s) <> ctrans v |
209 | where (s, v) = eigSH m | 209 | where (s, v) = eigSH m |
210 | 210 | ||
@@ -274,11 +274,16 @@ cholCTest = chol ((2><2) [1,2,2,9::Complex Double]) == (2><2) [1,2,0,2.236067977 | |||
274 | 274 | ||
275 | --------------------------------------------------------------------- | 275 | --------------------------------------------------------------------- |
276 | 276 | ||
277 | qrTest qr m = q <> r |~| m && q <> ctrans q |~| ident (rows m) | 277 | qrTest qr m = q <> r |~| m && unitary q |
278 | where (q,r) = qr m | 278 | where (q,r) = qr m |
279 | 279 | ||
280 | --------------------------------------------------------------------- | 280 | --------------------------------------------------------------------- |
281 | 281 | ||
282 | hessTest m = m |~| p <> h <> ctrans p && unitary p | ||
283 | where (p,h) = hess m | ||
284 | |||
285 | --------------------------------------------------------------------- | ||
286 | |||
282 | asFortran m = (rows m >|< cols m) $ toList (fdat m) | 287 | asFortran m = (rows m >|< cols m) $ toList (fdat m) |
283 | asC m = (rows m >< cols m) $ toList (cdat m) | 288 | asC m = (rows m >< cols m) $ toList (cdat m) |
284 | 289 | ||
@@ -338,6 +343,9 @@ tests = do | |||
338 | quickCheck (qrTest ( unpackQR . GSL.qrPacked)) | 343 | quickCheck (qrTest ( unpackQR . GSL.qrPacked)) |
339 | quickCheck (qrTest qr ::RM->Bool) | 344 | quickCheck (qrTest qr ::RM->Bool) |
340 | quickCheck (qrTest qr ::CM->Bool) | 345 | quickCheck (qrTest qr ::CM->Bool) |
346 | putStrLn "--------- hess --------" | ||
347 | quickCheck (hessTest . sqm ::SqM Double->Bool) | ||
348 | quickCheck (hessTest . sqm ::SqM (Complex Double) -> Bool) | ||
341 | putStrLn "--------- nullspace ------" | 349 | putStrLn "--------- nullspace ------" |
342 | quickCheck (nullspaceTest :: RM -> Bool) | 350 | quickCheck (nullspaceTest :: RM -> Bool) |
343 | quickCheck (nullspaceTest :: CM -> Bool) | 351 | quickCheck (nullspaceTest :: CM -> Bool) |