diff options
Diffstat (limited to 'examples/tests.hs')
-rw-r--r-- | examples/tests.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/tests.hs b/examples/tests.hs index 7b85a9b..90437bb 100644 --- a/examples/tests.hs +++ b/examples/tests.hs | |||
@@ -13,6 +13,7 @@ import Test.QuickCheck hiding (test) | |||
13 | import Test.HUnit hiding ((~:),test) | 13 | import Test.HUnit hiding ((~:),test) |
14 | import System.Random(randomRs,mkStdGen) | 14 | import System.Random(randomRs,mkStdGen) |
15 | import System.Info | 15 | import System.Info |
16 | import Data.List(foldl1') | ||
16 | 17 | ||
17 | type RM = Matrix Double | 18 | type RM = Matrix Double |
18 | type CM = Matrix (Complex Double) | 19 | type CM = Matrix (Complex Double) |
@@ -310,6 +311,20 @@ mulF a b = multiply' ColumnMajor a b | |||
310 | 311 | ||
311 | --------------------------------------------------------------------- | 312 | --------------------------------------------------------------------- |
312 | 313 | ||
314 | rot :: Double -> Matrix Double | ||
315 | rot a = (3><3) [ c,0,s | ||
316 | , 0,1,0 | ||
317 | ,-s,0,c ] | ||
318 | where c = cos a | ||
319 | s = sin a | ||
320 | |||
321 | fun n = foldl1' (<>) (map rot angles) | ||
322 | where angles = toList $ linspace n (0,1) | ||
323 | |||
324 | rotTest = fun (10^5) :~12~: rot 5E4 | ||
325 | |||
326 | --------------------------------------------------------------------- | ||
327 | |||
313 | tests = do | 328 | tests = do |
314 | putStrLn "--------- internal -----" | 329 | putStrLn "--------- internal -----" |
315 | quickCheck ((\m -> m == trans m).sym :: Sym Double -> Bool) | 330 | quickCheck ((\m -> m == trans m).sym :: Sym Double -> Bool) |
@@ -322,6 +337,9 @@ tests = do | |||
322 | quickCheck $ \m -> m == asFortran (m :: CM) | 337 | quickCheck $ \m -> m == asFortran (m :: CM) |
323 | quickCheck $ \m -> m == (asC . asFortran) (m :: RM) | 338 | quickCheck $ \m -> m == (asC . asFortran) (m :: RM) |
324 | quickCheck $ \m -> m == (asC . asFortran) (m :: CM) | 339 | quickCheck $ \m -> m == (asC . asFortran) (m :: CM) |
340 | runTestTT $ TestList | ||
341 | [ test "1E5 rots" rotTest | ||
342 | ] | ||
325 | putStrLn "--------- multiply ----" | 343 | putStrLn "--------- multiply ----" |
326 | quickCheck $ \(PairM m1 m2) -> mulC m1 m2 == mulF m1 (m2 :: RM) | 344 | quickCheck $ \(PairM m1 m2) -> mulC m1 m2 == mulF m1 (m2 :: RM) |
327 | quickCheck $ \(PairM m1 m2) -> mulC m1 m2 == mulF m1 (m2 :: CM) | 345 | quickCheck $ \(PairM m1 m2) -> mulC m1 m2 == mulF m1 (m2 :: CM) |