diff options
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) |