Skip to content

Instantly share code, notes, and snippets.

@aalmada
Created February 13, 2024 12:04
Show Gist options
  • Save aalmada/a9f939d76af5f16788a0440aba935ea8 to your computer and use it in GitHub Desktop.
Save aalmada/a9f939d76af5f16788a0440aba935ea8 to your computer and use it in GitHub Desktop.
Difference in behavior between Enumerable.Max() and TensorPrimitives.Max()
// @nuget: System.Numerics.Tensors
using System;
using System.Linq;
using System.Numerics.Tensors;
float[] array = [1.0f, float.NaN, 2.0f];
Console.WriteLine($"LINQ Min: {array.Min()}");
Console.WriteLine($"LINQ Max: {array.Max()}");
Console.WriteLine($"Tensors Min: {TensorPrimitives.Min(array)}");
Console.WriteLine($"Tensors Max: {TensorPrimitives.Max(array)}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment