Is there any way to use argpartition on a general n-dimensional array and have it return only the first 2 components?
Of course I can just call argpartition on the array and then discard everything after the second component, but I need it to be faster. Is there a way to get numpy to compute (and return) only the first two components? If I remember correctly finding the first two components should be O(n) + O(n) as opposed to O(n log n) of sorting the whole thing; and there is a space advantage in not having to return a big array just to discard most of it immediately after
Thank you for your help!