示例#1
0
        public static float MaxAbsDiff(float mean, ReadOnlySpan <float> source)
        {
            Contracts.AssertNonEmpty(source);

            if (Avx.IsSupported)
            {
                return(AvxIntrinsics.MaxAbsDiffU(mean, source));
            }
            else if (Sse.IsSupported)
            {
                return(SseIntrinsics.MaxAbsDiffU(mean, source));
            }
            else
            {
                float max = 0;
                for (int i = 0; i < source.Length; i++)
                {
                    float abs = Math.Abs(source[i] - mean);
                    if (abs > max)
                    {
                        max = abs;
                    }
                }
                return(max);
            }
        }
示例#2
0
 private static float MaxAbsDiff(float mean, Span <float> src)
 {
     if (Sse.IsSupported)
     {
         return(SseIntrinsics.MaxAbsDiffU(mean, src));
     }
     else
     {
         float max = 0;
         for (int i = 0; i < src.Length; i++)
         {
             float abs = Math.Abs(src[i] - mean);
             if (abs > max)
             {
                 max = abs;
             }
         }
         return(max);
     }
 }