Peculiar version of expand.grid() for matrices

mult_grid(L)
pair_grid(a,b)

Arguments

L

List of matrices

a,b

Matrices

Details

Function pair_grid(a,b) returns a matrix with each column of a cbind()-ed to each column of b.

Function mult_grid() takes a list of matrices; it is designed for use by ggrl().

Author

Robin K. S. Hankin

See also

Examples

pair_grid(diag(2),diag(3))
#>      [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,]    1    1    1    0    0    0
#> [2,]    0    0    0    1    1    1
#> [3,]    1    0    0    1    0    0
#> [4,]    0    1    0    0    1    0
#> [5,]    0    0    1    0    0    1
mult_grid(lapply(1:4,diag))
#> [[1]]
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
#>  [1,]    1    1    1    1    1    1    1    1    1     1     1     1     1
#>  [2,]    1    1    1    1    1    1    1    1    1     1     1     1     0
#>  [3,]    0    0    0    0    0    0    0    0    0     0     0     0     1
#>  [4,]    1    1    1    1    0    0    0    0    0     0     0     0     1
#>  [5,]    0    0    0    0    1    1    1    1    0     0     0     0     0
#>  [6,]    0    0    0    0    0    0    0    0    1     1     1     1     0
#>  [7,]    1    0    0    0    1    0    0    0    1     0     0     0     1
#>  [8,]    0    1    0    0    0    1    0    0    0     1     0     0     0
#>  [9,]    0    0    1    0    0    0    1    0    0     0     1     0     0
#> [10,]    0    0    0    1    0    0    0    1    0     0     0     1     0
#>       [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
#>  [1,]     1     1     1     1     1     1     1     1     1     1     1
#>  [2,]     0     0     0     0     0     0     0     0     0     0     0
#>  [3,]     1     1     1     1     1     1     1     1     1     1     1
#>  [4,]     1     1     1     0     0     0     0     0     0     0     0
#>  [5,]     0     0     0     1     1     1     1     0     0     0     0
#>  [6,]     0     0     0     0     0     0     0     1     1     1     1
#>  [7,]     0     0     0     1     0     0     0     1     0     0     0
#>  [8,]     1     0     0     0     1     0     0     0     1     0     0
#>  [9,]     0     1     0     0     0     1     0     0     0     1     0
#> [10,]     0     0     1     0     0     0     1     0     0     0     1
#>