summaryrefslogtreecommitdiff
path: root/examples/tests.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-10-29 18:21:06 +0000
committerAlberto Ruiz <aruiz@um.es>2007-10-29 18:21:06 +0000
commit2facdf74f267ff81645336528a50696f61bb8670 (patch)
treedd5049c2d0cb1b1c4cd919af77a305b9025fe8dd /examples/tests.hs
parentfd73d3eb9d671bd5be23024d4cc5eeb7b5fdeb58 (diff)
fixed terrible toList bug
Diffstat (limited to 'examples/tests.hs')
-rw-r--r--examples/tests.hs18
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)
13import Test.HUnit hiding ((~:),test) 13import Test.HUnit hiding ((~:),test)
14import System.Random(randomRs,mkStdGen) 14import System.Random(randomRs,mkStdGen)
15import System.Info 15import System.Info
16import Data.List(foldl1')
16 17
17type RM = Matrix Double 18type RM = Matrix Double
18type CM = Matrix (Complex Double) 19type CM = Matrix (Complex Double)
@@ -310,6 +311,20 @@ mulF a b = multiply' ColumnMajor a b
310 311
311--------------------------------------------------------------------- 312---------------------------------------------------------------------
312 313
314rot :: Double -> Matrix Double
315rot a = (3><3) [ c,0,s
316 , 0,1,0
317 ,-s,0,c ]
318 where c = cos a
319 s = sin a
320
321fun n = foldl1' (<>) (map rot angles)
322 where angles = toList $ linspace n (0,1)
323
324rotTest = fun (10^5) :~12~: rot 5E4
325
326---------------------------------------------------------------------
327
313tests = do 328tests = 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)