Skip to contents

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

Usage

blocklist(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 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

blocklist(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,]    5    6    7    8
#> [2,]   13   14   15   16
#> [3,]   21   22   23   24
#> [4,]   29   30   31   32
#> 
#> $`3`
#>      [,1] [,2] [,3] [,4]
#> [1,]   33   34   35   36
#> [2,]   41   42   43   44
#> [3,]   49   50   51   52
#> [4,]   57   58   59   60
#> 
#> $`4`
#>      [,1] [,2] [,3] [,4]
#> [1,]   37   38   39   40
#> [2,]   45   46   47   48
#> [3,]   53   54   55   56
#> [4,]   61   62   63   64
#>