summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Vector.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-06-25 07:32:56 +0000
committerAlberto Ruiz <aruiz@um.es>2007-06-25 07:32:56 +0000
commit1871acb835b4fc164bcff3f6e7467884b87fbd0f (patch)
treeac1028d40778bbae532c3915276b5af21ba5f5cb /lib/Data/Packed/Internal/Vector.hs
parent3d5d6f06598aac00906c93ac5358e68697c47fc7 (diff)
l.a. algorithms, etc.
Diffstat (limited to 'lib/Data/Packed/Internal/Vector.hs')
-rw-r--r--lib/Data/Packed/Internal/Vector.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs
index 25e848d..f1addf4 100644
--- a/lib/Data/Packed/Internal/Vector.hs
+++ b/lib/Data/Packed/Internal/Vector.hs
@@ -48,7 +48,7 @@ fromList l = unsafePerformIO $ do
48toList :: Storable a => Vector a -> [a] 48toList :: Storable a => Vector a -> [a]
49toList v = unsafePerformIO $ peekArray (dim v) (ptr v) 49toList v = unsafePerformIO $ peekArray (dim v) (ptr v)
50 50
51n # l = if length l == n then fromList l else error "# with wrong size" 51n |> l = if length l == n then fromList l else error "|> with wrong size"
52 52
53at' :: Storable a => Vector a -> Int -> a 53at' :: Storable a => Vector a -> Int -> a
54at' v n = unsafePerformIO $ peekElemOff (ptr v) n 54at' v n = unsafePerformIO $ peekElemOff (ptr v) n
@@ -58,7 +58,7 @@ at v n | n >= 0 && n < dim v = at' v n
58 | otherwise = error "vector index out of range" 58 | otherwise = error "vector index out of range"
59 59
60instance (Show a, Storable a) => (Show (Vector a)) where 60instance (Show a, Storable a) => (Show (Vector a)) where
61 show v = (show (dim v))++" # " ++ show (toList v) 61 show v = (show (dim v))++" |> " ++ show (toList v)
62 62
63-- | creates a Vector taking a number of consecutive toList from another Vector 63-- | creates a Vector taking a number of consecutive toList from another Vector
64subVector :: Storable t => Int -- ^ index of the starting element 64subVector :: Storable t => Int -- ^ index of the starting element
@@ -129,3 +129,5 @@ constant x n | isReal id x = scast $ constantR (scast x) n
129 | isComp id x = scast $ constantC (scast x) n 129 | isComp id x = scast $ constantC (scast x) n
130 | otherwise = constantG x n 130 | otherwise = constantG x n
131 131
132liftVector f = fromList . map f . toList
133liftVector2 f u v = fromList $ zipWith f (toList u) (toList v)