diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-03-01 11:15:22 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-03-01 11:15:22 +0000 |
commit | 283f3033f86fabde2290bb28a59e7d87fd0754f5 (patch) | |
tree | ac9000c976a805636b557b916af9e139922df70c /examples/vector.hs | |
parent | 54bcc1fc1e0f9676cb10f627f412eeeea34b5d2c (diff) |
compatible with vector
Diffstat (limited to 'examples/vector.hs')
-rw-r--r-- | examples/vector.hs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/vector.hs b/examples/vector.hs index 12cbc42..855c6b4 100644 --- a/examples/vector.hs +++ b/examples/vector.hs | |||
@@ -12,7 +12,7 @@ import qualified Data.Vector.Storable as V | |||
12 | 12 | ||
13 | fromVector :: Storable t => V.Vector t -> H.Vector t | 13 | fromVector :: Storable t => V.Vector t -> H.Vector t |
14 | fromVector v = unsafeFromForeignPtr p i n where | 14 | fromVector v = unsafeFromForeignPtr p i n where |
15 | (p,i,n) = V.unsafeToForeignPtr (V.copy v) | 15 | (p,i,n) = V.unsafeToForeignPtr v |
16 | 16 | ||
17 | toVector :: H.Vector t -> V.Vector t | 17 | toVector :: H.Vector t -> V.Vector t |
18 | toVector v = V.unsafeFromForeignPtr p i n where | 18 | toVector v = V.unsafeFromForeignPtr p i n where |
@@ -22,8 +22,11 @@ toVector v = V.unsafeFromForeignPtr p i n where | |||
22 | 22 | ||
23 | v = V.slice 5 10 (V.fromList [1 .. 10::Double] V.++ V.replicate 10 7) | 23 | v = V.slice 5 10 (V.fromList [1 .. 10::Double] V.++ V.replicate 10 7) |
24 | 24 | ||
25 | w = linspace 5 (0,2) | 25 | w = subVector 2 3 (linspace 10 (0,2)) |
26 | 26 | ||
27 | main = do | 27 | main = do |
28 | print v | ||
28 | print $ fromVector v | 29 | print $ fromVector v |
30 | print w | ||
29 | print $ toVector w | 31 | print $ toVector w |
32 | |||