Beispiel #1
0
        public Matrix Uniform(float a)
        {
            float a2 = 2 * a;
            float an = -a;

            ThreadSafeFastRandom.NextFloats(Data.AsSpan());
            SIMD.Multiply(Data.AsSpan(), a2);
            SIMD.Add(Data.AsSpan(), an);

            return(this);
        }
Beispiel #2
0
        public Matrix Uniform(float a)
        {
            float a2 = 2 * a;
            float an = -a;

            Parallel.For(0, Rows, (i) =>
            {
                ThreadSafeFastRandom.NextFloats(Data[i]);
                SIMD.Multiply(ref Data[i], a2);
                SIMD.Add(ref Data[i], an);
            });
            return(this);
        }
Beispiel #3
0
        public void ResizeAndFillRows(int newRows, float a)
        {
            float a2 = 2 * a;
            float an = -a;

            Array.Resize(ref Data, newRows * Columns);
            var toFill = Data.AsSpan().Slice(Rows * Columns);

            ThreadSafeFastRandom.NextFloats(toFill);
            SIMD.Multiply(toFill, a2);
            SIMD.Add(toFill, an);

            Rows = newRows;
        }