|
@ -13,6 +13,21 @@ namespace gp { |
|
|
Sean Eron Anderson |
|
|
Sean Eron Anderson |
|
|
seander@cs.stanford.edu |
|
|
seander@cs.stanford.edu |
|
|
**/ |
|
|
**/ |
|
|
|
|
|
template<> |
|
|
|
|
|
constexpr size_t log2<uint8_t>(uint8_t v) |
|
|
|
|
|
{ |
|
|
|
|
|
constexpr int MultiplyDeBruijnBitPosition[8] = |
|
|
|
|
|
{ |
|
|
|
|
|
0, 5, 1, 6, 4, 3, 2, 7 |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
v |= v >> 1; |
|
|
|
|
|
v |= v >> 2; |
|
|
|
|
|
v |= v >> 4; |
|
|
|
|
|
|
|
|
|
|
|
return MultiplyDeBruijnBitPosition[(v * 29U) >> 5]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
template<> |
|
|
template<> |
|
|
constexpr size_t log2<uint32_t>(uint32_t v) |
|
|
constexpr size_t log2<uint32_t>(uint32_t v) |
|
|
{ |
|
|
{ |
|
|