Esempio n. 1
0
 private static float SumSq(float mean, Span <float> src)
 {
     if (Sse.IsSupported)
     {
         return((mean == 0) ? SseIntrinsics.SumSqU(src) : SseIntrinsics.SumSqDiffU(mean, src));
     }
     else
     {
         float result = 0;
         for (int i = 0; i < src.Length; i++)
         {
             result += (src[i] - mean) * (src[i] - mean);
         }
         return(result);
     }
 }
Esempio n. 2
0
 private static float SumSq(Span <float> src)
 {
     if (Sse.IsSupported)
     {
         return(SseIntrinsics.SumSqU(src));
     }
     else
     {
         float result = 0;
         for (int i = 0; i < src.Length; i++)
         {
             result += src[i] * src[i];
         }
         return(result);
     }
 }
Esempio n. 3
0
        public static float SumSq(float mean, ReadOnlySpan <float> source)
        {
            Contracts.AssertNonEmpty(source);

            if (Avx.IsSupported)
            {
                return((mean == 0) ? AvxIntrinsics.SumSqU(source) : AvxIntrinsics.SumSqDiffU(mean, source));
            }
            else if (Sse.IsSupported)
            {
                return((mean == 0) ? SseIntrinsics.SumSqU(source) : SseIntrinsics.SumSqDiffU(mean, source));
            }
            else
            {
                float result = 0;
                for (int i = 0; i < source.Length; i++)
                {
                    result += (source[i] - mean) * (source[i] - mean);
                }
                return(result);
            }
        }
Esempio n. 4
0
        public static float SumSq(ReadOnlySpan <float> source)
        {
            Contracts.AssertNonEmpty(source);

            if (Avx.IsSupported)
            {
                return(AvxIntrinsics.SumSqU(source));
            }
            else if (Sse.IsSupported)
            {
                return(SseIntrinsics.SumSqU(source));
            }
            else
            {
                float result = 0;
                for (int i = 0; i < source.Length; i++)
                {
                    result += source[i] * source[i];
                }
                return(result);
            }
        }