PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ uint32_hilbert()

static uint64_t uint32_hilbert ( uint32_t  px,
uint32_t  py 
)
inlinestatic

Definition at line 256 of file lwinline.h.

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

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: