Beispiel #1
0
 private static float SumAbs(Span <float> src)
 {
     if (Sse.IsSupported)
     {
         return(SseIntrinsics.SumAbsU(src));
     }
     else
     {
         float sum = 0;
         for (int i = 0; i < src.Length; i++)
         {
             sum += Math.Abs(src[i]);
         }
         return(sum);
     }
 }
Beispiel #2
0
 private static float SumAbs(float mean, Span <float> src)
 {
     if (Sse.IsSupported)
     {
         return((mean == 0) ? SseIntrinsics.SumAbsU(src) : SseIntrinsics.SumAbsDiffU(mean, src));
     }
     else
     {
         float sum = 0;
         for (int i = 0; i < src.Length; i++)
         {
             sum += Math.Abs(src[i] - mean);
         }
         return(sum);
     }
 }
Beispiel #3
0
        public static float SumAbs(float mean, ReadOnlySpan <float> source)
        {
            Contracts.AssertNonEmpty(source);

            if (Avx.IsSupported)
            {
                return((mean == 0) ? AvxIntrinsics.SumAbsU(source) : AvxIntrinsics.SumAbsDiffU(mean, source));
            }
            else if (Sse.IsSupported)
            {
                return((mean == 0) ? SseIntrinsics.SumAbsU(source) : SseIntrinsics.SumAbsDiffU(mean, source));
            }
            else
            {
                float sum = 0;
                for (int i = 0; i < source.Length; i++)
                {
                    sum += Math.Abs(source[i] - mean);
                }
                return(sum);
            }
        }
        public static float SumAbs(ReadOnlySpan <float> src)
        {
            Contracts.AssertNonEmpty(src);

            if (Avx.IsSupported)
            {
                return(AvxIntrinsics.SumAbsU(src));
            }
            else if (Sse.IsSupported)
            {
                return(SseIntrinsics.SumAbsU(src));
            }
            else
            {
                float sum = 0;
                for (int i = 0; i < src.Length; i++)
                {
                    sum += Math.Abs(src[i]);
                }
                return(sum);
            }
        }