Beispiel #1
0
        /// <summary>
        /// Reifies a permutation of length 16 from its canonical scalar representative
        /// </summary>
        /// <param name="rep">The representative</param>
        public static Perm <N16> ToPerm(this Perm16 rep)
        {
            uint data = (uint)rep;
            var  dst  = Perm <N16> .Alloc();

            for (int i = 0, offset = 0; i < dst.Length; i++, offset += 4)
            {
                dst[i] = (int)BitMask.between(in data, offset, offset + 3);
            }
            return(dst);
        }
Beispiel #2
0
        public static PermCycle Cycle(this Perm16 src)
        {
            Span <PermTerm> terms   = stackalloc PermTerm[16];
            var             counter = 0;

            for (var i = 0; i < 16; i++)
            {
                if (src.Includes(i))
                {
                    terms[counter] = new PermTerm(counter, i);
                }
                counter++;
            }
            return(new PermCycle(terms.Slice(0, counter)));
        }
Beispiel #3
0
 public static ulong ToScalar(this Perm16 src)
 => (ulong)src;
Beispiel #4
0
 public static bool Includes(this Perm16 src, int index)
 => (((int)src & (4 << index)) != 0);