summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/base/src/Internal/CG.hs2
-rw-r--r--packages/base/src/Internal/Convolution.hs2
-rw-r--r--packages/base/src/Internal/Devel.hs9
-rw-r--r--packages/base/src/Internal/Modular.hs2
-rw-r--r--packages/base/src/Internal/Vector.hs16
5 files changed, 6 insertions, 25 deletions
diff --git a/packages/base/src/Internal/CG.hs b/packages/base/src/Internal/CG.hs
index 758d130..8c4afee 100644
--- a/packages/base/src/Internal/CG.hs
+++ b/packages/base/src/Internal/CG.hs
@@ -7,7 +7,7 @@ module Internal.CG(
7) where 7) where
8 8
9import Internal.Vector 9import Internal.Vector
10import Internal.Matrix hiding (mat) 10import Internal.Matrix
11import Internal.Numeric 11import Internal.Numeric
12import Internal.Element 12import Internal.Element
13import Internal.IO 13import Internal.IO
diff --git a/packages/base/src/Internal/Convolution.hs b/packages/base/src/Internal/Convolution.hs
index 1a70011..384fdf8 100644
--- a/packages/base/src/Internal/Convolution.hs
+++ b/packages/base/src/Internal/Convolution.hs
@@ -18,7 +18,7 @@ module Internal.Convolution(
18 18
19import qualified Data.Vector.Storable as SV 19import qualified Data.Vector.Storable as SV
20import Internal.Vector 20import Internal.Vector
21import Internal.Matrix hiding (mat) 21import Internal.Matrix
22import Internal.Numeric 22import Internal.Numeric
23import Internal.Element 23import Internal.Element
24import Internal.Conversion 24import Internal.Conversion
diff --git a/packages/base/src/Internal/Devel.hs b/packages/base/src/Internal/Devel.hs
index 4be0afd..710d626 100644
--- a/packages/base/src/Internal/Devel.hs
+++ b/packages/base/src/Internal/Devel.hs
@@ -17,7 +17,7 @@ import Foreign.C.Types ( CInt )
17--import Foreign.Storable.Complex () 17--import Foreign.Storable.Complex ()
18import Foreign.Ptr(Ptr) 18import Foreign.Ptr(Ptr)
19import Control.Exception as E ( SomeException, catch ) 19import Control.Exception as E ( SomeException, catch )
20import Internal.Vector(Vector,avec,arrvec) 20import Internal.Vector(Vector,avec)
21import Foreign.Storable(Storable) 21import Foreign.Storable(Storable)
22 22
23-- | postfix function application (@flip ($)@) 23-- | postfix function application (@flip ($)@)
@@ -83,8 +83,7 @@ class TransArray c
83 type Elem c 83 type Elem c
84 apply :: (Trans c b) -> c -> b 84 apply :: (Trans c b) -> c -> b
85 applyRaw :: (TransRaw c b) -> c -> b 85 applyRaw :: (TransRaw c b) -> c -> b
86 applyArray :: (Ptr CInt -> Ptr (Elem c) -> b) -> c -> b 86 infixl 1 `apply`, `applyRaw`
87 infixl 1 `apply`, `applyRaw`, `applyArray`
88 87
89instance Storable t => TransArray (Vector t) 88instance Storable t => TransArray (Vector t)
90 where 89 where
@@ -95,8 +94,4 @@ instance Storable t => TransArray (Vector t)
95 {-# INLINE apply #-} 94 {-# INLINE apply #-}
96 applyRaw = avec 95 applyRaw = avec
97 {-# INLINE applyRaw #-} 96 {-# INLINE applyRaw #-}
98 applyArray = arrvec
99 {-# INLINE applyArray #-}
100
101
102 97
diff --git a/packages/base/src/Internal/Modular.hs b/packages/base/src/Internal/Modular.hs
index 098817e..37f6e9b 100644
--- a/packages/base/src/Internal/Modular.hs
+++ b/packages/base/src/Internal/Modular.hs
@@ -27,7 +27,7 @@ module Internal.Modular(
27) where 27) where
28 28
29import Internal.Vector 29import Internal.Vector
30import Internal.Matrix hiding (mat,size) 30import Internal.Matrix hiding (size)
31import Internal.Numeric 31import Internal.Numeric
32import Internal.Element 32import Internal.Element
33import Internal.Container 33import Internal.Container
diff --git a/packages/base/src/Internal/Vector.hs b/packages/base/src/Internal/Vector.hs
index e5ac440..29b6797 100644
--- a/packages/base/src/Internal/Vector.hs
+++ b/packages/base/src/Internal/Vector.hs
@@ -14,7 +14,7 @@ module Internal.Vector(
14 I,Z,R,C, 14 I,Z,R,C,
15 fi,ti, 15 fi,ti,
16 Vector, fromList, unsafeToForeignPtr, unsafeFromForeignPtr, unsafeWith, 16 Vector, fromList, unsafeToForeignPtr, unsafeFromForeignPtr, unsafeWith,
17 createVector, vec, avec, arrvec, inlinePerformIO, 17 createVector, avec, inlinePerformIO,
18 toList, dim, (@>), at', (|>), 18 toList, dim, (@>), at', (|>),
19 vjoin, subVector, takesV, idxs, 19 vjoin, subVector, takesV, idxs,
20 buildVector, 20 buildVector,
@@ -67,25 +67,11 @@ dim = Vector.length
67 67
68 68
69-- C-Haskell vector adapter 69-- C-Haskell vector adapter
70-- vec :: Adapt (CInt -> Ptr t -> r) (Vector t) r
71vec :: (Storable t) => Vector t -> (((CInt -> Ptr t -> t1) -> t1) -> IO b) -> IO b
72vec x f = unsafeWith x $ \p -> do
73 let v g = do
74 g (fi $ dim x) p
75 f v
76{-# INLINE vec #-}
77
78{-# INLINE avec #-} 70{-# INLINE avec #-}
79avec :: Storable a => (CInt -> Ptr a -> b) -> Vector a -> b 71avec :: Storable a => (CInt -> Ptr a -> b) -> Vector a -> b
80avec f v = inlinePerformIO (unsafeWith v (return . f (fromIntegral (Vector.length v)))) 72avec f v = inlinePerformIO (unsafeWith v (return . f (fromIntegral (Vector.length v))))
81infixl 1 `avec` 73infixl 1 `avec`
82 74
83{-# INLINE arrvec #-}
84arrvec :: Storable a => (Ptr CInt -> Ptr a -> b) -> Vector a -> b
85arrvec f v = inlinePerformIO (unsafeWith (idxs [1,dim v]) (\p -> unsafeWith v (return . f p)))
86
87
88
89-- allocates memory for a new vector 75-- allocates memory for a new vector
90createVector :: Storable a => Int -> IO (Vector a) 76createVector :: Storable a => Int -> IO (Vector a)
91createVector n = do 77createVector n = do