R/api.R
nv_diag.Rd
Creates a diagonal matrix from a 1-D tensor.
nv_diag(x)
(tensorish) A 1-D tensor of length n whose elements become the diagonal entries.
tensorish
n
tensorish An n x n matrix with x on the diagonal and zeros elsewhere.
n x n
x
jit_eval({ nv_diag(nv_tensor(c(1, 2, 3))) }) #> AnvilTensor #> 1 0 0 #> 0 2 0 #> 0 0 3 #> [ CPUf32{3,3} ]