diff options
Diffstat (limited to 'lib/Data/Packed')
-rw-r--r-- | lib/Data/Packed/Internal/Vector.hs | 8 | ||||
-rw-r--r-- | lib/Data/Packed/Vector.hs | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs index c8cc2c2..be2fcbb 100644 --- a/lib/Data/Packed/Internal/Vector.hs +++ b/lib/Data/Packed/Internal/Vector.hs | |||
@@ -17,7 +17,7 @@ module Data.Packed.Internal.Vector ( | |||
17 | Vector, dim, | 17 | Vector, dim, |
18 | fromList, toList, (|>), | 18 | fromList, toList, (|>), |
19 | join, (@>), safe, at, at', subVector, takesV, | 19 | join, (@>), safe, at, at', subVector, takesV, |
20 | mapVector, zipVector, unzipVectorWith, | 20 | mapVector, zipVectorWith, unzipVectorWith, |
21 | mapVectorM, mapVectorM_, | 21 | mapVectorM, mapVectorM_, |
22 | foldVector, foldVectorG, foldLoop, | 22 | foldVector, foldVectorG, foldLoop, |
23 | createVector, vec, | 23 | createVector, vec, |
@@ -319,8 +319,8 @@ mapVector f v = unsafePerformIO $ do | |||
319 | {-# INLINE mapVector #-} | 319 | {-# INLINE mapVector #-} |
320 | 320 | ||
321 | -- | zipWith for Vectors | 321 | -- | zipWith for Vectors |
322 | zipVector :: (Storable a, Storable b, Storable c) => (a-> b -> c) -> Vector a -> Vector b -> Vector c | 322 | zipVectorWith :: (Storable a, Storable b, Storable c) => (a-> b -> c) -> Vector a -> Vector b -> Vector c |
323 | zipVector f u v = unsafePerformIO $ do | 323 | zipVectorWith f u v = unsafePerformIO $ do |
324 | let n = min (dim u) (dim v) | 324 | let n = min (dim u) (dim v) |
325 | w <- createVector n | 325 | w <- createVector n |
326 | unsafeWith u $ \pu -> | 326 | unsafeWith u $ \pu -> |
@@ -333,7 +333,7 @@ zipVector f u v = unsafePerformIO $ do | |||
333 | go (k-1) | 333 | go (k-1) |
334 | go (n -1) | 334 | go (n -1) |
335 | return w | 335 | return w |
336 | {-# INLINE zipVector #-} | 336 | {-# INLINE zipVectorWith #-} |
337 | 337 | ||
338 | -- | unzipWith for Vectors | 338 | -- | unzipWith for Vectors |
339 | unzipVectorWith :: (Storable (a,b), Storable c, Storable d) | 339 | unzipVectorWith :: (Storable (a,b), Storable c, Storable d) |
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs index 81dfa37..a526caa 100644 --- a/lib/Data/Packed/Vector.hs +++ b/lib/Data/Packed/Vector.hs | |||
@@ -26,7 +26,7 @@ module Data.Packed.Vector ( | |||
26 | -- vectorFMax, vectorFMin, vectorFMaxIndex, vectorFMinIndex, | 26 | -- vectorFMax, vectorFMin, vectorFMaxIndex, vectorFMinIndex, |
27 | -- vectorMax, vectorMin, | 27 | -- vectorMax, vectorMin, |
28 | vectorMaxIndex, vectorMinIndex, | 28 | vectorMaxIndex, vectorMinIndex, |
29 | mapVector, zipVector, unzipVector, unzipVectorWith, | 29 | mapVector, zipVector, zipVectorWith, unzipVector, unzipVectorWith, |
30 | mapVectorM, mapVectorM_, | 30 | mapVectorM, mapVectorM_, |
31 | fscanfVector, fprintfVector, freadVector, fwriteVector, | 31 | fscanfVector, fprintfVector, freadVector, fwriteVector, |
32 | foldLoop, foldVector, foldVectorG | 32 | foldLoop, foldVector, foldVectorG |
@@ -114,6 +114,10 @@ buildVector len f = | |||
114 | fromList $ map f [0 .. (len - 1)] | 114 | fromList $ map f [0 .. (len - 1)] |
115 | 115 | ||
116 | 116 | ||
117 | -- | zip for Vectors | ||
118 | zipVector :: (Storable a, Storable b, Storable (a,b)) => Vector a -> Vector b -> Vector (a,b) | ||
119 | zipVector = zipVectorWith (,) | ||
120 | |||
117 | -- | unzip for Vectors | 121 | -- | unzip for Vectors |
118 | unzipVector :: (Storable a, Storable b, Storable (a,b)) => Vector (a,b) -> (Vector a,Vector b) | 122 | unzipVector :: (Storable a, Storable b, Storable (a,b)) => Vector (a,b) -> (Vector a,Vector b) |
119 | unzipVector = unzipVectorWith id | 123 | unzipVector = unzipVectorWith id |