tril

tril(x: array, /, *, k: int = 0) array

Returns the lower triangular part of a matrix (or a stack of matrices) x.

Note

The lower triangular part of the matrix is defined as the elements on and below the specified diagonal k.

Parameters:
  • x (array) – input array having shape (..., M, N) and whose innermost two dimensions form MxN matrices.

  • k (int) –

    diagonal above which to zero elements. If k = 0, the diagonal is the main diagonal. If k < 0, the diagonal is below the main diagonal. If k > 0, the diagonal is above the main diagonal. Default: 0.

    Note

    The main diagonal is defined as the set of indices {(i, i)} for i on the interval [0, min(M, N) - 1].

Returns:

out (array) – an array containing the lower triangular part(s). The returned array must have the same shape and data type as x. All elements above the specified diagonal k must be zeroed. The returned array should be allocated on the same device as x.