dpctl.tensor.triu

dpctl.tensor.triu(x, /, *, k=0)[source]

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

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

Parameters:
  • x (usm_ndarray) – Input array

  • k (int, optional) – Specifies the diagonal below which to set elements to zero. 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

Returns:

An upper-triangular array or a stack of upper-triangular arrays.

Return type:

usm_ndarray