From fe795ee9b1e71666d408879ce30fe6d4ca80830e Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Thu, 19 Jun 2008 17:25:58 +0000 Subject: ST bug fixed with NOINLINE newVector/Matrix --- examples/inplace.hs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'examples/inplace.hs') 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_[ test5, test6, print test7, + test8, test0] -- helper functions @@ -112,3 +113,29 @@ test0 = do print m --print hv --print hm + +------------------------------------------------- + +histogram n ds = runSTVector $ do + h <- newVector (0::Double) n -- number of bins + let inc k = modifyVector h k (+1) + mapM_ inc ds + return h + +-- check that newVector is really called with a fresh new array +histoCheck ds = runSTVector $ do + h <- newVector (0::Double) 15 -- > constant for this test + let inc k = modifyVector h k (+1) + mapM_ inc ds + return h + + +test8 = do + let ds = [0..14] + print $ histogram 15 ds + print $ histogram 15 ds + print $ histogram 15 ds + print $ histoCheck ds + print $ histoCheck ds + print $ histoCheck ds + putStrLn "----------------------" -- cgit v1.2.3