Beispiel #1
0
 internal static uint Unshuffle2(uint x)
 {
     // "unshuffle" (twice) even bits to low half and odd bits to high half
     x = Bits.BitPermuteStep(x, 0x0000FF00U, 8);
     x = Bits.BitPermuteStep(x, 0x00F000F0U, 4);
     x = Bits.BitPermuteStep(x, 0x0000CCCCU, 14);
     x = Bits.BitPermuteStep(x, 0x00AA00AAU, 7);
     return(x);
 }
Beispiel #2
0
 internal static uint Unshuffle(uint x)
 {
     // "unshuffle" even bits to low half and odd bits to high half
     x = Bits.BitPermuteStep(x, 0x22222222U, 1);
     x = Bits.BitPermuteStep(x, 0x0C0C0C0CU, 2);
     x = Bits.BitPermuteStep(x, 0x00F000F0U, 4);
     x = Bits.BitPermuteStep(x, 0x0000FF00U, 8);
     return(x);
 }
Beispiel #3
0
 internal static uint Shuffle2(uint x)
 {
     // "shuffle" (twice) low half to even bits and high half to odd bits
     x = Bits.BitPermuteStep(x, 0x00AA00AAU, 7);
     x = Bits.BitPermuteStep(x, 0x0000CCCCU, 14);
     x = Bits.BitPermuteStep(x, 0x00F000F0U, 4);
     x = Bits.BitPermuteStep(x, 0x0000FF00U, 8);
     return(x);
 }
Beispiel #4
0
 internal static uint Shuffle(uint x)
 {
     // "shuffle" low half to even bits and high half to odd bits
     x = Bits.BitPermuteStep(x, 0x0000FF00U, 8);
     x = Bits.BitPermuteStep(x, 0x00F000F0U, 4);
     x = Bits.BitPermuteStep(x, 0x0C0C0C0CU, 2);
     x = Bits.BitPermuteStep(x, 0x22222222U, 1);
     return(x);
 }
Beispiel #5
0
        internal static ulong Expand32to64(uint x)
        {
            // "shuffle" low half to even bits and high half to odd bits
            x = Bits.BitPermuteStep(x, 0x0000FF00U, 8);
            x = Bits.BitPermuteStep(x, 0x00F000F0U, 4);
            x = Bits.BitPermuteStep(x, 0x0C0C0C0CU, 2);
            x = Bits.BitPermuteStep(x, 0x22222222U, 1);

            return(((x >> 1) & M32) << 32 | (x & M32));
        }
Beispiel #6
0
 internal static ulong Unshuffle(ulong x)
 {
     // "unshuffle" even bits to low half and odd bits to high half
     x = Bits.BitPermuteStep(x, 0x2222222222222222UL, 1);
     x = Bits.BitPermuteStep(x, 0x0C0C0C0C0C0C0C0CUL, 2);
     x = Bits.BitPermuteStep(x, 0x00F000F000F000F0UL, 4);
     x = Bits.BitPermuteStep(x, 0x0000FF000000FF00UL, 8);
     x = Bits.BitPermuteStep(x, 0x00000000FFFF0000UL, 16);
     return(x);
 }
Beispiel #7
0
 internal static ulong Shuffle(ulong x)
 {
     // "shuffle" low half to even bits and high half to odd bits
     x = Bits.BitPermuteStep(x, 0x00000000FFFF0000UL, 16);
     x = Bits.BitPermuteStep(x, 0x0000FF000000FF00UL, 8);
     x = Bits.BitPermuteStep(x, 0x00F000F000F000F0UL, 4);
     x = Bits.BitPermuteStep(x, 0x0C0C0C0C0C0C0C0CUL, 2);
     x = Bits.BitPermuteStep(x, 0x2222222222222222UL, 1);
     return(x);
 }
Beispiel #8
0
        internal static void Expand64To128(ulong x, ulong[] z, int zOff)
        {
            // "shuffle" low half to even bits and high half to odd bits
            x = Bits.BitPermuteStep(x, 0x00000000FFFF0000UL, 16);
            x = Bits.BitPermuteStep(x, 0x0000FF000000FF00UL, 8);
            x = Bits.BitPermuteStep(x, 0x00F000F000F000F0UL, 4);
            x = Bits.BitPermuteStep(x, 0x0C0C0C0C0C0C0C0CUL, 2);
            x = Bits.BitPermuteStep(x, 0x2222222222222222UL, 1);

            z[zOff]     = (x) & M64;
            z[zOff + 1] = (x >> 1) & M64;
        }