From 53b361e5b9840273ccfd50e5b256002498a97469 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Tue, 10 Jun 2008 08:31:27 +0000 Subject: added examples/benchmarks.hs --- lib/Data/Packed/Internal.hs | 2 +- lib/Data/Packed/Internal/Matrix.hs | 27 --------------------------- lib/Data/Packed/Internal/Vector.hs | 22 ---------------------- lib/Data/Packed/Matrix.hs | 2 +- 4 files changed, 2 insertions(+), 51 deletions(-) (limited to 'lib/Data') diff --git a/lib/Data/Packed/Internal.hs b/lib/Data/Packed/Internal.hs index e5028d3..0bf9f8c 100644 --- a/lib/Data/Packed/Internal.hs +++ b/lib/Data/Packed/Internal.hs @@ -21,4 +21,4 @@ module Data.Packed.Internal ( import Data.Packed.Internal.Common import Data.Packed.Internal.Vector -import Data.Packed.Internal.Matrix \ No newline at end of file +import Data.Packed.Internal.Matrix diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 7a35a61..caf3699 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs @@ -394,30 +394,3 @@ fromFile filename (r,c) = do --free charname -- TO DO: free the auxiliary CString return res foreign import ccall "auxi.h matrix_fscanf" c_gslReadMatrix:: Ptr CChar -> TM - ----------------------------------------------------------------------------- - -{- | creates a new matrix with the given position updated with a modification function - -@> updateMatrix (0,2) (const 57) (ident 3 :: Matrix Double) -(3><3) - [ 1.0, 0.0, 57.0 - , 0.0, 1.0, 0.0 - , 0.0, 0.0, 1.0 ]@ - --} -updateMatrix :: Storable t - => (Int,Int) -- ^ position (row,column) - -> (t -> t) -- ^ modification function - -> Matrix t -- ^ source matrix - -> Matrix t -- ^ result - -updateMatrix (i,j) f (m@MC {rows = r, cols = c, cdat = v}) - | i<0 || i>=r || j<0 || j>=c = error $ "updateMatrix out of range(size="++show (r,c)++", pos="++show (i,j)++")" - | otherwise = let pos = i*c+j - in m { cdat = updateVector pos f v } - -updateMatrix (i,j) f (m@MF {rows = r, cols = c, fdat = v}) - | i<0 || i>=r || j<0 || j>=c = error $ "updateMatrix out of range(size="++show (r,c)++", pos="++show (i,j)++")" - | otherwise = let pos = j*r+i - in m { fdat = updateVector pos f v } 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) ----------------------------------------------------------------- -{- | creates a new vector with a desired position updated with a modification function - -@> updateVector 3 (+7) (fromList [1..5]) -5 |> [1.0,2.0,3.0,11.0,5.0]@ - --} -updateVector :: Storable t => Int -- ^ position - -> (t->t) -- ^ modification function - -> Vector t -- ^ source - -> Vector t -- ^ result -updateVector k h (v@V {dim=n}) - | k<0 || k >= n = error $ "updateVector out of range (dim="++show n++", pos="++show k++")" - | otherwise = unsafePerformIO $ do - r <- createVector n - let f _ s _ d = copyArray d s n - >> pokeElemOff d k (h (v`at'`k)) - >> return 0 - app2 f vec v vec r "updateVector" - return r - ------------------------------------------------------------------ - cloneVector :: Storable t => Vector t -> IO (Vector t) cloneVector (v@V {dim=n}) = do r <- createVector n diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index 62d28b1..7d2c564 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs @@ -226,4 +226,4 @@ extractRows l m = fromRows $ extract (toRows $ m) l -} repmat :: (Element t) => Matrix t -> Int -> Int -> Matrix t -repmat m r c = fromBlocks $ partit c $ replicate (r*c) m \ No newline at end of file +repmat m r c = fromBlocks $ partit c $ replicate (r*c) m -- cgit v1.2.3