private static void Scale(float a, Span <float> src, Span <float> dst) { if (Avx.IsSupported) { AvxIntrinsics.ScaleSrcU(a, src, dst); } else if (Sse.IsSupported) { SseIntrinsics.ScaleSrcU(a, src, dst); } else { for (int i = 0; i < dst.Length; i++) { dst[i] = a * src[i]; } } }
// destination = value * source public static void Scale(float value, ReadOnlySpan <float> source, Span <float> destination, int count) { Contracts.AssertNonEmpty(source); Contracts.AssertNonEmpty(destination); Contracts.Assert(count > 0); Contracts.Assert(count <= source.Length); Contracts.Assert(count <= destination.Length); if (Avx.IsSupported) { AvxIntrinsics.ScaleSrcU(value, source, destination, count); } else if (Sse.IsSupported) { SseIntrinsics.ScaleSrcU(value, source, destination, count); } else { for (int i = 0; i < count; i++) { destination[i] = value * source[i]; } } }
// dst = a * src public static void Scale(float a, ReadOnlySpan <float> src, Span <float> dst, int count) { Contracts.AssertNonEmpty(src); Contracts.AssertNonEmpty(dst); Contracts.Assert(count > 0); Contracts.Assert(count <= src.Length); Contracts.Assert(count <= dst.Length); if (Avx.IsSupported) { AvxIntrinsics.ScaleSrcU(a, src, dst, count); } else if (Sse.IsSupported) { SseIntrinsics.ScaleSrcU(a, src, dst, count); } else { for (int i = 0; i < count; i++) { dst[i] = a * src[i]; } } }
public void ScaleSrcU() => AvxIntrinsics.ScaleSrcU(DefaultScale, src, dst, Length);
public void ManagedScaleSrcUPerf() { AvxIntrinsics.ScaleSrcU(DEFAULT_SCALE, new Span <float>(src, 0, LEN), new Span <float>(dst, 0, LEN)); }
public void ScaleSrcU() => AvxIntrinsics.ScaleSrcU(DEFAULT_SCALE, new Span <float>(src, 0, LEN), new Span <float>(dst, 0, LEN));
public void ScaleSrcU() => AvxIntrinsics.ScaleSrcU(DefaultScale, new Span <float>(src, 0, Length), new Span <float>(dst, 0, Length));