-1
我創建了一個形狀爲(4,2)的簡單numpy數組,名爲A
。邏輯索引 - 在C++中的numpy.where
import numpy as np
A = np.array([[1, 2],
[2, 2],
[3, 2],
[4, 2]])
我想獲得其中第一列是2和第3行的指標,所以我所做的:
indices = np.where((A[:, 0] == 2) | (A[:, 0] == 3))[0]
這樣做我有兩個項目的數組(1和2) ,這是我想要的。
現在我想用C++高效地做到這一點。有沒有辦法使用Eigen做到這一點?我想避免循環。
謝謝。