n <- 100
ps <- c(10, 20, 30)
mats <- lapply(ps, function(p) {
X <- matrix(rnorm(n * p), n, p)
matrix.dense(t(X) %*% X, method="cov")
})
out <- matrix.block_diag(mats, method="cov")
mats <- lapply(ps, function(p) {
X <- matrix(rnorm(n * p), n, p)
matrix.dense(X, method="naive")
})
out <- matrix.block_diag(mats, method="naive")
Run the code above in your browser using DataLab