我一直在試圖獲取包含元素nd的矩陣(A)的所有行索引。獲取滿足條件的Python矩陣的行索引
A的大小是4M * 4,這個操作需要大約12秒。
鏈接到文件:data
# Download the file named elementconnectivity before running this small script
A=np.loadtxt('elementconnectivity')
A=A.astype(int)
nd=1103
v=[i for i in range(len(A)) if nd in A[i]]
有沒有做到這一點更快的方法?
如果可以,請分享'A'和'nd'的樣本值。這會給我們更多的想法,知道你在做什麼樣的操作以及哪種解決方案更適合。 –
你好Vivek - 我給出了樣本值 – Mechanician