b.diag | R Documentation |
Construct a block diagonal matrix using multiple given block matrices.
b.diag(..., fill = 0)
... |
individual matrices or one list of matrices. |
fill |
non-block-diagonal elements. Default is |
Avoid combining matrices and lists for the ...
argument.
b.diag()
covers the arguments of type "character".
If a sparse matrix needed, run the following:
library(Matrix); Matrix(b_diag, sparse = TRUE)
where b_diag
is the matrix returned by b.diag()
.
b.diag()
returns a block diagonal matrix obtained by combining the arguments.
Hassan Pazira
Maintainer: Hassan Pazira hassan.pazira@radboudumc.nl
b.diag(1, matrix(1:3, 3,4), diag(3:2))
b.diag(matrix(1:6, 2), as.character(2))
lists <- list(1, 2:3, diag(4:6), 7, cbind(8,9:12), 13:15)
b.diag(lists)
identical(b.diag(lists), b.diag(lapply(lists, as.matrix)))
b.diag(replicate(3, matrix(round(rnorm(9)), 3, 3), simplify=FALSE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.