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/GSL/Vector.hs | |
parent | 3d5d6f06598aac00906c93ac5358e68697c47fc7 (diff) |
l.a. algorithms, etc.
Diffstat (limited to 'lib/GSL/Vector.hs')
-rw-r--r-- | lib/GSL/Vector.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/GSL/Vector.hs b/lib/GSL/Vector.hs index a772b34..a074254 100644 --- a/lib/GSL/Vector.hs +++ b/lib/GSL/Vector.hs | |||
@@ -18,7 +18,7 @@ module GSL.Vector ( | |||
18 | FunCodeV(..), vectorMapR, vectorMapC, | 18 | FunCodeV(..), vectorMapR, vectorMapC, |
19 | FunCodeSV(..), vectorMapValR, vectorMapValC, | 19 | FunCodeSV(..), vectorMapValR, vectorMapValC, |
20 | FunCodeVV(..), vectorZipR, vectorZipC, | 20 | FunCodeVV(..), vectorZipR, vectorZipC, |
21 | scale, addConstant, add, mul, | 21 | scale, addConstant, add, sub, mul, |
22 | ) where | 22 | ) where |
23 | 23 | ||
24 | import Data.Packed.Internal | 24 | import Data.Packed.Internal |
@@ -84,6 +84,11 @@ add u v | isReal baseOf v = scast $ vectorZipR Add (scast u) (scast v) | |||
84 | | isComp baseOf v = scast $ vectorZipC Add (scast u) (scast v) | 84 | | isComp baseOf v = scast $ vectorZipC Add (scast u) (scast v) |
85 | | otherwise = fromList $ zipWith (+) (toList u) (toList v) | 85 | | otherwise = fromList $ zipWith (+) (toList u) (toList v) |
86 | 86 | ||
87 | sub :: (Num a, Field a) => Vector a -> Vector a -> Vector a | ||
88 | sub u v | isReal baseOf v = scast $ vectorZipR Sub (scast u) (scast v) | ||
89 | | isComp baseOf v = scast $ vectorZipC Sub (scast u) (scast v) | ||
90 | | otherwise = fromList $ zipWith (-) (toList u) (toList v) | ||
91 | |||
87 | mul :: (Num a, Field a) => Vector a -> Vector a -> Vector a | 92 | mul :: (Num a, Field a) => Vector a -> Vector a -> Vector a |
88 | mul u v | isReal baseOf v = scast $ vectorZipR Mul (scast u) (scast v) | 93 | mul u v | isReal baseOf v = scast $ vectorZipR Mul (scast u) (scast v) |
89 | | isComp baseOf v = scast $ vectorZipC Mul (scast u) (scast v) | 94 | | isComp baseOf v = scast $ vectorZipC Mul (scast u) (scast v) |