mindspore.numpy.tril_indices(n, k=0, m=None)[source]

Returns the indices for the lower-triangle of an (n, m) array.

  • n (int) – The size of the arrays for which the returned indices will be valid.

  • k (int, optional) – Diagonal offset, default is 0.

  • m (int, optional) – The column dimension of the arrays for which the returned arrays will be valid. By default m is taken equal to n.


The indices for the triangle. The returned tuple contains two tensors, each with the indices along one dimension of the tensor.


TypeError – If n, k, m are not numbers.

Supported Platforms:

Ascend GPU CPU


>>> import mindspore.numpy as np
>>> print(np.tril_indices(3))
(Tensor(shape=[6], dtype=Int32, value= [0, 1, 1, 2, 2, 2]),
Tensor(shape=[6], dtype=Int32, value= [0, 0, 1, 0, 1, 2]))