summaryrefslogtreecommitdiff
path: root/lib/GSL/Vector.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-06-16 11:20:50 +0000
committerAlberto Ruiz <aruiz@um.es>2007-06-16 11:20:50 +0000
commitcc2c8c39dc088dcace0d2749cfe9180bf5fdbfd2 (patch)
tree0c33b9e728eec572ebcf5a5806f35d89cdcf8dbc /lib/GSL/Vector.hs
parentf71a0a7e65f5fcd4e4e05a3cf114fc7d76419091 (diff)
differentiation, integration, special
Diffstat (limited to 'lib/GSL/Vector.hs')
-rw-r--r--lib/GSL/Vector.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/GSL/Vector.hs b/lib/GSL/Vector.hs
index e538b7e..3225139 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 21 scale, addConstant, add, mul,
22) where 22) where
23 23
24import Data.Packed.Internal 24import Data.Packed.Internal
@@ -79,6 +79,18 @@ addConstant x v | isReal baseOf v = scast $ vectorMapValR AddConstant (scast x)
79 | isComp baseOf v = scast $ vectorMapValC AddConstant (scast x) (scast v) 79 | isComp baseOf v = scast $ vectorMapValC AddConstant (scast x) (scast v)
80 | otherwise = fromList $ map (*x) $ toList v 80 | otherwise = fromList $ map (*x) $ toList v
81 81
82add :: (Num a, Field a) => Vector a -> Vector a -> Vector a
83add u v | isReal baseOf v = scast $ vectorZipR Add (scast u) (scast v)
84 | isComp baseOf v = scast $ vectorZipC Add (scast u) (scast v)
85 | otherwise = fromList $ zipWith (+) (toList u) (toList v)
86
87mul :: (Num a, Field a) => Vector a -> Vector a -> Vector a
88mul u v | isReal baseOf v = scast $ vectorZipR Mul (scast u) (scast v)
89 | isComp baseOf v = scast $ vectorZipC Mul (scast u) (scast v)
90 | otherwise = fromList $ zipWith (*) (toList u) (toList v)
91
92
93
82------------------------------------------------------------------ 94------------------------------------------------------------------
83 95
84toScalarAux fun code v = unsafePerformIO $ do 96toScalarAux fun code v = unsafePerformIO $ do