The function takes a list and constructs a block diagonal matrix with the elements of the list on the diagonal. If d is not a list then d will be repeated n times and written on the diagonal (a wrapper for kronecker())

diag.block(d, n)

Arguments

d

a list of matrices or vectors, or a matrix or vector

n

number of repetitions

Value

returns a matrix with the elements of the list or the repetitions of the supplied matrix or vector on the diagonal.

See also

Examples

a <- matrix(rep(1, 4), nrow = 2) b <- matrix(rep(2, 6), nrow = 2) e <- c(3, 3, 3, 3) f <- t(e) d <- list(a, b, e, f) diag.block(d)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #> [1,] 1 1 0 0 0 0 0 0 0 0 #> [2,] 1 1 0 0 0 0 0 0 0 0 #> [3,] 0 0 2 2 2 0 0 0 0 0 #> [4,] 0 0 2 2 2 0 0 0 0 0 #> [5,] 0 0 0 0 0 3 0 0 0 0 #> [6,] 0 0 0 0 0 3 0 0 0 0 #> [7,] 0 0 0 0 0 3 0 0 0 0 #> [8,] 0 0 0 0 0 3 0 0 0 0 #> [9,] 0 0 0 0 0 0 3 3 3 3
diag.block(a, 3)
#> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 1 1 0 0 0 0 #> [2,] 1 1 0 0 0 0 #> [3,] 0 0 1 1 0 0 #> [4,] 0 0 1 1 0 0 #> [5,] 0 0 0 0 1 1 #> [6,] 0 0 0 0 1 1