summaryrefslogtreecommitdiff
path: root/examples/inplace.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2008-06-19 17:25:58 +0000
committerAlberto Ruiz <aruiz@um.es>2008-06-19 17:25:58 +0000
commitfe795ee9b1e71666d408879ce30fe6d4ca80830e (patch)
tree81e691ee455832823bebad6febde9fdf216b0b86 /examples/inplace.hs
parent8dce18602825da9914832114283748244fa9b859 (diff)
ST bug fixed with NOINLINE newVector/Matrix
Diffstat (limited to 'examples/inplace.hs')
-rw-r--r--examples/inplace.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/inplace.hs b/examples/inplace.hs
index 29fac6f..9f23e0c 100644
--- a/examples/inplace.hs
+++ b/examples/inplace.hs
@@ -18,6 +18,7 @@ main = sequence_[
18 test5, 18 test5,
19 test6, 19 test6,
20 print test7, 20 print test7,
21 test8,
21 test0] 22 test0]
22 23
23-- helper functions 24-- helper functions
@@ -112,3 +113,29 @@ test0 = do
112 print m 113 print m
113 --print hv 114 --print hv
114 --print hm 115 --print hm
116
117-------------------------------------------------
118
119histogram n ds = runSTVector $ do
120 h <- newVector (0::Double) n -- number of bins
121 let inc k = modifyVector h k (+1)
122 mapM_ inc ds
123 return h
124
125-- check that newVector is really called with a fresh new array
126histoCheck ds = runSTVector $ do
127 h <- newVector (0::Double) 15 -- > constant for this test
128 let inc k = modifyVector h k (+1)
129 mapM_ inc ds
130 return h
131
132
133test8 = do
134 let ds = [0..14]
135 print $ histogram 15 ds
136 print $ histogram 15 ds
137 print $ histogram 15 ds
138 print $ histoCheck ds
139 print $ histoCheck ds
140 print $ histoCheck ds
141 putStrLn "----------------------"