Python | Numpy np.triu_indices Last Updated : 30 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report With the help of np.triu_indices() method, we can get the indices for the upper triangle of an [n, m] array by using np.triu_indices() method. Syntax : np.triu_indices(n, m) Return : Return the indices for the upper triangle. Example #1 : In this example we can see that by using np.triu_indices() method, we are able to get the indices for the upper triangle of an [n, m] array by using this method. Python3 1=1 # import numpy and triu_indices import numpy as np # using np.triu_indices() method gfg = np.triu_indices(2, 3) print(gfg) Output : (array([], dtype = int64), array([], dtype = int64)) Example #2 : Python3 1=1 # import numpy and triu_indices import numpy as np # using np.triu_indices() method gfg = np.triu_indices(4) print(gfg) Output : array([], dtype = int64) Comment More infoAdvertise with us Next Article numpy.diag_indices() in Python J jitender_1998 Follow Improve Article Tags : Python Python numpy-Indexing Practice Tags : python Similar Reads numpy.triu() in Python numpy.triu(a, k = 0) : Returns copy of array with upper part of the triangle w.r.t k Parameters : a : input array k : [int, optional, 0 by default] Diagonal we require; k>0 means diagonal above main diagonal or vice versa. Returns : Upper triangle of a, having same shape and data-type as a. Pytho 1 min read numpy.tri() in Python numpy.tri(R, C = None, k = 0, dtype = 'float') : Creates an array with 1's at and below the given diagonal(about k) and 0's 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 2 min read numpy.tril() in Python numpy.tril(a, k=0) : Returns copy of array with lower part of the triangle w.r.t k Parameters : a : input array k : [int, optional, 0 by default] Diagonal we require; k>0 means diagonal above main diagonal or vice versa. Returns : Lower triangle of a, having same shape and data-type as a. Python 1 min read numpy.cos() in Python numpy.cos(x[, out]) = ufunc 'cos') : This mathematical function helps user to calculate trigonometric cosine for all x(being the array elements). Parameters : array : [array_like]elements are in radians. 2pi Radians = 360 degrees Return : An array with trigonometric cosine of x for all x i.e. array 2 min read numpy.diag_indices() in Python The numpy.diag_indices() function returns indices in order to access the elements of main diagonal of a array with minimum dimension = 2. Returns indices in the form of tuple. to access the main diagonal of an array. Syntax: numpy.diag_indices(n, n_dim = 2) Parameters : n : size of array, for whic 2 min read numpy.take() in Python The numpy.take() function returns elements from array along the mentioned axis and indices. Syntax: numpy.take(array, indices, axis = None, out = None, mode ='raise') Parameters : array : array_like, input array indices : index of the values to be fetched axis : [int, optional] axis over which we ne 2 min read Like