Creates a block diagonal matrix with its arguments as the blocks.

BlockMatrix(...)

Arguments

...

Matrices that should be put on the diagonal.

Value

Block diagonal matrix having the specified matrices on its diagonal.

Details

BlockMatrix() tries to coerce its arguments to a matrix, using as.matrix.

Author

Dylan Beijers, dylanbeijers@gmail.com

Examples

BlockMatrix(diag(ceiling(9 * stats::runif(5))), matrix(1:8, 4, 2), c(14, 8))
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#>  [1,]    9    0    0    0    0    0    0    0
#>  [2,]    0    2    0    0    0    0    0    0
#>  [3,]    0    0    5    0    0    0    0    0
#>  [4,]    0    0    0    5    0    0    0    0
#>  [5,]    0    0    0    0    5    0    0    0
#>  [6,]    0    0    0    0    0    1    5    0
#>  [7,]    0    0    0    0    0    2    6    0
#>  [8,]    0    0    0    0    0    3    7    0
#>  [9,]    0    0    0    0    0    4    8    0
#> [10,]    0    0    0    0    0    0    0   14
#> [11,]    0    0    0    0    0    0    0    8