update the way to get bitposition

This commit is contained in:
万康 2021-05-04 23:46:00 +08:00
parent 4bb63e1464
commit fa96613aeb

View File

@ -1550,12 +1550,15 @@ public:
for (size_t row = 0; row < size; ++row)
{
UnsignedT x = vec_from[row];
int position = 0;
while (x)
{
UnsignedT y = x & (x - 1);
UnsignedT bit = x ^ y;
x = y;
res_values.push_back(std::log2(bit));
if(x & 1)
{
res_values.push_back(position);
}
x >>= 1 ;
position++;
}
res_offsets[row] = res_values.size();
}