This is documentation for an old release of NumPy (version 1.6.0). Read this page in the documentation of the latest stable release (version > 1.17).
An array with ones at and below the given diagonal and zeros elsewhere.
Parameters : | N : int
M : int, optional
k : int, optional
dtype : dtype, optional
|
---|---|
Returns : | T : ndarray of shape (N, M)
|
Examples
>>> np.tri(3, 5, 2, dtype=int)
array([[1, 1, 1, 0, 0],
[1, 1, 1, 1, 0],
[1, 1, 1, 1, 1]])
>>> np.tri(3, 5, -1)
array([[ 0., 0., 0., 0., 0.],
[ 1., 0., 0., 0., 0.],
[ 1., 1., 0., 0., 0.]])