scipy.linalg.tri#

scipy.linalg.tri(N, M=None, k=0, dtype=None)[source]#

Deprecated since version 1.11.0: tri is deprecated in favour of numpy.tri and will be removed in SciPy 1.13.0.

Construct (N, M) matrix filled with ones at and below the kth diagonal.

The matrix has A[i,j] == 1 for j <= i + k

Parameters:
Nint

The size of the first dimension of the matrix.

Mint or None, optional

The size of the second dimension of the matrix. If M is None, M = N is assumed.

kint, optional

Number of subdiagonal below which matrix is filled with ones. k = 0 is the main diagonal, k < 0 subdiagonal and k > 0 superdiagonal.

dtypedtype, optional

Data type of the matrix.

Returns:
tri(N, M) ndarray

Tri matrix.

Examples

>>> from scipy.linalg import tri
>>> tri(3, 5, 2, dtype=int)
array([[1, 1, 1, 0, 0],
       [1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1]])
>>> tri(3, 5, -1, dtype=int)
array([[0, 0, 0, 0, 0],
       [1, 0, 0, 0, 0],
       [1, 1, 0, 0, 0]])