Patent ID: 8264391

Claim:
A method for selecting a set of elements in a vector, the method comprising: receiving a control value at a vector processor that indicates a number N elements that are to be selected from an input vector having M elements; sorting the elements of the input vector into a bitonic sequence in a first clock cycle of the vector processor; separating the elements of the bitonic sequence into a larger value group and a smaller value group in the same first clock cycle with a bitonic split, wherein the elements in the larger value group are larger than any of the elements in the smaller value group; sorting only the larger value group into an ordered sequence in the same first clock cycle with repeated bitonic splits when the control value is less than M/2 and selecting N largest elements from the ordered sequence; and sorting only the smaller value group into an ordered sequence in the same first clock cycle with repeated bitonic splits when the control value is greater than M/2 and selecting N−M/2 largest elements from the ordered sequence and all of the elements in the larger value group.