diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-06-07 11:13:32 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-06-07 11:13:32 +0000 |
commit | 92b1ed5e7fcbebbfbcde34206c040a8472d847d9 (patch) | |
tree | 6f22b46ea656490e6392a005321e6d5f7da0898d /lib/Data/Packed | |
parent | e7c03c1ab4de85e7a700d2eafaebd37f4607c51f (diff) |
adapting lapack wrappers
Diffstat (limited to 'lib/Data/Packed')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 14 | ||||
-rw-r--r-- | lib/Data/Packed/Internal/Tensor.hs | 4 |
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index ec6657a..db53cd1 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -160,6 +160,10 @@ toRows m = toRows' 0 where | |||
160 | toRows' k | k == r*c = [] | 160 | toRows' k | k == r*c = [] |
161 | | otherwise = subVector k c v : toRows' (k+c) | 161 | | otherwise = subVector k c v : toRows' (k+c) |
162 | 162 | ||
163 | ----------------------------------------------------------------- | ||
164 | |||
165 | liftMatrix f m = m { dat = f dat, tdat = f tdat } -- check sizes | ||
166 | |||
163 | ------------------------------------------------------------------ | 167 | ------------------------------------------------------------------ |
164 | 168 | ||
165 | dotL a b = sum (zipWith (*) a b) | 169 | dotL a b = sum (zipWith (*) a b) |
@@ -208,6 +212,16 @@ multiplyD order a b | |||
208 | 212 | ||
209 | ---------------------------------------------------------------------- | 213 | ---------------------------------------------------------------------- |
210 | 214 | ||
215 | outer u v = dat (multiply RowMajor r c) | ||
216 | where r = matrixFromVector RowMajor 1 u | ||
217 | c = matrixFromVector RowMajor (dim v) v | ||
218 | |||
219 | dot u v = dat (multiply RowMajor r c) `at` 0 | ||
220 | where r = matrixFromVector RowMajor (dim u) u | ||
221 | c = matrixFromVector RowMajor 1 v | ||
222 | |||
223 | ---------------------------------------------------------------------- | ||
224 | |||
211 | -- | extraction of a submatrix of a real matrix | 225 | -- | extraction of a submatrix of a real matrix |
212 | subMatrixR :: (Int,Int) -- ^ (r0,c0) starting position | 226 | subMatrixR :: (Int,Int) -- ^ (r0,c0) starting position |
213 | -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix | 227 | -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix |
diff --git a/lib/Data/Packed/Internal/Tensor.hs b/lib/Data/Packed/Internal/Tensor.hs index b66d6b8..67dcb09 100644 --- a/lib/Data/Packed/Internal/Tensor.hs +++ b/lib/Data/Packed/Internal/Tensor.hs | |||
@@ -27,10 +27,6 @@ data Tensor t = T { dims :: [(Int,(IdxTp,String))] | |||
27 | 27 | ||
28 | rank = length . dims | 28 | rank = length . dims |
29 | 29 | ||
30 | outer u v = dat (multiply RowMajor r c) | ||
31 | where r = matrixFromVector RowMajor 1 u | ||
32 | c = matrixFromVector RowMajor (dim v) v | ||
33 | |||
34 | instance (Show a,Storable a) => Show (Tensor a) where | 30 | instance (Show a,Storable a) => Show (Tensor a) where |
35 | show T {dims = [], ten = t} = "scalar "++show (t `at` 0) | 31 | show T {dims = [], ten = t} = "scalar "++show (t `at` 0) |
36 | show T {dims = ds, ten = t} = "("++shdims ds ++") "++ show (toList t) | 32 | show T {dims = ds, ten = t} = "("++shdims ds ++") "++ show (toList t) |