efficient loop over numpy array

前端 未结 8 1646
轮回少年
轮回少年 2021-01-06 02:05

Versions of this question have already been asked but I have not found a satisfactory answer.

Problem: given a large numpy vector, find indices of t

8条回答
  •  无人及你
    2021-01-06 02:29

    This solution using the numpy_indexed package has complexity n Log n, and is fully vectorized; so not terribly different from C performance, in all likelihood.

    import numpy_indexed as npi
    dpl = np.flatnonzero(npi.multiplicity(vect) > 1)
    

提交回复
热议问题