diff options
Diffstat (limited to 'packages/base')
-rw-r--r-- | packages/base/src/Internal/CG.hs | 2 | ||||
-rw-r--r-- | packages/base/src/Internal/Convolution.hs | 2 | ||||
-rw-r--r-- | packages/base/src/Internal/Devel.hs | 9 | ||||
-rw-r--r-- | packages/base/src/Internal/Modular.hs | 2 | ||||
-rw-r--r-- | packages/base/src/Internal/Vector.hs | 16 |
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 | ||
9 | import Internal.Vector | 9 | import Internal.Vector |
10 | import Internal.Matrix hiding (mat) | 10 | import Internal.Matrix |
11 | import Internal.Numeric | 11 | import Internal.Numeric |
12 | import Internal.Element | 12 | import Internal.Element |
13 | import Internal.IO | 13 | import 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 | ||
19 | import qualified Data.Vector.Storable as SV | 19 | import qualified Data.Vector.Storable as SV |
20 | import Internal.Vector | 20 | import Internal.Vector |
21 | import Internal.Matrix hiding (mat) | 21 | import Internal.Matrix |
22 | import Internal.Numeric | 22 | import Internal.Numeric |
23 | import Internal.Element | 23 | import Internal.Element |
24 | import Internal.Conversion | 24 | import 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 () |
18 | import Foreign.Ptr(Ptr) | 18 | import Foreign.Ptr(Ptr) |
19 | import Control.Exception as E ( SomeException, catch ) | 19 | import Control.Exception as E ( SomeException, catch ) |
20 | import Internal.Vector(Vector,avec,arrvec) | 20 | import Internal.Vector(Vector,avec) |
21 | import Foreign.Storable(Storable) | 21 | import 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 | ||
89 | instance Storable t => TransArray (Vector t) | 88 | instance 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 | ||
29 | import Internal.Vector | 29 | import Internal.Vector |
30 | import Internal.Matrix hiding (mat,size) | 30 | import Internal.Matrix hiding (size) |
31 | import Internal.Numeric | 31 | import Internal.Numeric |
32 | import Internal.Element | 32 | import Internal.Element |
33 | import Internal.Container | 33 | import 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 | ||
71 | vec :: (Storable t) => Vector t -> (((CInt -> Ptr t -> t1) -> t1) -> IO b) -> IO b | ||
72 | vec 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 #-} |
79 | avec :: Storable a => (CInt -> Ptr a -> b) -> Vector a -> b | 71 | avec :: Storable a => (CInt -> Ptr a -> b) -> Vector a -> b |
80 | avec f v = inlinePerformIO (unsafeWith v (return . f (fromIntegral (Vector.length v)))) | 72 | avec f v = inlinePerformIO (unsafeWith v (return . f (fromIntegral (Vector.length v)))) |
81 | infixl 1 `avec` | 73 | infixl 1 `avec` |
82 | 74 | ||
83 | {-# INLINE arrvec #-} | ||
84 | arrvec :: Storable a => (Ptr CInt -> Ptr a -> b) -> Vector a -> b | ||
85 | arrvec 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 |
90 | createVector :: Storable a => Int -> IO (Vector a) | 76 | createVector :: Storable a => Int -> IO (Vector a) |
91 | createVector n = do | 77 | createVector n = do |