Nikolaus Rath wrote:

> eat <e.antero.ta...@gmail.com> writes:
>> Nikolaus Rath <Nikolaus <at> rath.org> writes:
>>
>> [snip]
>>> Not quite, because I'm interested in the n largest values over all
>>> elements, not the largest element in each row or column. But Keith's
>>> solution seems to work fine, even though I'm still struggling to
>>> understand what's going on there .
>>
>> My bad. I just concentrated on your example, not the actual question.
>>
>> However, what's wrong with your above approach
>> "[ np.unravel_index(i, x.shape) for i in idx[-3:] ]" ?
>>
>> Especially if your n largest elements are just a small fraction of all
>> elements.
> 
> The fact that it sorts the entire list. But since for my arrays it's not
> really an efficiency problem, I will use it anyway.
> 
> 
> 
> Best,
> 
>    -Nikolaus
> 

I use boost::python and pyublas to package a function that exposes the c++ 
std::partial_sort

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to