Skip to content

[API Proposal]: Add missing Min/MaxNumber generic math APIs on TensorPrimitives #98862

Description

@stephentoub

Background and motivation

These slipped through when aiming for parity.

API Proposal

namespace System.Numerics.Tensors;

public static class TensorPrimitives
{
    // Same surface area as Min/Max{Magnitude}, but for Min/Max{Magnitude}Number
+   public static int IndexOfMaxNumber<T>(ReadOnlySpan<T> x) where T : INumber<T>;
+   public static int IndexOfMinNumber<T>(ReadOnlySpan<T> x) where T : INumber<T>;
+   public static int IndexOfMaxMagnitudeNumber<T>(ReadOnlySpan<T> x) where T : INumber<T>;
+   public static int IndexOfMinMagnitudeNumber<T>(ReadOnlySpan<T> x) where T : INumber<T>;

+   public static T MaxMagnitudeNumber<T>(ReadOnlySpan<T> x) where T : INumberBase<T>;
+   public static void MaxMagnitudeNumber<T>(ReadOnlySpan<T> x, ReadOnlySpan<T> y, System.Span<T> destination) where T : INumberBase<T>;
+   public static void MaxMagnitudeNumber<T>(ReadOnlySpan<T> x, T y, Span<T> destination) where T : INumberBase<T>;

+   public static T MaxNumber<T>(ReadOnlySpan<T> x) where T : INumber<T>;
+   public static void MaxNumber<T>(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) where T : INumber<T>;
+   public static void MaxNumber<T>(ReadOnlySpan<T> x, T y, Span<T> destination) where T : INumber<T>;

+   public static T MinMagnitudeNumber<T>(ReadOnlySpan<T> x) where T : INumberBase<T>;
+   public static void MinMagnitudeNumber<T>(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) where T : INumberBase<T>;
+   public static void MinMagnitudeNumber<T>(ReadOnlySpan<T> x, T y, Span<T> destination) where T : INumberBase<T>;

+   public static T MinNumber<T>(ReadOnlySpan<T> x) where T : INumber<T>;
+   public static void MinNumber<T>(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Span<T> destination) where T : INumber<T>;
+   public static void MinNumber<T>(ReadOnlySpan<T> x, T y, Span<T> destination) where T : INumber<T>;
}

API Usage

TensorPrimitives.MaxMagnitude(x, y, dest);

Alternative Designs

No response

Risks

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions