diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-11-12 10:01:39 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-11-12 10:01:39 +0000 |
commit | c41d21fefa04c66039a0b218daaa53c2577ef838 (patch) | |
tree | 3dd182457a89edbf52688fb43fdc8b2a130829e8 /lib/Data/Packed/Matrix.hs | |
parent | 9e6500bf8e925b363e74e01834f81dde0810f808 (diff) |
data structures simplification
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index e96500f..7b6bf29 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -44,7 +44,7 @@ import Data.Array | |||
44 | joinVert :: Element t => [Matrix t] -> Matrix t | 44 | joinVert :: Element t => [Matrix t] -> Matrix t |
45 | joinVert ms = case common cols ms of | 45 | joinVert ms = case common cols ms of |
46 | Nothing -> error "joinVert on matrices with different number of columns" | 46 | Nothing -> error "joinVert on matrices with different number of columns" |
47 | Just c -> reshape c $ join (map cdat ms) | 47 | Just c -> reshape c $ join (map flatten ms) |
48 | 48 | ||
49 | -- | creates a matrix from a horizontal list of matrices | 49 | -- | creates a matrix from a horizontal list of matrices |
50 | joinHoriz :: Element t => [Matrix t] -> Matrix t | 50 | joinHoriz :: Element t => [Matrix t] -> Matrix t |
@@ -94,7 +94,7 @@ diagRect s r c | |||
94 | 94 | ||
95 | -- | extracts the diagonal from a rectangular matrix | 95 | -- | extracts the diagonal from a rectangular matrix |
96 | takeDiag :: (Element t) => Matrix t -> Vector t | 96 | takeDiag :: (Element t) => Matrix t -> Vector t |
97 | takeDiag m = fromList [cdat m `at` (k*cols m+k) | k <- [0 .. min (rows m) (cols m) -1]] | 97 | takeDiag m = fromList [flatten m `at` (k*cols m+k) | k <- [0 .. min (rows m) (cols m) -1]] |
98 | 98 | ||
99 | -- | creates the identity matrix of given dimension | 99 | -- | creates the identity matrix of given dimension |
100 | ident :: Element a => Int -> Matrix a | 100 | ident :: Element a => Int -> Matrix a |
@@ -136,14 +136,6 @@ dropColumns n mat = subMatrix (0,n) (rows mat, cols mat - n) mat | |||
136 | 136 | ||
137 | ---------------------------------------------------------------- | 137 | ---------------------------------------------------------------- |
138 | 138 | ||
139 | {- | Creates a vector by concatenation of rows | ||
140 | |||
141 | @\> flatten ('ident' 3) | ||
142 | 9 |> [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]@ | ||
143 | -} | ||
144 | flatten :: Element t => Matrix t -> Vector t | ||
145 | flatten = cdat | ||
146 | |||
147 | {- | Creates a 'Matrix' from a list of lists (considered as rows). | 139 | {- | Creates a 'Matrix' from a list of lists (considered as rows). |
148 | 140 | ||
149 | @\> fromLists [[1,2],[3,4],[5,6]] | 141 | @\> fromLists [[1,2],[3,4],[5,6]] |