Skip to contents

Given a matrix and the size of a block, returns a list containing all diagonal submatrices made by blocks.

Usage

dblocklist(mat, block)

Arguments

mat

numeric matrix

block

Integer vector of length 2, containing the size of the block (rows, columns). If only one integer is passed, the block is square

Value

A list of diangonal submatrices made by blocks

Examples

mat <- matrix(1:64, nrow = 8, byrow = TRUE)
mat
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#> [1,]    1    2    3    4    5    6    7    8
#> [2,]    9   10   11   12   13   14   15   16
#> [3,]   17   18   19   20   21   22   23   24
#> [4,]   25   26   27   28   29   30   31   32
#> [5,]   33   34   35   36   37   38   39   40
#> [6,]   41   42   43   44   45   46   47   48
#> [7,]   49   50   51   52   53   54   55   56
#> [8,]   57   58   59   60   61   62   63   64

dblocklist(mat, 4)
#> $`1`
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    2    3    4
#> [2,]    9   10   11   12
#> [3,]   17   18   19   20
#> [4,]   25   26   27   28
#> 
#> $`2`
#>      [,1] [,2] [,3] [,4]
#> [1,]   37   38   39   40
#> [2,]   45   46   47   48
#> [3,]   53   54   55   56
#> [4,]   61   62   63   64
#>