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