private static float Sum(Span <float> src) { if (Sse.IsSupported) { return(SseIntrinsics.SumU(src)); } else { float sum = 0; for (int i = 0; i < src.Length; i++) { sum += src[i]; } return(sum); } }
public static float Sum(ReadOnlySpan <float> src) { Contracts.AssertNonEmpty(src); if (Avx.IsSupported) { return(AvxIntrinsics.SumU(src)); } else if (Sse.IsSupported) { return(SseIntrinsics.SumU(src)); } else { float sum = 0; for (int i = 0; i < src.Length; i++) { sum += src[i]; } return(sum); } }