diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index fe8c159..1b67820 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -30,7 +30,7 @@ module Data.Packed.Matrix ( | |||
30 | (@@>), | 30 | (@@>), |
31 | asRow, asColumn, | 31 | asRow, asColumn, |
32 | fromRows, toRows, fromColumns, toColumns, | 32 | fromRows, toRows, fromColumns, toColumns, |
33 | fromBlocks, toBlocks, toBlocksEvery, | 33 | fromBlocks, diagBlock, toBlocks, toBlocksEvery, |
34 | repmat, | 34 | repmat, |
35 | flipud, fliprl, | 35 | flipud, fliprl, |
36 | subMatrix, takeRows, dropRows, takeColumns, dropColumns, | 36 | subMatrix, takeRows, dropRows, takeColumns, dropColumns, |
@@ -156,7 +156,19 @@ adaptBlocks ms = ms' where | |||
156 | x = m@@>(0,0) | 156 | x = m@@>(0,0) |
157 | g _ _ = error "inconsistent dimensions in fromBlocks" | 157 | g _ _ = error "inconsistent dimensions in fromBlocks" |
158 | 158 | ||
159 | ----------------------------------------------------------- | 159 | |
160 | -------------------------------------------------------------------------------- | ||
161 | |||
162 | -- | create a block diagonal matrix | ||
163 | diagBlock :: (Element t, Num t) => [Matrix t] -> Matrix t | ||
164 | diagBlock ms = fromBlocks $ zipWith f ms [0..] | ||
165 | where | ||
166 | f m k = take n $ replicate k z ++ m : repeat z | ||
167 | n = length ms | ||
168 | z = (1><1) [0] | ||
169 | |||
170 | -------------------------------------------------------------------------------- | ||
171 | |||
160 | 172 | ||
161 | -- | Reverse rows | 173 | -- | Reverse rows |
162 | flipud :: Element t => Matrix t -> Matrix t | 174 | flipud :: Element t => Matrix t -> Matrix t |