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); } }
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); } }