Skip to content

TensorPrimitives.IndexOfMaxMagnitude signed integer magnitude tie bug #128478

Description

@lilinus

Description

There's a bug in vectorized path.

.NET 10 is affected and it lives on in master after #127454 since unit test coverage was missing.

Reproduction Steps

using System.Numerics.Tensors;
var arr = new int[] { -1, -1, 1, -1 };
Console.WriteLine($"MaxMagnitude -> {TensorPrimitives.MaxMagnitude(arr)}"); // Returns 1 
Console.WriteLine($"IndexOfMaxMagnitude -> {arr[TensorPrimitives.IndexOfMaxMagnitude(arr)]}"); // Returns 0

Expected behavior

Should give equal values:

MaxMagnitude -> 1
IndexOfMaxMagnitude -> 1

Actual behavior

MaxMagnitude -> 1
IndexOfMaxMagnitude -> -1

Regression?

No.

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions