diff options
author | Alberto Ruiz <aruiz@um.es> | 2014-05-08 08:48:12 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2014-05-08 08:48:12 +0200 |
commit | 1925c123d7d8184a1d2ddc0a413e0fd2776e1083 (patch) | |
tree | fad79f909d9c3be53d68e6ebd67202650536d387 /lib/Numeric/GSL/Internal.hs | |
parent | eb3f702d065a4a967bb754977233e6eec408fd1f (diff) |
empty hmatrix-base
Diffstat (limited to 'lib/Numeric/GSL/Internal.hs')
-rw-r--r-- | lib/Numeric/GSL/Internal.hs | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/lib/Numeric/GSL/Internal.hs b/lib/Numeric/GSL/Internal.hs deleted file mode 100644 index 69a9750..0000000 --- a/lib/Numeric/GSL/Internal.hs +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | -- Module : Numeric.GSL.Internal | ||
2 | -- Copyright : (c) Alberto Ruiz 2009 | ||
3 | -- License : GPL | ||
4 | -- | ||
5 | -- Maintainer : Alberto Ruiz (aruiz at um dot es) | ||
6 | -- Stability : provisional | ||
7 | -- Portability : uses ffi | ||
8 | -- | ||
9 | -- Auxiliary functions. | ||
10 | -- | ||
11 | -- #hide | ||
12 | |||
13 | module Numeric.GSL.Internal where | ||
14 | |||
15 | import Data.Packed.Internal | ||
16 | |||
17 | import Foreign.Marshal.Array(copyArray) | ||
18 | import Foreign.Ptr(Ptr, FunPtr) | ||
19 | import Foreign.C.Types | ||
20 | import System.IO.Unsafe(unsafePerformIO) | ||
21 | |||
22 | iv :: (Vector Double -> Double) -> (CInt -> Ptr Double -> Double) | ||
23 | iv f n p = f (createV (fromIntegral n) copy "iv") where | ||
24 | copy n' q = do | ||
25 | copyArray q p (fromIntegral n') | ||
26 | return 0 | ||
27 | |||
28 | -- | conversion of Haskell functions into function pointers that can be used in the C side | ||
29 | foreign import ccall safe "wrapper" | ||
30 | mkVecfun :: (CInt -> Ptr Double -> Double) | ||
31 | -> IO( FunPtr (CInt -> Ptr Double -> Double)) | ||
32 | |||
33 | foreign import ccall safe "wrapper" | ||
34 | mkVecVecfun :: TVV -> IO (FunPtr TVV) | ||
35 | |||
36 | foreign import ccall safe "wrapper" | ||
37 | mkDoubleVecVecfun :: (Double -> TVV) -> IO (FunPtr (Double -> TVV)) | ||
38 | |||
39 | foreign import ccall safe "wrapper" | ||
40 | mkDoublefun :: (Double -> Double) -> IO (FunPtr (Double -> Double)) | ||
41 | |||
42 | aux_vTov :: (Vector Double -> Vector Double) -> TVV | ||
43 | aux_vTov f n p nr r = g where | ||
44 | v = f x | ||
45 | x = createV (fromIntegral n) copy "aux_vTov" | ||
46 | copy n' q = do | ||
47 | copyArray q p (fromIntegral n') | ||
48 | return 0 | ||
49 | g = do unsafeWith v $ \p' -> copyArray r p' (fromIntegral nr) | ||
50 | return 0 | ||
51 | |||
52 | foreign import ccall safe "wrapper" | ||
53 | mkVecMatfun :: TVM -> IO (FunPtr TVM) | ||
54 | |||
55 | foreign import ccall safe "wrapper" | ||
56 | mkDoubleVecMatfun :: (Double -> TVM) -> IO (FunPtr (Double -> TVM)) | ||
57 | |||
58 | aux_vTom :: (Vector Double -> Matrix Double) -> TVM | ||
59 | aux_vTom f n p rr cr r = g where | ||
60 | v = flatten $ f x | ||
61 | x = createV (fromIntegral n) copy "aux_vTov" | ||
62 | copy n' q = do | ||
63 | copyArray q p (fromIntegral n') | ||
64 | return 0 | ||
65 | g = do unsafeWith v $ \p' -> copyArray r p' (fromIntegral $ rr*cr) | ||
66 | return 0 | ||
67 | |||
68 | createV n fun msg = unsafePerformIO $ do | ||
69 | r <- createVector n | ||
70 | app1 fun vec r msg | ||
71 | return r | ||
72 | |||
73 | createMIO r c fun msg = do | ||
74 | res <- createMatrix RowMajor r c | ||
75 | app1 fun mat res msg | ||
76 | return res | ||