示例#1
0
 private static void Scale(float a, Span <float> src, Span <float> dst)
 {
     if (Sse.IsSupported)
     {
         SseIntrinsics.ScaleSrcU(a, src, dst);
     }
     else
     {
         for (int i = 0; i < dst.Length; i++)
         {
             dst[i] = a * src[i];
         }
     }
 }
示例#2
0
        // destination = value * source
        public static void Scale(float value, 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.ScaleSrcU(value, source, destination, count);
            }
            else if (Sse.IsSupported)
            {
                SseIntrinsics.ScaleSrcU(value, source, destination, count);
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    destination[i] = value * source[i];
                }
            }
        }
        // dst = a * src
        public static void Scale(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.ScaleSrcU(a, src, dst, count);
            }
            else if (Sse.IsSupported)
            {
                SseIntrinsics.ScaleSrcU(a, src, dst, count);
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    dst[i] = a * src[i];
                }
            }
        }