cupy.indices#

cupy.indices(dimensions, dtype=<class 'int'>)[source]#

Returns an array representing the indices of a grid.

Computes an array where the subarrays contain index values 0,1,… varying only along the corresponding axis.

Parameters:
  • dimensions – The shape of the grid.

  • dtype – Data type specifier. It is int by default.

Returns:

The array of grid indices, grid.shape = (len(dimensions),) + tuple(dimensions).

Return type:

ndarray

Examples

>>> grid = cupy.indices((2, 3))
>>> grid.shape
(2, 2, 3)
>>> grid[0]        # row indices
array([[0, 0, 0],
       [1, 1, 1]])
>>> grid[1]        # column indices
array([[0, 1, 2],
       [0, 1, 2]])

See also

numpy.indices()