diff options
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index ab02670..2ab1541 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -109,17 +109,18 @@ joinVert ms = case common cols ms of | |||
109 | joinHoriz :: Element t => [Matrix t] -> Matrix t | 109 | joinHoriz :: Element t => [Matrix t] -> Matrix t |
110 | joinHoriz ms = trans. joinVert . map trans $ ms | 110 | joinHoriz ms = trans. joinVert . map trans $ ms |
111 | 111 | ||
112 | {- | Creates a matrix from blocks given as a list of lists of matrices. | 112 | {- | Create a matrix from blocks given as a list of lists of matrices. |
113 | 113 | ||
114 | Single row/column components are automatically expanded to match the | 114 | Single row-column components are automatically expanded to match the |
115 | corresponding common row and column: | 115 | corresponding common row and column: |
116 | 116 | ||
117 | @\> let disp = putStr . dispf 2 | 117 | @ |
118 | \> let vector xs = fromList xs :: Vector Double | 118 | > let disp = putStr . dispf 2 |
119 | \> let diagl = diag . vector | 119 | > let vector xs = fromList xs :: Vector Double |
120 | \> let rowm = asRow . vector | 120 | > let diagl = diag . vector |
121 | > let rowm = asRow . vector | ||
121 | 122 | ||
122 | \> disp $ fromBlocks [[ident 5, 7, rowm[10,20]], [3, diagl[1,2,3], 0]] | 123 | > disp $ fromBlocks [[ident 5, 7, rowm[10,20]], [3, diagl[1,2,3], 0]] |
123 | 124 | ||
124 | 8x10 | 125 | 8x10 |
125 | 1 0 0 0 0 7 7 7 10 20 | 126 | 1 0 0 0 0 7 7 7 10 20 |
@@ -129,7 +130,9 @@ corresponding common row and column: | |||
129 | 0 0 0 0 1 7 7 7 10 20 | 130 | 0 0 0 0 1 7 7 7 10 20 |
130 | 3 3 3 3 3 1 0 0 0 0 | 131 | 3 3 3 3 3 1 0 0 0 0 |
131 | 3 3 3 3 3 0 2 0 0 0 | 132 | 3 3 3 3 3 0 2 0 0 0 |
132 | 3 3 3 3 3 0 0 3 0 0@ | 133 | 3 3 3 3 3 0 0 3 0 0 |
134 | @ | ||
135 | |||
133 | -} | 136 | -} |
134 | fromBlocks :: Element t => [[Matrix t]] -> Matrix t | 137 | fromBlocks :: Element t => [[Matrix t]] -> Matrix t |
135 | fromBlocks = fromBlocksRaw . adaptBlocks | 138 | fromBlocks = fromBlocksRaw . adaptBlocks |