numpy.tri(N, M=None, k=0, dtype=<class 'float'>)
[source]
An array with ones at and below the given diagonal and zeros elsewhere.
Parameters: |
N : int Number of rows in the array. M : int, optional Number of columns in the array. By default, k : int, optional The sub-diagonal at and below which the array is filled. dtype : dtype, optional Data type of the returned array. The default is float. |
---|---|
Returns: |
tri : ndarray of shape (N, M) Array with its lower triangle filled with ones and zero elsewhere; in other words |
>>> 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.]])
© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.14.2/reference/generated/numpy.tri.html