summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2008-11-15 11:50:24 +0000
committerAlberto Ruiz <aruiz@um.es>2008-11-15 11:50:24 +0000
commit1e9b6bb90273cdf192bdcf0ccf73af59241c1d95 (patch)
treef7c1656c2c3b883e8126519610a5428e7e9b7382 /examples
parentf0a2248b9d9532e0814519408bff8b886bca2bbc (diff)
zipVector
Diffstat (limited to 'examples')
-rw-r--r--examples/benchmarks.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/benchmarks.hs b/examples/benchmarks.hs
index bffa221..f5ca550 100644
--- a/examples/benchmarks.hs
+++ b/examples/benchmarks.hs
@@ -46,6 +46,16 @@ bench1 = do
46 time $ print $ constant (1::Double) 5000001 @> 7 46 time $ print $ constant (1::Double) 5000001 @> 7
47 time $ print $ constant i 5000001 @> 7 47 time $ print $ constant i 5000001 @> 7
48 time $ print $ conj (constant i 5000001) @> 7 48 time $ print $ conj (constant i 5000001) @> 7
49 putStrLn "some zips:"
50 time $ print $ (w / w2) @> 7
51 time $ print $ (zipVector (/) w w2) @> 7
52 putStrLn "some folds:"
53 let t = constant (1::Double) 5000002
54 print $ t @> 7
55 time $ print $ foldVector max (t@>0) t
56 time $ print $ vectorMax t
57 time $ print $ sqrt $ foldVector (\v s -> v*v+s) 0 t
58 time $ print $ pnorm PNorm2 t
49 59
50sumVH v = go (d - 1) 0 60sumVH v = go (d - 1) 0
51 where 61 where
@@ -56,7 +66,7 @@ sumVH v = go (d - 1) 0
56 66
57innerH u v = go (d - 1) 0 67innerH u v = go (d - 1) 0
58 where 68 where
59 d = dim u 69 d = min (dim u) (dim v)
60 go :: Int -> Double -> Double 70 go :: Int -> Double -> Double
61 go 0 s = s + (u @> 0) * (v @> 0) 71 go 0 s = s + (u @> 0) * (v @> 0)
62 go !j !s = go (j - 1) (s + (u @> j) * (v @> j)) 72 go !j !s = go (j - 1) (s + (u @> j) * (v @> j))