numpy.tril() in Python

The tril() function of Python numpy class returns a copy of an array with the elements above the k-th diagonal zeroed.

Syntax

Parameter

a: It represents the input array

k: This parameter represents the Diagonal we require. It is an optional integer parameter, and its default value is 0. If k>0, it means the diagonal is above the main diagonal or vice versa.

Return

This function returns the Lower triangle of the parameter ‘a’ while having the same shape and data-type as ‘a’.

Example 1

Output

Pin It on Pinterest

Share This