public static float DotProductDense(ReadOnlySpan <float> left, ReadOnlySpan <float> right, int count) { Contracts.AssertNonEmpty(left); Contracts.AssertNonEmpty(right); Contracts.Assert(count > 0); Contracts.Assert(left.Length >= count); Contracts.Assert(right.Length >= count); if (Avx.IsSupported) { return(AvxIntrinsics.DotU(left, right, count)); } else if (Sse.IsSupported) { return(SseIntrinsics.DotU(left, right, count)); } else { float result = 0; for (int i = 0; i < count; i++) { result += left[i] * right[i]; } return(result); } }
public static float DotProductDense(ReadOnlySpan <float> a, ReadOnlySpan <float> b, int count) { Contracts.AssertNonEmpty(a); Contracts.AssertNonEmpty(b); Contracts.Assert(count > 0); Contracts.Assert(a.Length >= count); Contracts.Assert(b.Length >= count); if (Avx.IsSupported) { return(AvxIntrinsics.DotU(a, b, count)); } else if (Sse.IsSupported) { return(SseIntrinsics.DotU(a, b, count)); } else { float result = 0; for (int i = 0; i < count; i++) { result += a[i] * b[i]; } return(result); } }
private static float DotProductDense(Span <float> a, Span <float> b) { if (Sse.IsSupported) { return(SseIntrinsics.DotU(a, b)); } else { float result = 0; for (int i = 0; i < b.Length; i++) { result += a[i] * b[i]; } return(result); } }