mindspore.numpy.tril

View Source On Gitee
mindspore.numpy.tril(m, k=0)[source]

Returns a lower triangle of a tensor.

Returns a copy of a tensor with elements above the k-th diagonal zeroed.

Parameters
  • m (Union[Tensor, list, tuple]) – The shape and data-type of m define these same attributes of the returned tensor.

  • k (int, optional) – Diagonal above which to zero elements. \(k = 0\) (the default) is the main diagonal, \(k < 0\) is below it and \(k > 0\) is above.

Returns

Lower triangle of m, of same shape and data-type as m.

Supported Platforms:

Ascend GPU CPU

Raises
  • TypeError – If input arguments have types not specified above.

  • ValueError – If input m's rank \(< 1\).

Examples

>>> import mindspore.numpy as np
>>> output = np.tril(np.ones((3, 3)))
>>> print(output)
[[1. 0. 0.]
[1. 1. 0.]
[1. 1. 1.]]