/// <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); }
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))); }
public static ulong ToScalar(this Perm16 src) => (ulong)src;
public static bool Includes(this Perm16 src, int index) => (((int)src & (4 << index)) != 0);