On Dec 2, 2009, at 6:55 PM, Howard Chong wrote:
> 
> My question is: how can I make the latter version run faster? I think the 
> answer is that I have to do the iteration in C.
> 
> If that's the case, can anyone point me to where np.array.argmax() is 
> implemented so I can write np.array.argmaxN() extend it to the N largest 
> values?

What about using .argsort and take the last N values ?
>>>  x=np.array([10,40,30,50,20])
>>> i=x.argsort()[-2:]
>>> (i,x[i])
 (array([1, 3]), array([40, 50]))
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to