I'd like to know how to search over N vectors for the differences between them and a reference vector. In other words, i want all elements of reference_arr
that is not present in any of the N vectors.
Example:
reference_arr = [0,1,2,3,4,5,6,7,8,9,10]
A = [0, 4, 5]
B = [0, 10]
C = [1, 5, 7]
Desired output would be: [2,3,6,8,9]
My solution would be concatenate everything in a single vector, cast as a set to remove duplicate values and then use np.setdiff1d()
. I don't know how this can scale (how many N
vectors i would have), so i can't say it's the best solution. Any guidance would be appreciated.
Thanks in advance.
question from:
https://stackoverflow.com/questions/65929250/get-difference-among-n-vectors-and-a-reference-array 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…