Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is an efficient way to perform bit reversal, using O(log n) shift operations. If you interpret a 64-bit UINT as an 8x8 array of bits, then bit reversal corresponds to a rotation by 180 degrees.</p> <p>Half of these shifts effectively perform a horizontal reflection; the other half perform a vertical reflection. To obtain rotations by 90 and 270 degrees, an orthogonal (i.e. vertical or horizontal) reflection could be combined with a diagonal reflection, but the latter remains an awkward bit.</p> <pre><code>typedef unsigned long long uint64; uint64 reflect_vert (uint64 value) { value = ((value &amp; 0xFFFFFFFF00000000ull) &gt;&gt; 32) | ((value &amp; 0x00000000FFFFFFFFull) &lt;&lt; 32); value = ((value &amp; 0xFFFF0000FFFF0000ull) &gt;&gt; 16) | ((value &amp; 0x0000FFFF0000FFFFull) &lt;&lt; 16); value = ((value &amp; 0xFF00FF00FF00FF00ull) &gt;&gt; 8) | ((value &amp; 0x00FF00FF00FF00FFull) &lt;&lt; 8); return value; } uint64 reflect_horiz (uint64 value) { value = ((value &amp; 0xF0F0F0F0F0F0F0F0ull) &gt;&gt; 4) | ((value &amp; 0x0F0F0F0F0F0F0F0Full) &lt;&lt; 4); value = ((value &amp; 0xCCCCCCCCCCCCCCCCull) &gt;&gt; 2) | ((value &amp; 0x3333333333333333ull) &lt;&lt; 2); value = ((value &amp; 0xAAAAAAAAAAAAAAAAull) &gt;&gt; 1) | ((value &amp; 0x5555555555555555ull) &lt;&lt; 1); return value; } uint64 reflect_diag (uint64 value) { uint64 new_value = value &amp; 0x8040201008040201ull; // stationary bits new_value |= (value &amp; 0x0100000000000000ull) &gt;&gt; 49; new_value |= (value &amp; 0x0201000000000000ull) &gt;&gt; 42; new_value |= (value &amp; 0x0402010000000000ull) &gt;&gt; 35; new_value |= (value &amp; 0x0804020100000000ull) &gt;&gt; 28; new_value |= (value &amp; 0x1008040201000000ull) &gt;&gt; 21; new_value |= (value &amp; 0x2010080402010000ull) &gt;&gt; 14; new_value |= (value &amp; 0x4020100804020100ull) &gt;&gt; 7; new_value |= (value &amp; 0x0080402010080402ull) &lt;&lt; 7; new_value |= (value &amp; 0x0000804020100804ull) &lt;&lt; 14; new_value |= (value &amp; 0x0000008040201008ull) &lt;&lt; 21; new_value |= (value &amp; 0x0000000080402010ull) &lt;&lt; 28; new_value |= (value &amp; 0x0000000000804020ull) &lt;&lt; 35; new_value |= (value &amp; 0x0000000000008040ull) &lt;&lt; 42; new_value |= (value &amp; 0x0000000000000080ull) &lt;&lt; 49; return new_value; } uint64 rotate_90 (uint64 value) { return reflect_diag (reflect_vert (value)); } uint64 rotate_180 (uint64 value) { return reflect_horiz (reflect_vert (value)); } uint64 rotate_270 (uint64 value) { return reflect_diag (reflect_horiz (value)); } </code></pre> <p>In the above code, the reflect_diag() function still requires many shifts. I suspect that it is possible to implement this function with fewer shifts, but I have not yet found a way to do that.</p>
    singulars
    1. This table or related slice is empty.
    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