summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Vector.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2008-06-10 08:31:27 +0000
committerAlberto Ruiz <aruiz@um.es>2008-06-10 08:31:27 +0000
commit53b361e5b9840273ccfd50e5b256002498a97469 (patch)
treec96ae1a373cd6884821f4b74b9e6cabd5e6f2204 /lib/Data/Packed/Internal/Vector.hs
parent9cb72979acc7bcd9df2fa8eab05169d9c5ca84f5 (diff)
added examples/benchmarks.hs
Diffstat (limited to 'lib/Data/Packed/Internal/Vector.hs')
-rw-r--r--lib/Data/Packed/Internal/Vector.hs22
1 files changed, 0 insertions, 22 deletions
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs
index 6274e48..2df33e0 100644
--- a/lib/Data/Packed/Internal/Vector.hs
+++ b/lib/Data/Packed/Internal/Vector.hs
@@ -189,28 +189,6 @@ liftVector2 f u v = fromList $ zipWith f (toList u) (toList v)
189 189
190----------------------------------------------------------------- 190-----------------------------------------------------------------
191 191
192{- | creates a new vector with a desired position updated with a modification function
193
194@> updateVector 3 (+7) (fromList [1..5])
1955 |> [1.0,2.0,3.0,11.0,5.0]@
196
197-}
198updateVector :: Storable t => Int -- ^ position
199 -> (t->t) -- ^ modification function
200 -> Vector t -- ^ source
201 -> Vector t -- ^ result
202updateVector k h (v@V {dim=n})
203 | k<0 || k >= n = error $ "updateVector out of range (dim="++show n++", pos="++show k++")"
204 | otherwise = unsafePerformIO $ do
205 r <- createVector n
206 let f _ s _ d = copyArray d s n
207 >> pokeElemOff d k (h (v`at'`k))
208 >> return 0
209 app2 f vec v vec r "updateVector"
210 return r
211
212-----------------------------------------------------------------
213
214cloneVector :: Storable t => Vector t -> IO (Vector t) 192cloneVector :: Storable t => Vector t -> IO (Vector t)
215cloneVector (v@V {dim=n}) = do 193cloneVector (v@V {dim=n}) = do
216 r <- createVector n 194 r <- createVector n