Skip to contents

Implements the matrix exponential acyclicity regularizer from DAGs with no TEARS (Zheng et al 2018)

Usage

h_expm(W, include_grad = FALSE)

h_expm_grad(W)

Arguments

W

weighted adjacency matrix

include_grad

whether to include the gradient of the regularizer

Value

either a list if gradient is included or a scalar

Examples

 X <- matrix(0, nrow = 3, ncol = 3)
X_lower <- lower.tri(X)

# DAG
h_expm(lower.tri(X))
#> [1] 0

# Not a DAG
X2 <- X_lower
X2[1, 2] <- 1
h_expm(X2)
#> [1] 1.086161