Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use <a href="http://en.wikipedia.org/wiki/Radix_sort" rel="nofollow">radix sort</a>. Split each 1-dimensional index to <code>d .. 32</code> parts, each of size <code>1 .. 32/d</code> bits. Then (from high-order bits to low-order bits) for each index piece compute its Hilbert value and shuffle objects to proper bins.</p> <p>This should work well with both evenly and unevenly distributed data, both Hilbert ordering or Z-order. And no multi-precision calculations needed.</p> <p>One detail about converting index pieces to Hilbert order:</p> <ul> <li>first extract necessary bits,</li> <li>then interleave bits from all dimensions,</li> <li>then convert 1-dimensional indexes to inverse Gray code.</li> </ul> <p>If the indexes are stored in doubles:</p> <ul> <li>If indexes may be negative, add some value to make everything positive and thus simplify the task.</li> <li>Determine the smallest integer power of 2, which is greater than all the indexes and divide all indexes to this value</li> <li>Multiply the index to 2^(necessary number of bits for current sorting step). Truncate the result, convert it to integer, and use it for Hilbert ordering (interleave and compute the inverse Gray code)</li> <li>Subtract the result, truncated on previous step, from the index: <code>index = index - i</code></li> </ul> <p>Coming to your variant of radix sort, i'd suggest to extend zsort (to make hilbertsort out of zsort) with two binary arrays of size <code>d</code> (one used mostly as a stack, other is used to invert index bits) and the rotation value (used to rearrange dimensions).</p> <p>If top value in the stack is 1, change pivotize(... ascending) to pivotize(... descending), and then for the first part of the recursion, push this top value to the stack, for second one - push the inverse of this value. This stack should be restored after each recursion. It contains the "decision tree" of last <code>d</code> recursions of radix sort procedure (in inverse Gray code).</p> <p>After <code>d</code> recursions this "decision tree" stack should be used to recalculate both the rotation value and the array of inversions. The exact way how to do it is non-trivial. It may be found in the following links: <a href="http://web.archive.org/web/20041102084739/http://www.caam.rice.edu/~dougm/twiddle/Hilbert/hilbert.c" rel="nofollow">hilbert.c</a> or <a href="http://computation.pa.msu.edu/NO/F90/SFC/hilbert.c" rel="nofollow">hilbert.c</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload