I have run into a problem that I can probably circumvent by arranging my algorithm differently, but it's quite interesting and maybe one of you has a good idea.
The situation is as follows: I have two lists of unsigned long integers, both lists have the same size, and if this is helpful you can assume that this size is a power of two. The size of these lists is usually in the range of several hundred. Now I want to compute an integer that has a set bit in every position in which the first list has more set bits than the second list.
Speed is everything.
Simplified example:
list1 list2
1010 0101
1111 0000
1100 0011
1010 0101
result: 1010
because of 4>0, 2<=2, 3>1, 1<=3
Edit: The alternative arrangement of data would result in bit vectors that contain what is now the bits of a certain position in several different vectors. In that case I could just use a bit counting algorithm and then compare, which would amount to less than 30 operations per 64 bits in both lists. Basically I have a matrix of bits and I can use the bit vectors for the columns or the rows.
Additional structure: John Willemse's comment made me realise that I could calculate a third list, so that these three lists complement each other bitwise. Though I don't see how that would be helpful.