diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Cbrt.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Cbrt.cs index 1bc8b85696c121..3336411a098966 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Cbrt.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Cbrt.cs @@ -26,7 +26,7 @@ public static void Cbrt(ReadOnlySpan x, Span destination) private readonly struct CbrtOperator : IUnaryOperator where T : IRootFunctions { - public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double); + public static bool Vectorizable => false; // typeof(T) == typeof(float) || typeof(T) == typeof(double); // TODO: https://github.com/dotnet/runtime/issues/100535 public static T Invoke(T x) => T.Cbrt(x); diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Log.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Log.cs index 74d17f036d9404..d3d2f3e9a705d3 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Log.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Log.cs @@ -161,7 +161,7 @@ public static Vector512 Invoke(Vector512 x) private readonly struct LogBaseOperator : IBinaryOperator where T : ILogarithmicFunctions { - public static bool Vectorizable => LogOperator.Vectorizable; + public static bool Vectorizable => false; //LogOperator.Vectorizable; // TODO: https://github.com/dotnet/runtime/issues/100535 public static T Invoke(T x, T y) => T.Log(x, y); public static Vector128 Invoke(Vector128 x, Vector128 y) => LogOperator.Invoke(x) / LogOperator.Invoke(y); public static Vector256 Invoke(Vector256 x, Vector256 y) => LogOperator.Invoke(x) / LogOperator.Invoke(y); diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Pow.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Pow.cs index 72d35ed5be779f..263235e4a5c2e3 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Pow.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Pow.cs @@ -59,7 +59,7 @@ public static void Pow(T x, ReadOnlySpan y, Span destination) private readonly struct PowOperator : IBinaryOperator where T : IPowerFunctions { - public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double); + public static bool Vectorizable => false; // typeof(T) == typeof(float) || typeof(T) == typeof(double); // TODO: https://github.com/dotnet/runtime/issues/100535 public static T Invoke(T x, T y) => T.Pow(x, y); diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.RootN.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.RootN.cs index e7c394892950a9..5a732f76936000 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.RootN.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.RootN.cs @@ -28,7 +28,7 @@ private readonly struct RootNOperator(int n) : IStatefulUnaryOperator wher { private readonly int _n = n; - public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double); + public static bool Vectorizable => false; // typeof(T) == typeof(float) || typeof(T) == typeof(double); // TODO: https://github.com/dotnet/runtime/issues/100535 public T Invoke(T x) => T.RootN(x, _n); diff --git a/src/libraries/System.Numerics.Tensors/tests/Helpers.cs b/src/libraries/System.Numerics.Tensors/tests/Helpers.cs index 83c9d2f41c902d..802cd4ac2ab1b9 100644 --- a/src/libraries/System.Numerics.Tensors/tests/Helpers.cs +++ b/src/libraries/System.Numerics.Tensors/tests/Helpers.cs @@ -30,6 +30,11 @@ private static class DefaultTolerance where T : unmanaged, INumber public static bool IsEqualWithTolerance(T expected, T actual, T? tolerance = null) where T : unmanaged, INumber { + if (T.IsNaN(expected) != T.IsNaN(actual)) + { + return false; + } + tolerance = tolerance ?? DefaultTolerance.Value; T diff = T.Abs(expected - actual); return !(diff > tolerance && diff > T.Max(T.Abs(expected), T.Abs(actual)) * tolerance); @@ -37,6 +42,11 @@ public static bool IsEqualWithTolerance(T expected, T actual, T? tolerance = #else public static bool IsEqualWithTolerance(float expected, float actual, float? tolerance = null) { + if (float.IsNaN(expected) != float.IsNaN(actual)) + { + return false; + } + tolerance ??= DefaultFloatTolerance; float diff = MathF.Abs(expected - actual); return !(diff > tolerance && diff > MathF.Max(MathF.Abs(expected), MathF.Abs(actual)) * tolerance);