numpy.tri (R, C = No, k = 0, dtype = & # 39; float & # 39;): Creates an array with 1 at and below the given diagonal (about k) and 0 elsewhere.
Parameters :
R: Number of rows C: [optional] Number of columns; By default R = C k: [int, optional, 0 by default] Diagonal we require; k" 0 means diagonal above main diagonal or vice versa. dtype: [optional, float (byDefault)] Data type of returned array.
|
Exit:
tri with k = 1: [[1. 1. 0.] [1. 1. 1.]] tri with main diagonal: [[1. 0. 0. 0. 0 .] [1. 1. 0. 0. 0.] [1. 1. 1. 0. 0.]] tri with k = -1: [[0. 0. 0. 0. 0.] [1. 0. 0. 0. 0.] [1. 1. 0. 0. 0.]]
Links:
https: / /docs.scipy.org/doc/numpy/reference/generated/numpy.tri.html
Notes:
These NumPy-Python programs will not work with onlineID, so run them on your systems to examine them
,
This article is provided by Mohit Gupta_OMG