1 #ifndef INLINEDFUNCT_HPP_
2 #define INLINEDFUNCT_HPP_
8 inline uint64_t splitBy3(
unsigned int a){
9 uint64_t x = a & 0x1fffff;
10 x = (x | x << 32) & 0x1f00000000ffff;
11 x = (x | x << 16) & 0x1f0000ff0000ff;
12 x = (x | x << 8) & 0x100f00f00f00f00f;
13 x = (x | x << 4) & 0x10c30c30c30c30c3;
14 x = (x | x << 2) & 0x1249249249249249;
18 inline uint64_t mortonEncode_magicbits(
unsigned int x,
unsigned int y,
unsigned int z){
20 answer |= splitBy3(x) | splitBy3(y) << 1 | splitBy3(z) << 2;
24 inline uint64_t splitBy2(
unsigned int a){
26 x = (x | x << 16) & 0xFFFF0000FFFF;
27 x = (x | x << 8) & 0xFF00FF00FF00FF;
28 x = (x | x << 4) & 0xF0F0F0F0F0F0F0F;
29 x = (x | x << 2) & 0x3333333333333333;
30 x = (x | x << 1) & 0x5555555555555555;
34 inline uint64_t mortonEncode_magicbits(
unsigned int x,
unsigned int y){
36 answer |= splitBy2(x) | splitBy2(y) << 1;
42 inline uint64_t keyXY(uint64_t x, uint64_t y){
44 answer |= x | (y << MAX_LEVEL_2D);
48 inline uint64_t keyXYZ(uint64_t x, uint64_t y, uint64_t z){
50 answer |= x | (y << MAX_LEVEL_3D) | (z << 2*MAX_LEVEL_3D);