コード例 #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));
        }
コード例 #2
0
        static Vec256 <T> CalcUnits()
        {
            var n   = Length;
            var dst = Span256.Alloc <T>(n);
            var one = gmath.one <T>();

            for (var i = 0; i < n; i++)
            {
                dst[i] = one;
            }
            return(Vec256.Load(dst));
        }
コード例 #3
0
        /// <summary>
        /// Creates a vector with incrementing components
        /// v[0] = first and v[i+1] = v[i] + 1 for i=1...N-1
        /// </summary>
        /// <param name="first">The value of the first component</param>
        /// <typeparam name="T">The primal component type</typeparam>
        public static Vec256 <T> Increments(T first = default, params Swap[] swaps)
        {
            var n   = Length;
            var dst = Span256.Alloc <T>(n);
            var val = first;

            for (var i = 0; i < n; i++)
            {
                dst[i] = val;
                gmath.inc(ref val);
            }
            return(Vec256.Load(dst.Swap(swaps)));
        }
コード例 #4
0
 public static BlockVector <T> Alloc <T>(int n, T?fill = null)
     where T : struct
 => Span256.Alloc <T>(n, fill);
コード例 #5
0
 public static BlockVector <N, T> Alloc <N, T>(N n, T fill)
     where N : ITypeNat, new()
     where T : struct
 => BlockVector <N, T> .LoadAligned(Span256.Alloc <N, T>(fill));
コード例 #6
0
 public static BlockMatrix <M, N, T> Alloc <M, N, T>(M m = default, N n = default, T exemplar = default)
     where M : ITypeNat, new()
     where N : ITypeNat, new()
     where T : struct
 => Span256.Alloc <M, N, T>();