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 /examples/vector.hs | |
parent | eb3f702d065a4a967bb754977233e6eec408fd1f (diff) |
empty hmatrix-base
Diffstat (limited to 'examples/vector.hs')
-rw-r--r-- | examples/vector.hs | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/examples/vector.hs b/examples/vector.hs deleted file mode 100644 index f531cbd..0000000 --- a/examples/vector.hs +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | -- conversion to/from Data.Vector.Storable | ||
2 | -- from Roman Leshchinskiy "vector" package | ||
3 | -- | ||
4 | -- In the future Data.Packed.Vector will be replaced by Data.Vector.Storable | ||
5 | |||
6 | ------------------------------------------- | ||
7 | |||
8 | import Numeric.LinearAlgebra as H | ||
9 | import Data.Packed.Development(unsafeFromForeignPtr, unsafeToForeignPtr) | ||
10 | import Foreign.Storable | ||
11 | import qualified Data.Vector.Storable as V | ||
12 | |||
13 | fromVector :: Storable t => V.Vector t -> H.Vector t | ||
14 | fromVector v = unsafeFromForeignPtr p i n where | ||
15 | (p,i,n) = V.unsafeToForeignPtr v | ||
16 | |||
17 | toVector :: Storable t => H.Vector t -> V.Vector t | ||
18 | toVector v = V.unsafeFromForeignPtr p i n where | ||
19 | (p,i,n) = unsafeToForeignPtr v | ||
20 | |||
21 | ------------------------------------------- | ||
22 | |||
23 | v = V.slice 5 10 (V.fromList [1 .. 10::Double] V.++ V.replicate 10 7) | ||
24 | |||
25 | w = subVector 2 3 (linspace 5 (0,1)) :: Vector Double | ||
26 | |||
27 | main = do | ||
28 | print v | ||
29 | print $ fromVector v | ||
30 | print w | ||
31 | print $ toVector w | ||