summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README28
-rw-r--r--examples/parallel.hs25
2 files changed, 41 insertions, 12 deletions
diff --git a/README b/README
index 8c6f954..00188ce 100644
--- a/README
+++ b/README
@@ -10,10 +10,10 @@ INSTALLATION
10(More detailed information is included in the "tutorial", 10(More detailed information is included in the "tutorial",
11available in the web page of the project.) 11available in the web page of the project.)
12 12
13$ runhaskell Setup.hs configure --prefix=$HOME 13$ runhaskell Setup.lhs configure --prefix=$HOME
14$ runhaskell Setup.hs build 14$ runhaskell Setup.lhs build
15$ runhaskell Setup.hs haddock 15$ runhaskell Setup.lhs haddock
16$ runhaskell Setup.hs install --user 16$ runhaskell Setup.lhs install --user
17 17
18USING ATLAS 18USING ATLAS
19 19
@@ -27,11 +27,23 @@ $ runhaskell examples/tests.hs
27EXAMPLES 27EXAMPLES
28 28
29$ ghci 29$ ghci
30Prelude> :m + GSL 30Prelude> :m + Numeric.GSL
31Prelude GSL> let quad = integrateQNG 1E-10 31Prelude Numeric.GSL> let quad = integrateQNG 1E-10
32Prelude GSL> quad (^2) 0 1 32Prelude Numeric.GSL> quad (^2) 0 1
33(0.3333333333333333,3.700743415417188e-15) 33(0.3333333333333333,3.700743415417188e-15)
34Prelude GSL> :q 34
35Prelude Numeric.GSL> :m + Numeric.LinearAlgebra
36Prelude Numeric.LinearAlgebra> let m = (2><3)[1,2,3,4,5,6::Double]
37Prelude Numeric.LinearAlgebra> let (u,d,v) = full svd m
38Prelude Numeric.LinearAlgebra> d
39(2><3)
40 [ 9.508032000695724, 0.0, 0.0
41 , 0.0, 0.7728696356734838, 0.0 ]
42Prelude Numeric.LinearAlgebra> u <> d <> trans v
43(2><3)
44 [ 1.0000000000000004, 2.0, 3.0
45 , 3.9999999999999996, 5.000000000000001, 6.0 ]
46Prelude Numeric.GSL> :q
35Leaving GHCi. 47Leaving GHCi.
36 48
37-------------------------------------------------------------------------------------- 49--------------------------------------------------------------------------------------
diff --git a/examples/parallel.hs b/examples/parallel.hs
index 2ad686e..8f67863 100644
--- a/examples/parallel.hs
+++ b/examples/parallel.hs
@@ -1,10 +1,27 @@
1import System(getArgs) 1import System(getArgs)
2import Numeric.LinearAlgebra 2import Numeric.LinearAlgebra
3import Control.Parallel.Strategies 3import Control.Parallel.Strategies
4import System.Time
4 5
5work k = vectorMax s 6inParallel = parMap rwhnf id
6 where (_,s,_) = svd (ident k :: Matrix Double) 7
8parMul x y = fromBlocks [[ay],[by]]
9 where p = rows x `div` 2
10 a = takeRows p x
11 b = dropRows p x
12 [ay,by] = inParallel [a<>y,b<>y]
7 13
8main = do 14main = do
9 args <- (read . head) `fmap` getArgs 15 n <- (read . head) `fmap` getArgs
10 print $ sum $ parMap rnf work args \ No newline at end of file 16 let m = ident n :: Matrix Double
17 time $ print $ vectorMax $ takeDiag $ parMul m m
18 time $ print $ vectorMax $ takeDiag $ m <> m
19
20a = (2><3) [1..6::Double]
21b = (3><4) [1..12::Double]
22
23time act = do
24 t0 <- getClockTime
25 act
26 t1 <- getClockTime
27 print $ tdSec $ normalizeTimeDiff $ diffClockTimes t1 t0