summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Matrix.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r--lib/Data/Packed/Matrix.hs12
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
44joinVert :: Element t => [Matrix t] -> Matrix t 44joinVert :: Element t => [Matrix t] -> Matrix t
45joinVert ms = case common cols ms of 45joinVert 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
50joinHoriz :: Element t => [Matrix t] -> Matrix t 50joinHoriz :: 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
96takeDiag :: (Element t) => Matrix t -> Vector t 96takeDiag :: (Element t) => Matrix t -> Vector t
97takeDiag m = fromList [cdat m `at` (k*cols m+k) | k <- [0 .. min (rows m) (cols m) -1]] 97takeDiag 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
100ident :: Element a => Int -> Matrix a 100ident :: 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)
1429 |> [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]@
143-}
144flatten :: Element t => Matrix t -> Vector t
145flatten = 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]]