TensorPrimitives.IndexOfMaxMagnitude Method

Definition

Overloads

IndexOfMaxMagnitude(ReadOnlySpan<Single>)

Searches for the index of the single-precision floating-point number with the largest magnitude in the specified tensor.

IndexOfMaxMagnitude<T>(ReadOnlySpan<T>)

Searches for the index of the number with the largest magnitude in the specified tensor.

IndexOfMaxMagnitude(ReadOnlySpan<Single>)

Source:
TensorPrimitives.cs
Source:
TensorPrimitives.Single.cs
Source:
TensorPrimitives.Single.cs

Searches for the index of the single-precision floating-point number with the largest magnitude in the specified tensor.

C#
public static int IndexOfMaxMagnitude (ReadOnlySpan<float> x);

Parameters

x
ReadOnlySpan<Single>

The tensor, represented as a span.

Returns

The index of the element in x with the largest magnitude (absolute value), or -1 if x is empty.

Remarks

The determination of the maximum magnitude matches the IEEE 754:2019 `maximumMagnitude` function. If any value equal to NaN is present, the index of the first is returned. If two values have the same magnitude and one is positive and the other is negative, the positive value is considered to have the larger magnitude.

This method may call into the underlying C runtime or employ instructions specific to the current architecture. Exact results may differ between different operating systems or architectures.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

IndexOfMaxMagnitude<T>(ReadOnlySpan<T>)

Source:
TensorPrimitives.IndexOfMaxMagnitude.cs
Source:
TensorPrimitives.IndexOfMaxMagnitude.cs

Searches for the index of the number with the largest magnitude in the specified tensor.

C#
public static int IndexOfMaxMagnitude<T> (ReadOnlySpan<T> x) where T : System.Numerics.INumber<T>;

Type Parameters

T

Parameters

x
ReadOnlySpan<T>

The tensor, represented as a span.

Returns

The index of the element in x with the largest magnitude (absolute value), or -1 if x is empty.

Remarks

The determination of the maximum magnitude matches the IEEE 754:2019 `maximumMagnitude` function. If any value equal to NaN is present, the index of the first is returned. If two values have the same magnitude and one is positive and the other is negative, the positive value is considered to have the larger magnitude.

This method may call into the underlying C runtime or employ instructions specific to the current architecture. Exact results may differ between different operating systems or architectures.

Applies to

.NET 9 (package-provided) and .NET 8 (package-provided)
Product Versions
.NET 8 (package-provided), 9 (package-provided)