summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Matrix.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-06-22 17:33:17 +0000
committerAlberto Ruiz <aruiz@um.es>2007-06-22 17:33:17 +0000
commit978e6d038239af50d70bae2c303f4e45b1879b7a (patch)
tree571b2060f388d0693820f808b40089acb100a5d9 /lib/Data/Packed/Matrix.hs
parent989bdf7e88c13500bd1986dcde36f6cc4f467efb (diff)
refactoring
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r--lib/Data/Packed/Matrix.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs
index ec5744d..c7d5cfa 100644
--- a/lib/Data/Packed/Matrix.hs
+++ b/lib/Data/Packed/Matrix.hs
@@ -16,12 +16,13 @@ module Data.Packed.Matrix (
16 Matrix(rows,cols), Field, 16 Matrix(rows,cols), Field,
17 toLists, (><), (>|<), (@@>), 17 toLists, (><), (>|<), (@@>),
18 trans, 18 trans,
19 reshape, 19 reshape, flatten,
20 fromRows, toRows, fromColumns, toColumns, 20 fromRows, toRows, fromColumns, toColumns,
21 joinVert, joinHoriz, 21 joinVert, joinHoriz,
22 flipud, fliprl, 22 flipud, fliprl,
23 liftMatrix, liftMatrix2, 23 liftMatrix, liftMatrix2,
24 multiply, 24 multiply,
25 outer,
25 subMatrix, 26 subMatrix,
26 takeRows, dropRows, takeColumns, dropColumns, 27 takeRows, dropRows, takeColumns, dropColumns,
27 diag, takeDiag, diagRect, ident 28 diag, takeDiag, diagRect, ident
@@ -54,11 +55,11 @@ diagRect s r c
54 | r == c = diag s 55 | r == c = diag s
55 | r < c = trans $ diagRect s c r 56 | r < c = trans $ diagRect s c r
56 | r > c = joinVert [diag s , zeros (r-c,c)] 57 | r > c = joinVert [diag s , zeros (r-c,c)]
57 where zeros (r,c) = reshape c $ constant (r*c) 0 58 where zeros (r,c) = reshape c $ constant 0 (r*c)
58 59
59takeDiag m = fromList [cdat m `at` (k*cols m+k) | k <- [0 .. min (rows m) (cols m) -1]] 60takeDiag m = fromList [cdat m `at` (k*cols m+k) | k <- [0 .. min (rows m) (cols m) -1]]
60 61
61ident n = diag (constant n 1) 62ident n = diag (constant 1 n)
62 63
63r >< c = f where 64r >< c = f where
64 f l | dim v == r*c = matrixFromVector RowMajor c v 65 f l | dim v == r*c = matrixFromVector RowMajor c v
@@ -88,3 +89,5 @@ dropColumns :: Field t => Int -> Matrix t -> Matrix t
88dropColumns n mat = subMatrix (0,n) (rows mat, cols mat - n) mat 89dropColumns n mat = subMatrix (0,n) (rows mat, cols mat - n) mat
89 90
90---------------------------------------------------------------- 91----------------------------------------------------------------
92
93flatten = cdat