triu

sparse.triu(x, k=0)[source]

Returns an array with all elements below the k-th diagonal set to zero.

Parameters:
  • x (COO) – The input array.

  • k (int, optional) – The diagonal below which elements are set to zero. The default is zero, which corresponds to the main diagonal.

Returns:

The output upper-triangular matrix.

Return type:

COO

Raises:

ValueError – If x doesn’t have zero fill-values.

See also

numpy.triu

NumPy equivalent function