Beispiel #1
0
        static Vec256 <T> ClearAlternating()
        {
            var mask = Span256.Alloc <T>(1);
            var chop = PrimalInfo.Get <T>().MaxVal;

            //For the first 128-bit lane
            var half = mask.Length / 2;

            for (byte i = 0; i < half; i++)
            {
                if (i % 2 != 0)
                {
                    mask[i] = chop;
                }
                else
                {
                    mask[i] = convert <byte, T>(i);
                }
            }

            //For the second 128-bit lane
            for (byte i = 0; i < half; i++)
            {
                if (i % 2 != 0)
                {
                    mask[i + half] = chop;
                }
                else
                {
                    mask[i + half] = convert <byte, T>(i);
                }
            }

            return(Vec256.Load(mask));
        }
Beispiel #2
0
        protected virtual Interval <byte> ShiftRange <K>()
            where K : unmanaged
        {
            var offsetMin = (byte)1;
            var offsetMax = (byte)(PrimalInfo.Get <K>().BitSize - 2);

            return(closed(offsetMin, offsetMax));
        }
Beispiel #3
0
 /// <summary>
 /// Creates a graph from supplied vertices and edges, sorting the provided vertices according to their index
 /// </summary>
 /// <param name="vertices">The vertices in the graph</param>
 /// <param name="edges">The edges that connect the vertices</param>
 public static Graph <V> Define(IEnumerable <Vertex <V> > vertices, IEnumerable <Edge <V> > edges)
 => new Graph <V>(vertices.OrderBy(x => x.Index, PrimalInfo.comparer <V>()).ToArray(), edges.ToArray());