Esempio n. 1
0
 private static void AddScale(float a, Span <float> src, Span <float> dst)
 {
     if (Sse.IsSupported)
     {
         SseIntrinsics.AddScaleU(a, src, dst);
     }
     else
     {
         for (int i = 0; i < dst.Length; i++)
         {
             dst[i] += a * src[i];
         }
     }
 }
Esempio n. 2
0
        public static void AddScale(float scale, ReadOnlySpan <float> source, Span <float> destination, int count)
        {
            Contracts.AssertNonEmpty(source);
            Contracts.AssertNonEmpty(destination);
            Contracts.Assert(count > 0);
            Contracts.Assert(count <= source.Length);
            Contracts.Assert(count <= destination.Length);

            if (Avx.IsSupported)
            {
                AvxIntrinsics.AddScaleU(scale, source, destination, count);
            }
            else if (Sse.IsSupported)
            {
                SseIntrinsics.AddScaleU(scale, source, destination, count);
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    destination[i] += scale * source[i];
                }
            }
        }
        public static void AddScale(float a, ReadOnlySpan <float> src, Span <float> dst, int count)
        {
            Contracts.AssertNonEmpty(src);
            Contracts.AssertNonEmpty(dst);
            Contracts.Assert(count > 0);
            Contracts.Assert(count <= src.Length);
            Contracts.Assert(count <= dst.Length);

            if (Avx.IsSupported)
            {
                AvxIntrinsics.AddScaleU(a, src, dst, count);
            }
            else if (Sse.IsSupported)
            {
                SseIntrinsics.AddScaleU(a, src, dst, count);
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    dst[i] += a * src[i];
                }
            }
        }