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.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs
index 2b93348..260c1e0 100644
--- a/lib/Data/Packed/Matrix.hs
+++ b/lib/Data/Packed/Matrix.hs
@@ -9,7 +9,7 @@
9-- Stability : provisional 9-- Stability : provisional
10-- Portability : portable 10-- Portability : portable
11-- 11--
12-- Matrices 12-- A Matrix representation suitable for numerical computations using LAPACK and GSL.
13-- 13--
14----------------------------------------------------------------------------- 14-----------------------------------------------------------------------------
15 15
@@ -22,7 +22,7 @@ module Data.Packed.Matrix (
22 trans, conjTrans, 22 trans, conjTrans,
23 asRow, asColumn, 23 asRow, asColumn,
24 fromRows, toRows, fromColumns, toColumns, 24 fromRows, toRows, fromColumns, toColumns,
25 fromBlocks, 25 fromBlocks, repmat,
26 flipud, fliprl, 26 flipud, fliprl,
27 subMatrix, takeRows, dropRows, takeColumns, dropColumns, 27 subMatrix, takeRows, dropRows, takeColumns, dropColumns,
28 extractRows, 28 extractRows,
@@ -215,3 +215,16 @@ readMatrix = fromLists . map (map read). map words . filter (not.null) . lines
215extractRows :: Field t => [Int] -> Matrix t -> Matrix t 215extractRows :: Field t => [Int] -> Matrix t -> Matrix t
216extractRows l m = fromRows $ extract (toRows $ m) l 216extractRows l m = fromRows $ extract (toRows $ m) l
217 where extract l is = [l!!i |i<-is] 217 where extract l is = [l!!i |i<-is]
218
219{- | creates matrix by repetition of a matrix a given number of rows and columns
220
221@> repmat (ident 2) 2 3 :: Matrix Double
222(4><6)
223 [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0
224 , 0.0, 1.0, 0.0, 1.0, 0.0, 1.0
225 , 1.0, 0.0, 1.0, 0.0, 1.0, 0.0
226 , 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]@
227
228-}
229repmat :: (Field t) => Matrix t -> Int -> Int -> Matrix t
230repmat m r c = fromBlocks $ partit c $ replicate (r*c) m \ No newline at end of file