cunumeric.diag_indices#

cunumeric.diag_indices(n: int, ndim: int = 2) tuple[ndarray, ...]#

Return the indices to access the main diagonal of an array.

This returns a tuple of indices that can be used to access the main diagonal of an array a with a.ndim >= 2 dimensions and shape (n, n, …, n). For a.ndim = 2 this is the usual diagonal, for a.ndim > 2 this is the set of indices to access a[i, i, …, i] for i = [0..n-1].

Parameters:
  • n (int) – The size, along each dimension, of the arrays for which the returned indices can be used.

  • ndim (int, optional) – The number of dimensions.

Availability:

Multiple GPUs, Multiple CPUs