summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVivian McPhail <haskell.vivian.mcphail@gmail.com>2010-07-12 21:07:42 +0000
committerVivian McPhail <haskell.vivian.mcphail@gmail.com>2010-07-12 21:07:42 +0000
commit007960d648485d5c161cd366d16282bc29fac68b (patch)
tree2ab7920ad71a0c29dd1f71c4b69266c85580a1f5 /lib
parentebfbc2f82813362e4840d134c57e1c9ce9518c36 (diff)
improve unzipVectorWith arguments
Diffstat (limited to 'lib')
-rw-r--r--lib/Data/Packed/Internal/Vector.hs11
-rw-r--r--lib/Data/Packed/Vector.hs2
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs
index c73ef10..7dd1289 100644
--- a/lib/Data/Packed/Internal/Vector.hs
+++ b/lib/Data/Packed/Internal/Vector.hs
@@ -322,8 +322,8 @@ zipVector f u v = unsafePerformIO $ do
322 322
323-- | unzipWith for Vectors 323-- | unzipWith for Vectors
324unzipVectorWith :: (Storable (a,b), Storable c, Storable d) 324unzipVectorWith :: (Storable (a,b), Storable c, Storable d)
325 => (a -> c) -> (b -> d) -> Vector (a,b) -> (Vector c,Vector d) 325 => ((a,b) -> (c,d)) -> Vector (a,b) -> (Vector c,Vector d)
326unzipVectorWith f g u = unsafePerformIO $ do 326unzipVectorWith f u = unsafePerformIO $ do
327 let n = dim u 327 let n = dim u
328 v <- createVector n 328 v <- createVector n
329 w <- createVector n 329 w <- createVector n
@@ -331,9 +331,10 @@ unzipVectorWith f g u = unsafePerformIO $ do
331 unsafeWith v $ \pv -> 331 unsafeWith v $ \pv ->
332 unsafeWith w $ \pw -> do 332 unsafeWith w $ \pw -> do
333 let go (-1) = return () 333 let go (-1) = return ()
334 go !k = do (x,y) <- peekElemOff pu k 334 go !k = do z <- peekElemOff pu k
335 pokeElemOff pv k (f x) 335 let (x,y) = f z
336 pokeElemOff pw k (g y) 336 pokeElemOff pv k x
337 pokeElemOff pw k y
337 go (k-1) 338 go (k-1)
338 go (n-1) 339 go (n-1)
339 return (v,w) 340 return (v,w)
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs
index 760f724..40dd6b5 100644
--- a/lib/Data/Packed/Vector.hs
+++ b/lib/Data/Packed/Vector.hs
@@ -152,6 +152,6 @@ vecdisp f v
152 152
153-- | unzip for Vectors 153-- | unzip for Vectors
154unzipVector :: (Storable a, Storable b, Storable (a,b)) => Vector (a,b) -> (Vector a,Vector b) 154unzipVector :: (Storable a, Storable b, Storable (a,b)) => Vector (a,b) -> (Vector a,Vector b)
155unzipVector = unzipVectorWith id id 155unzipVector = unzipVectorWith id
156 156
157 157