summaryrefslogtreecommitdiff
path: root/lib/Data/Packed
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed')
-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