From 6809103cf34a9345f8cb60a0ec3a8f55dd18d5ef Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Wed, 13 May 2009 09:39:25 +0000 Subject: added Development module --- lib/Data/Packed/Internal/Vector.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/Data/Packed/Internal/Vector.hs') diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs index fc8a6be..1b572a5 100644 --- a/lib/Data/Packed/Internal/Vector.hs +++ b/lib/Data/Packed/Internal/Vector.hs @@ -18,6 +18,7 @@ module Data.Packed.Internal.Vector where import Data.Packed.Internal.Common import Foreign +import Foreign.C.Types(CInt) import Complex import Control.Monad(when) @@ -36,6 +37,8 @@ data Vector t = , fptr :: {-# UNPACK #-} !(ForeignPtr t) -- ^ foreign pointer to the memory block } +-- C-Haskell vector adapter +vec :: Adapt (CInt -> Ptr t -> r) (Vector t) r vec = withVector withVector (V n fp) f = withForeignPtr fp $ \p -> do @@ -43,7 +46,7 @@ withVector (V n fp) f = withForeignPtr fp $ \p -> do g (fi n) p f v --- | allocates memory for a new vector +-- allocates memory for a new vector createVector :: Storable a => Int -> IO (Vector a) createVector n = do when (n <= 0) $ error ("trying to createVector of dim "++show n) -- cgit v1.2.3