diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-06-03 18:21:24 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-06-03 18:21:24 +0200 |
commit | b4fa1d9ca83f99f5057fcf70ed409b5038908f66 (patch) | |
tree | efedc612bfb9b27446fa8e043f314a26e95c9969 /packages/base/src/Data/Packed | |
parent | 5481f94f5b936a2ad1947200838ea27ee860d0e7 (diff) | |
parent | 55e2326e76e7e1ee2ac0d753198b8f47e1c695ef (diff) |
Merge pull request #126 from ntfrgl/master
Generalize step control function
Diffstat (limited to 'packages/base/src/Data/Packed')
-rw-r--r-- | packages/base/src/Data/Packed/Matrix.hs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/packages/base/src/Data/Packed/Matrix.hs b/packages/base/src/Data/Packed/Matrix.hs index 70b9232..3690293 100644 --- a/packages/base/src/Data/Packed/Matrix.hs +++ b/packages/base/src/Data/Packed/Matrix.hs | |||
@@ -33,8 +33,9 @@ module Data.Packed.Matrix ( | |||
33 | fromRows, toRows, fromColumns, toColumns, | 33 | fromRows, toRows, fromColumns, toColumns, |
34 | fromBlocks, diagBlock, toBlocks, toBlocksEvery, | 34 | fromBlocks, diagBlock, toBlocks, toBlocksEvery, |
35 | repmat, | 35 | repmat, |
36 | flipud, fliprl, | 36 | flipud, fliprl, subMatrix, |
37 | subMatrix, takeRows, dropRows, takeColumns, dropColumns, | 37 | takeRows, takeLastRows, dropRows, dropLastRows, |
38 | takeColumns, takeLastColumns, dropColumns, dropLastColumns, | ||
38 | extractRows, extractColumns, | 39 | extractRows, extractColumns, |
39 | diagRect, takeDiag, | 40 | diagRect, takeDiag, |
40 | mapMatrix, mapMatrixWithIndex, mapMatrixWithIndexM, mapMatrixWithIndexM_, | 41 | mapMatrix, mapMatrixWithIndex, mapMatrixWithIndexM, mapMatrixWithIndexM_, |
@@ -253,15 +254,27 @@ r >< c = f where | |||
253 | -- | Creates a matrix with the first n rows of another matrix | 254 | -- | Creates a matrix with the first n rows of another matrix |
254 | takeRows :: Element t => Int -> Matrix t -> Matrix t | 255 | takeRows :: Element t => Int -> Matrix t -> Matrix t |
255 | takeRows n mt = subMatrix (0,0) (n, cols mt) mt | 256 | takeRows n mt = subMatrix (0,0) (n, cols mt) mt |
257 | -- | Creates a matrix with the last n rows of another matrix | ||
258 | takeLastRows :: Element t => Int -> Matrix t -> Matrix t | ||
259 | takeLastRows n mt = subMatrix (rows mt - n, 0) (n, cols mt) mt | ||
256 | -- | Creates a copy of a matrix without the first n rows | 260 | -- | Creates a copy of a matrix without the first n rows |
257 | dropRows :: Element t => Int -> Matrix t -> Matrix t | 261 | dropRows :: Element t => Int -> Matrix t -> Matrix t |
258 | dropRows n mt = subMatrix (n,0) (rows mt - n, cols mt) mt | 262 | dropRows n mt = subMatrix (n,0) (rows mt - n, cols mt) mt |
263 | -- | Creates a copy of a matrix without the last n rows | ||
264 | dropLastRows :: Element t => Int -> Matrix t -> Matrix t | ||
265 | dropLastRows n mt = subMatrix (0,0) (rows mt - n, cols mt) mt | ||
259 | -- |Creates a matrix with the first n columns of another matrix | 266 | -- |Creates a matrix with the first n columns of another matrix |
260 | takeColumns :: Element t => Int -> Matrix t -> Matrix t | 267 | takeColumns :: Element t => Int -> Matrix t -> Matrix t |
261 | takeColumns n mt = subMatrix (0,0) (rows mt, n) mt | 268 | takeColumns n mt = subMatrix (0,0) (rows mt, n) mt |
269 | -- |Creates a matrix with the last n columns of another matrix | ||
270 | takeLastColumns :: Element t => Int -> Matrix t -> Matrix t | ||
271 | takeLastColumns n mt = subMatrix (0, cols mt - n) (rows mt, n) mt | ||
262 | -- | Creates a copy of a matrix without the first n columns | 272 | -- | Creates a copy of a matrix without the first n columns |
263 | dropColumns :: Element t => Int -> Matrix t -> Matrix t | 273 | dropColumns :: Element t => Int -> Matrix t -> Matrix t |
264 | dropColumns n mt = subMatrix (0,n) (rows mt, cols mt - n) mt | 274 | dropColumns n mt = subMatrix (0,n) (rows mt, cols mt - n) mt |
275 | -- | Creates a copy of a matrix without the last n columns | ||
276 | dropLastColumns :: Element t => Int -> Matrix t -> Matrix t | ||
277 | dropLastColumns n mt = subMatrix (0,0) (rows mt, cols mt - n) mt | ||
265 | 278 | ||
266 | ---------------------------------------------------------------- | 279 | ---------------------------------------------------------------- |
267 | 280 | ||