Skip to contents

Computes the trace (sum of diagonal elements) of a 2-D array.

Usage

nv_trace(operand)

Arguments

operand

(arrayish)
Operand.

Value

arrayish
A scalar with the same data type as operand.

Examples

x <- nv_array(c(1, 0, 0, 0, 2, 0, 0, 0, 3), shape = c(3, 3))
nv_trace(x)
#> AnvlArray
#>  6
#> [ CPUf32{} ]