You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static void GetMinMax(double[] values, out double min, out double max)
{
min = double.NaN;
max = double.NaN;
int length = values.Length;
if (length > 0)
{
min = values[0];
max = min;
for (int i = 1; i < length; i++)
{
double value = values[i];
if (min > value)
{
min = value;
}
else if (max < value)
{
max = value;
}
}
}
}
The text was updated successfully, but these errors were encountered:
You can't get much faster than that without a SIMD implementation. A small thing you can do is don't use length in the for loop, use values.Length, this will ensure bounds check elimination. And you could use a tuple for the return value rather than two out values (won't change performance just may be nicer to use)
If a SIMD version would be useful let me know, I could add that maybe.
Something better than this ?
The text was updated successfully, but these errors were encountered: