PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ uint32_hilbert()

static uint64_t uint32_hilbert ( uint32_t  px,
uint32_t  py 
)
inlinestatic

Definition at line 260 of file lwinline.h.

261 {
262  uint64_t x = px;
263  uint64_t y = py;
264 
265  uint64_t A, B, C, D;
266  uint64_t a, b, c, d;
267  uint64_t i0, i1;
268 
269  // Initial prefix scan round, prime with x and y
270  {
271  a = x ^ y;
272  b = 0xFFFFFFFFULL ^ a;
273  c = 0xFFFFFFFFULL ^ (x | y);
274  d = x & (y ^ 0xFFFFFFFFULL);
275 
276  A = a | (b >> 1);
277  B = (a >> 1) ^ a;
278  C = ((c >> 1) ^ (b & (d >> 1))) ^ c;
279  D = ((a & (c >> 1)) ^ (d >> 1)) ^ d;
280  }
281 
282  {
283  a = A;
284  b = B;
285  c = C;
286  d = D;
287 
288  A = ((a & (a >> 2)) ^ (b & (b >> 2)));
289  B = ((a & (b >> 2)) ^ (b & ((a ^ b) >> 2)));
290  C ^= ((a & (c >> 2)) ^ (b & (d >> 2)));
291  D ^= ((b & (c >> 2)) ^ ((a ^ b) & (d >> 2)));
292  }
293 
294  {
295  a = A;
296  b = B;
297  c = C;
298  d = D;
299 
300  A = ((a & (a >> 4)) ^ (b & (b >> 4)));
301  B = ((a & (b >> 4)) ^ (b & ((a ^ b) >> 4)));
302  C ^= ((a & (c >> 4)) ^ (b & (d >> 4)));
303  D ^= ((b & (c >> 4)) ^ ((a ^ b) & (d >> 4)));
304  }
305 
306  {
307  a = A;
308  b = B;
309  c = C;
310  d = D;
311 
312  A = ((a & (a >> 8)) ^ (b & (b >> 8)));
313  B = ((a & (b >> 8)) ^ (b & ((a ^ b) >> 8)));
314  C ^= ((a & (c >> 8)) ^ (b & (d >> 8)));
315  D ^= ((b & (c >> 8)) ^ ((a ^ b) & (d >> 8)));
316  }
317 
318  {
319  a = A;
320  b = B;
321  c = C;
322  d = D;
323 
324  C ^= ((a & (c >> 16)) ^ (b & (d >> 16)));
325  D ^= ((b & (c >> 16)) ^ ((a ^ b) & (d >> 16)));
326  }
327 
328  // Undo transformation prefix scan
329  a = C ^ (C >> 1);
330  b = D ^ (D >> 1);
331 
332  // Recover index bits
333  i0 = x ^ y;
334  i1 = b | (0xFFFFFFFFULL ^ (i0 | a));
335 
336  return uint64_interleave_2(i0, i1);
337 }
static uint64_t uint64_interleave_2(uint64_t x, uint64_t y)
Definition: lwinline.h:241

References uint64_interleave_2(), pixval::x, and pixval::y.

Referenced by box2df_get_sortable_hash(), and gbox_get_sortable_hash().

Here is the call graph for this function:
Here is the caller graph for this function: