R/api.R
nv_trace.Rd
Computes the trace (sum of diagonal elements) of a 2-D array.
nv_trace(operand)
(arrayish) Operand.
arrayish
arrayish A scalar with the same data type as operand.
operand
nv_extract_diag(), nv_diag()
nv_extract_diag()
nv_diag()
x <- nv_array(c(1, 0, 0, 0, 2, 0, 0, 0, 3), shape = c(3, 3)) nv_trace(x) #> AnvlArray #> 6 #> [ CPUf32{} ]