Exemple #1
0
        public static void AddScaleCopy(float scale, ReadOnlySpan <float> source, ReadOnlySpan <float> destination, Span <float> result, int count)
        {
            Contracts.AssertNonEmpty(source);
            Contracts.AssertNonEmpty(destination);
            Contracts.AssertNonEmpty(result);
            Contracts.Assert(count > 0);
            Contracts.Assert(count <= source.Length);
            Contracts.Assert(count <= destination.Length);
            Contracts.Assert(count <= result.Length);

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

            if (Avx.IsSupported)
            {
                AvxIntrinsics.AddScaleCopyU(a, src, dst, res, count);
            }
            else if (Sse.IsSupported)
            {
                SseIntrinsics.AddScaleCopyU(a, src, dst, res, count);
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    res[i] = a * src[i] + dst[i];
                }
            }
        }
Exemple #3
0
 private static void AddScaleCopy(float a, Span <float> src, Span <float> dst, Span <float> res)
 {
     if (Sse.IsSupported)
     {
         SseIntrinsics.AddScaleCopyU(a, src, dst, res);
     }
     else
     {
         for (int i = 0; i < res.Length; i++)
         {
             res[i] = a * src[i] + dst[i];
         }
     }
 }