summaryrefslogtreecommitdiff
path: root/lib/Data
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-06-26 07:47:21 +0000
committerAlberto Ruiz <aruiz@um.es>2007-06-26 07:47:21 +0000
commit3019948b97ba1c177b21ab103823fabe561b3ffe (patch)
tree7dbd400d679a765cdc1389e092cafb4b91f4eb89 /lib/Data
parent2984d5cc1cedb1621f6fa8d9dda0c515441f92e1 (diff)
passed easyVision tests
Diffstat (limited to 'lib/Data')
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs10
-rw-r--r--lib/Data/Packed/Vector.hs3
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-----------------------------------------------------------------
147liftMatrix :: (Vector a -> Vector b) -> Matrix a -> Matrix b 147liftMatrix :: (Field a, Field b) => (Vector a -> Vector b) -> Matrix a -> Matrix b
148liftMatrix f m = m { dat = f (dat m), tdat = f (tdat m) } -- check sizes 148liftMatrix f m = reshape (cols m) (f (cdat m))
149 149
150liftMatrix2 :: (Field t) => (Vector a -> Vector b -> Vector t) -> Matrix a -> Matrix b -> Matrix t 150liftMatrix2 :: (Field t) => (Vector a -> Vector b -> Vector t) -> Matrix a -> Matrix b -> Matrix t
151liftMatrix2 f m1 m2 = reshape (cols m1) (f (cdat m1) (cdat m2)) -- check sizes 151liftMatrix2 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
155compat :: Matrix a -> Matrix b -> Bool
156compat m1 m2 = rows m1 == rows m2 && cols m1 == cols m2
157
154dotL a b = sum (zipWith (*) a b) 158dotL a b = sum (zipWith (*) a b)
155 159
156multiplyL a b | ok = [[dotL x y | y <- transpose b] | x <- a] 160multiplyL 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
27import Data.Packed.Internal 28import Data.Packed.Internal