Skip to contents

Extracts the diagonal elements from a 2-D array.

Usage

nv_extract_diag(operand)

Arguments

operand

(arrayish)
Operand.

Value

arrayish
A 1-D array of length min(nrow, ncol) containing the diagonal elements.

See also

nv_diag() for creating a diagonal matrix, nv_trace()

Examples

x <- nv_array(1:9, shape = c(3, 3))
nv_extract_diag(x)
#> AnvlArray
#>  1
#>  5
#>  9
#> [ CPUi32{3} ]