public static void AddScale(float scale, ReadOnlySpan <float> source, ReadOnlySpan <int> indices, Span <float> destination, int count) { Contracts.AssertNonEmpty(source); Contracts.AssertNonEmpty(indices); Contracts.AssertNonEmpty(destination); Contracts.Assert(count > 0); Contracts.Assert(count <= source.Length); Contracts.Assert(count <= indices.Length); Contracts.Assert(count < destination.Length); if (Avx.IsSupported) { AvxIntrinsics.AddScaleSU(scale, source, indices, destination, count); } else if (Sse.IsSupported) { SseIntrinsics.AddScaleSU(scale, source, indices, destination, count); } else { for (int i = 0; i < count; i++) { int index = indices[i]; destination[index] += scale * source[i]; } } }
public static void AddScale(float a, ReadOnlySpan <float> src, ReadOnlySpan <int> indices, Span <float> dst, int count) { Contracts.AssertNonEmpty(src); Contracts.AssertNonEmpty(indices); Contracts.AssertNonEmpty(dst); Contracts.Assert(count > 0); Contracts.Assert(count <= src.Length); Contracts.Assert(count <= indices.Length); Contracts.Assert(count < dst.Length); if (Avx.IsSupported) { AvxIntrinsics.AddScaleSU(a, src, indices, dst, count); } else if (Sse.IsSupported) { SseIntrinsics.AddScaleSU(a, src, indices, dst, count); } else { for (int i = 0; i < count; i++) { int index = indices[i]; dst[index] += a * src[i]; } } }
private static void AddScale(float a, Span <float> src, Span <int> indices, Span <float> dst) { if (Sse.IsSupported) { SseIntrinsics.AddScaleSU(a, src, indices, dst); } else { for (int i = 0; i < indices.Length; i++) { int index = indices[i]; dst[index] += a * src[i]; } } }