Python | Numpy np.triu_indices
Last Updated :
30 Jan, 2020
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.
import numpy as np
gfg = np.triu_indices( 2 , 3 )
print (gfg)
|
Output :
(array([], dtype = int64), array([], dtype = int64))
Example #2 :
import numpy as np
gfg = np.triu_indices( 4 )
print (gfg)
|
Output :
array([], dtype = int64)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...