Repository : ssh://darcs.haskell.org//srv/darcs/packages/dph

On branch  : 

http://hackage.haskell.org/trac/ghc/changeset/2d2501d88ffb8ffcd3e42648a685bad83c4f4962

>---------------------------------------------------------------

commit 2d2501d88ffb8ffcd3e42648a685bad83c4f4962
Author: George Roldugin <[email protected]>
Date:   Tue May 17 09:50:35 2011 +1000

    Fix foldUP.

>---------------------------------------------------------------

 .../Parallel/Unlifted/Parallel/Combinators.hs      |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/dph-prim-par/Data/Array/Parallel/Unlifted/Parallel/Combinators.hs 
b/dph-prim-par/Data/Array/Parallel/Unlifted/Parallel/Combinators.hs
index e09030e..3f22a50 100644
--- a/dph-prim-par/Data/Array/Parallel/Unlifted/Parallel/Combinators.hs
+++ b/dph-prim-par/Data/Array/Parallel/Unlifted/Parallel/Combinators.hs
@@ -87,12 +87,18 @@ zipWithUP f xs ys
 
 
 -- | Undirected fold.
-foldUP :: (Unbox a, DT a) => (a -> a -> a) -> a -> Vector a -> a
+foldUP :: (DT a, Unbox a) => (a -> a -> a) -> a -> Vector a -> a
 {-# INLINE foldUP #-}
-foldUP f !z xs
-        = foldD theGang f
-                (mapD   theGang (Seq.fold f z)
-                (splitD theGang unbalanced xs))
+foldUP f !z arr
+        = (maybe z (f z)
+        . foldD  theGang combine
+        . mapD   theGang (Seq.fold1Maybe f)
+        . splitD theGang unbalanced) arr
+        where
+                combine (Just x) (Just y) = Just (f x y)
+                combine (Just x) Nothing  = Just x
+                combine Nothing  (Just y) = Just y
+                combine Nothing  Nothing  = Nothing
 
 
 -- | Array reduction proceeding from the left (requires associative 
combination)



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to