KEMBAR78
TensorPrimitives.IndexOfXx methods sometimes return the wrong index in the face of equality · Issue #97190 · dotnet/runtime · GitHub
Skip to content

TensorPrimitives.IndexOfXx methods sometimes return the wrong index in the face of equality #97190

@stephentoub

Description

@stephentoub

Description

When there are multiple equal elements that could have their index returned, the one with the smallest index is supposed to be returned. But it isn't always.

Reproduction Steps

using System.Numerics.Tensors;

ReadOnlySpan<float> floats = [10f, -20f, -30f, 1f, 1f, -40f];
Console.WriteLine(TensorPrimitives.IndexOfMinMagnitude(floats));

or

using System.Numerics.Tensors;

ReadOnlySpan<float> floats = [10f, 20f, 30f, 1f, 1f, 40f];
Console.WriteLine(TensorPrimitives.IndexOfMin(floats));

Expected behavior

Those should both print 3.

Actual behavior

They print 4.

Regression?

No

Known Workarounds

No response

Configuration

System.Numerics.Tensors v8.0.0 nuget package

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions