BetterDocs
Home
Docs

Creation | np.tril()

Method:

np.tril(m, k=0)

Extracts the lower triangular part of an array.

Returns:

np.ndarray

Parameters:

m: array-like-

The input matrix.

import numpy as np
matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
result = np.tril(m=matrix, k=0)
print(result)
'''
Output:
[[1 0 0]
 [4 5 0]
 [7 8 9]]
'''

k: int, Optional-

The diagonal offset (default 0). A positive value refers to an upper diagonal, and a negative value to a lower diagonal.

k = 0 (default) +

k = 1 +

k = -1 +


Logo

BetterDocs

Support

EmailDiscordForms

Documentations

Python

Company

AboutDocs

Policies

Terms of ServicePrivacy Policy