matrix.block_diag: Creates a block-diagonal matrix.

View source: R/matrix.R

matrix.block_diagR Documentation

Creates a block-diagonal matrix.

Description

Creates a block-diagonal matrix.

Usage

matrix.block_diag(mats, n_threads = 1)

Arguments

mats

List of matrices.

n_threads

Number of threads.

Value

Block-diagonal matrix.

Author(s)

Trevor Hastie and James Yang
Maintainer: Trevor Hastie hastie@stanford.edu

Examples

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)

adelie documentation built on Sept. 11, 2024, 6:36 p.m.