我有一个矩阵x_faces
有3列和N个元素(在本例中为4)。 每行,我想知道它是否包含任何元素的数组matches
与矩阵行中的元素匹配数组
x_faces = [[ 0, 43, 446],
[ 8, 43, 446],
[ 0, 10, 446],
[ 0, 5, 425]
]
matches = [8, 10, 44, 425, 440]
应返回此:
results = [
False,
True,
True,
True
]
我能想到的一个for循环,这样做,但有一个干净的方式来做到这一点在Python中?
我找到了更快的方法:'np.any( np.in1d(x_faces,匹配[i])。reshape(-1,3),axis = 1)' – bl3nd3d