diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-06-26 07:47:21 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-06-26 07:47:21 +0000 |
commit | 3019948b97ba1c177b21ab103823fabe561b3ffe (patch) | |
tree | 7dbd400d679a765cdc1389e092cafb4b91f4eb89 /lib/Data/Packed | |
parent | 2984d5cc1cedb1621f6fa8d9dda0c515441f92e1 (diff) |
passed easyVision tests
Diffstat (limited to 'lib/Data/Packed')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 10 | ||||
-rw-r--r-- | lib/Data/Packed/Vector.hs | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index dd33943..9895393 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -144,13 +144,17 @@ transdata c1 d c2 | isReal baseOf d = scast $ transdataR c1 (scast d) c2 | |||
144 | --{-# RULES "transdataC" transdata=transdataC #-} | 144 | --{-# RULES "transdataC" transdata=transdataC #-} |
145 | 145 | ||
146 | ----------------------------------------------------------------- | 146 | ----------------------------------------------------------------- |
147 | liftMatrix :: (Vector a -> Vector b) -> Matrix a -> Matrix b | 147 | liftMatrix :: (Field a, Field b) => (Vector a -> Vector b) -> Matrix a -> Matrix b |
148 | liftMatrix f m = m { dat = f (dat m), tdat = f (tdat m) } -- check sizes | 148 | liftMatrix f m = reshape (cols m) (f (cdat m)) |
149 | 149 | ||
150 | liftMatrix2 :: (Field t) => (Vector a -> Vector b -> Vector t) -> Matrix a -> Matrix b -> Matrix t | 150 | liftMatrix2 :: (Field t) => (Vector a -> Vector b -> Vector t) -> Matrix a -> Matrix b -> Matrix t |
151 | liftMatrix2 f m1 m2 = reshape (cols m1) (f (cdat m1) (cdat m2)) -- check sizes | 151 | liftMatrix2 f m1 m2 | compat m1 m2 = reshape (cols m1) (f (cdat m1) (cdat m2)) |
152 | | otherwise = error "nonconformant matrices in liftMatrix2" | ||
152 | ------------------------------------------------------------------ | 153 | ------------------------------------------------------------------ |
153 | 154 | ||
155 | compat :: Matrix a -> Matrix b -> Bool | ||
156 | compat m1 m2 = rows m1 == rows m2 && cols m1 == cols m2 | ||
157 | |||
154 | dotL a b = sum (zipWith (*) a b) | 158 | dotL a b = sum (zipWith (*) a b) |
155 | 159 | ||
156 | multiplyL a b | ok = [[dotL x y | y <- transpose b] | x <- a] | 160 | multiplyL a b | ok = [[dotL x y | y <- transpose b] | x <- a] |
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs index 94f70be..27ba6a3 100644 --- a/lib/Data/Packed/Vector.hs +++ b/lib/Data/Packed/Vector.hs | |||
@@ -21,7 +21,8 @@ module Data.Packed.Vector ( | |||
21 | toComplex, comp, | 21 | toComplex, comp, |
22 | conj, | 22 | conj, |
23 | dot, | 23 | dot, |
24 | linspace | 24 | linspace, |
25 | liftVector, liftVector2 | ||
25 | ) where | 26 | ) where |
26 | 27 | ||
27 | import Data.Packed.Internal | 28 | import Data.Packed.Internal |