MCPcopy Create free account
hub / github.com/catboost/catboost / ByteSums

Function ByteSums

util/generic/bitmap.h:17–24  ·  view source on GitHub ↗

Returns the number of bits set; result is in the most significant byte

Source from the content-addressed store, hash-verified

15namespace NBitMapPrivate {
16 // Returns the number of bits set; result is in the most significant byte
17 inline ui64 ByteSums(ui64 x) {
18 ui64 byteSums = x - ((x & 0xAAAAAAAAAAAAAAAAULL) >> 1);
19
20 byteSums = (byteSums & 0x3333333333333333ULL) + ((byteSums >> 2) & 0x3333333333333333ULL);
21 byteSums = (byteSums + (byteSums >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
22
23 return byteSums * 0x0101010101010101ULL;
24 }
25
26 // better than intrinsics without -mpopcnt
27 template <typename T>

Callers 1

CountBitsPrivateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected