diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-06-25 07:32:56 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-06-25 07:32:56 +0000 |
commit | 1871acb835b4fc164bcff3f6e7467884b87fbd0f (patch) | |
tree | ac1028d40778bbae532c3915276b5af21ba5f5cb /lib/Data/Packed/Internal/Vector.hs | |
parent | 3d5d6f06598aac00906c93ac5358e68697c47fc7 (diff) |
l.a. algorithms, etc.
Diffstat (limited to 'lib/Data/Packed/Internal/Vector.hs')
-rw-r--r-- | lib/Data/Packed/Internal/Vector.hs | 6 |
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 | |||
48 | toList :: Storable a => Vector a -> [a] | 48 | toList :: Storable a => Vector a -> [a] |
49 | toList v = unsafePerformIO $ peekArray (dim v) (ptr v) | 49 | toList v = unsafePerformIO $ peekArray (dim v) (ptr v) |
50 | 50 | ||
51 | n # l = if length l == n then fromList l else error "# with wrong size" | 51 | n |> l = if length l == n then fromList l else error "|> with wrong size" |
52 | 52 | ||
53 | at' :: Storable a => Vector a -> Int -> a | 53 | at' :: Storable a => Vector a -> Int -> a |
54 | at' v n = unsafePerformIO $ peekElemOff (ptr v) n | 54 | at' 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 | ||
60 | instance (Show a, Storable a) => (Show (Vector a)) where | 60 | instance (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 |
64 | subVector :: Storable t => Int -- ^ index of the starting element | 64 | subVector :: 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 | ||
132 | liftVector f = fromList . map f . toList | ||
133 | liftVector2 f u v = fromList $ zipWith f (toList u) (toList v) | ||