summaryrefslogtreecommitdiff
path: root/examples/devel/ej2/wrappers.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-10-04 19:46:43 +0200
committerAlberto Ruiz <aruiz@um.es>2015-10-04 19:46:43 +0200
commitc84a485f148063f6d0c23f016fe348ec94fb6b19 (patch)
tree2ac1755695a42d3964208e0029e74d446f5c3bd8 /examples/devel/ej2/wrappers.hs
parent0500032a1d954058b94cf9a0fa2a662e5666a526 (diff)
updated devel example
Diffstat (limited to 'examples/devel/ej2/wrappers.hs')
-rw-r--r--examples/devel/ej2/wrappers.hs32
1 files changed, 0 insertions, 32 deletions
diff --git a/examples/devel/ej2/wrappers.hs b/examples/devel/ej2/wrappers.hs
deleted file mode 100644
index 1c02a24..0000000
--- a/examples/devel/ej2/wrappers.hs
+++ /dev/null
@@ -1,32 +0,0 @@
1{-# LANGUAGE ForeignFunctionInterface #-}
2
3-- $ ghc -O2 --make wrappers.hs functions.c
4
5import Numeric.LinearAlgebra
6import Data.Packed.Development
7import Foreign(Ptr,unsafePerformIO)
8import Foreign.C.Types(CInt)
9
10-----------------------------------------------------
11
12main = do
13 print $ myDiag $ (3><5) [1..]
14
15-----------------------------------------------------
16-- arbitrary data order
17
18foreign import ccall unsafe "c_diag"
19 cDiag :: CInt -- matrix order
20 -> CInt -> CInt -> Ptr Double -- argument
21 -> CInt -> Ptr Double -- result1
22 -> CInt -> CInt -> Ptr Double -- result2
23 -> IO CInt -- exit code
24
25myDiag m = unsafePerformIO $ do
26 y <- createVector (min r c)
27 z <- createMatrix (orderOf m) r c
28 app3 (cDiag o) mat m vec y mat z "cDiag"
29 return (y,z)
30 where r = rows m
31 c = cols m
32 o = if orderOf m == RowMajor then 1 else 0