mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
55a7d80527
* incorporated feedback from previous pr, iterated with 100+ scalar loop tests to come to this skill, moved from skill to reference in the performance skill * Update tests/dotnet-diag/analyzing-dotnet-performance/eval.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update tests/dotnet-diag/analyzing-dotnet-performance/eval.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update plugins/dotnet-diag/skills/analyzing-dotnet-performance/references/simd-vectorization.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update plugins/dotnet-diag/skills/analyzing-dotnet-performance/references/simd-vectorization.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update plugins/dotnet-diag/skills/analyzing-dotnet-performance/references/simd-vectorization.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update plugins/dotnet-diag/skills/analyzing-dotnet-performance/references/simd-vectorization.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Address review feedback on SIMD vectorization reference - Check Span<T>/MemoryExtensions before TensorPrimitives (no extra dependency) - Add all supported types (sbyte, ushort, uint, ulong, nint, nuint, char via ushort) - TensorPrimitives: add constraint and applicable types columns (not just float/double) - Add FusedMultiplyAdd, clarify AddMultiply vs MultiplyAdd distinction - Prefer portable APIs over platform-specific intrinsics (allow when perf justifies) - Fix dispatch pattern to use if/else if to avoid pessimizing small inputs - Remove LINQ references Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * addressing more feedback * move to the experimental plugin * move the simd tests to exprimental * add codeowners --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
23 lines
623 B
C#
23 lines
623 B
C#
namespace MinMax;
|
|
|
|
public static class RangeCalculator
|
|
{
|
|
/// <summary>
|
|
/// Returns the minimum and maximum values in <paramref name="values"/>.
|
|
/// </summary>
|
|
public static (float Min, float Max) FindMinMax(ReadOnlySpan<float> values)
|
|
{
|
|
if (values.Length == 0)
|
|
throw new ArgumentException("Span must not be empty.");
|
|
|
|
float min = values[0];
|
|
float max = values[0];
|
|
for (int i = 1; i < values.Length; i++)
|
|
{
|
|
if (values[i] < min) min = values[i];
|
|
if (values[i] > max) max = values[i];
|
|
}
|
|
return (min, max);
|
|
}
|
|
}
|