np.triu_indices_from() 返回方陣的上三角矩陣的索引


np.triu_indices_from() 

返回方陣的上三角矩陣的索引

numpy.triu_indices_from(arr,k = 0 )

參數:

arr :ndarray,shape(N,N)

k: int,可選,對角線偏移

例子:

import numpy as np

a = np.array([[1,2],[4,5]])
np.triu_indices_from(a)
#(array([0, 0, 1], dtype=int64), array([0, 1, 1], dtype=int64))

https://numpy.org/doc/stable/reference/generated/numpy.triu_indices_from.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM