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