diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-11-30 19:55:34 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-11-30 19:55:34 +0000 |
commit | d7d3b731c037fca41bd9128c3da2a582189cb4d9 (patch) | |
tree | f1bf8f1fa538033ff184d6cc556e808bfaaa71a9 /examples/tests.hs | |
parent | 975d3730a923387f9d1a0be4f7d11b01b27a09df (diff) |
hide internal modules
Diffstat (limited to 'examples/tests.hs')
-rw-r--r-- | examples/tests.hs | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/examples/tests.hs b/examples/tests.hs index 2d6b7e9..60bef8f 100644 --- a/examples/tests.hs +++ b/examples/tests.hs | |||
@@ -2,19 +2,19 @@ | |||
2 | 2 | ||
3 | module Main where | 3 | module Main where |
4 | 4 | ||
5 | import Data.Packed.Internal((>|<), multiply', multiplyG, MatrixOrder(..),debug,fmat) | ||
6 | import Numeric.GSL hiding (sin,cos,exp,choose) | 5 | import Numeric.GSL hiding (sin,cos,exp,choose) |
7 | import Numeric.LinearAlgebra | 6 | import Numeric.LinearAlgebra |
8 | import Numeric.LinearAlgebra.Linear(Linear) | ||
9 | import Numeric.LinearAlgebra.LAPACK | 7 | import Numeric.LinearAlgebra.LAPACK |
10 | import Numeric.GSL.Matrix(svdg) | ||
11 | import qualified Numeric.GSL.Matrix as GSL | 8 | import qualified Numeric.GSL.Matrix as GSL |
12 | import Test.QuickCheck hiding (test) | 9 | import Test.QuickCheck hiding (test) |
13 | import Test.HUnit hiding ((~:),test) | 10 | import Test.HUnit hiding ((~:),test) |
14 | import System.Random(randomRs,mkStdGen) | 11 | import System.Random(randomRs,mkStdGen) |
15 | import System.Info | 12 | import System.Info |
16 | import Data.List(foldl1') | 13 | import Data.List(foldl1', transpose) |
17 | import System(getArgs) | 14 | import System(getArgs) |
15 | import Debug.Trace(trace) | ||
16 | |||
17 | debug x = trace (show x) x | ||
18 | 18 | ||
19 | type RM = Matrix Double | 19 | type RM = Matrix Double |
20 | type CM = Matrix (Complex Double) | 20 | type CM = Matrix (Complex Double) |
@@ -340,8 +340,20 @@ expmTestDiag m = expm (logm m) |~| complex m | |||
340 | asFortran m = (rows m >|< cols m) $ toList (flatten $ trans m) | 340 | asFortran m = (rows m >|< cols m) $ toList (flatten $ trans m) |
341 | asC m = (rows m >< cols m) $ toList (flatten m) | 341 | asC m = (rows m >< cols m) $ toList (flatten m) |
342 | 342 | ||
343 | mulC a b = multiply' RowMajor a b | 343 | mulC a b = a <> b |
344 | mulF a b = multiply' ColumnMajor a b | 344 | mulF a b = trans $ trans b <> trans a |
345 | |||
346 | ------------------------------------------------------------------------- | ||
347 | |||
348 | multiplyG a b = reshape (cols b) $ fromList $ concat $ multiplyL (toLists a) (toLists b) | ||
349 | where multiplyL a b = [[dotL x y | y <- transpose b] | x <- a] | ||
350 | dotL a b = sum (zipWith (*) a b) | ||
351 | |||
352 | r >|< c = f where | ||
353 | f l | dim v == r*c = reshapeF r v | ||
354 | | otherwise = error "(>|<)" | ||
355 | where v = fromList l | ||
356 | reshapeF r = trans . reshape r | ||
345 | 357 | ||
346 | --------------------------------------------------------------------- | 358 | --------------------------------------------------------------------- |
347 | 359 | ||
@@ -389,7 +401,7 @@ tests = do | |||
389 | quickCheck (svdTest' svdR) | 401 | quickCheck (svdTest' svdR) |
390 | quickCheck (svdTest' svdRdd) | 402 | quickCheck (svdTest' svdRdd) |
391 | quickCheck (svdTest' svdC) | 403 | quickCheck (svdTest' svdC) |
392 | quickCheck (svdTest' svdg) | 404 | quickCheck (svdTest' GSL.svdg) |
393 | putStrLn "--------- eig ---------" | 405 | putStrLn "--------- eig ---------" |
394 | quickCheck (eigTest . sqm :: SqM Double -> Bool) | 406 | quickCheck (eigTest . sqm :: SqM Double -> Bool) |
395 | quickCheck (eigTest . sqm :: SqM (Complex Double) -> Bool) | 407 | quickCheck (eigTest . sqm :: SqM (Complex Double) -> Bool) |