diff options
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 9 |
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 | ||
59 | takeDiag m = fromList [cdat m `at` (k*cols m+k) | k <- [0 .. min (rows m) (cols m) -1]] | 60 | takeDiag m = fromList [cdat m `at` (k*cols m+k) | k <- [0 .. min (rows m) (cols m) -1]] |
60 | 61 | ||
61 | ident n = diag (constant n 1) | 62 | ident n = diag (constant 1 n) |
62 | 63 | ||
63 | r >< c = f where | 64 | r >< 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 | |||
88 | dropColumns n mat = subMatrix (0,n) (rows mat, cols mat - n) mat | 89 | dropColumns n mat = subMatrix (0,n) (rows mat, cols mat - n) mat |
89 | 90 | ||
90 | ---------------------------------------------------------------- | 91 | ---------------------------------------------------------------- |
92 | |||
93 | flatten = cdat | ||