Construct diagonal matrix from vector

as_diag(x)

Arguments

x

Matrix with 1 row or 1 column that is the diagonal in a new diagonal matrix

Examples

if (has_sympy()) {
  d <- as_sym(c("a", "b", "c"))
  D <- as_diag(d)
  D
}
#> c: ⎡a  0  0⎤
#>    ⎢       ⎥
#>    ⎢0  b  0⎥
#>    ⎢       ⎥
#>    ⎣0  0  c⎦