Skip to content

Add reciprocal and SinCos methods to IFloatingPoint #58607

Closed

Description

@lilinus

Background and Motivation

Suggestion for the generic math. The mentioned methods are available in Math and MathF classes. I think it would be nice to add these to the IFloatingPoint interface.

Proposed API

namespace System
{
    public interface IFloatingPoint<TSelf>
    {
...
+        (TSelf, TSelf) SinCos(TSelf x);
+        TSelf ReciprocalEstimate(TSelf x);
+        TSelf ReciprocalSqrtEstimate(TSelf x);
...
    }
}

Oops forgot to add api suggestion label...

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Sep 3, 2021
  2. huoyaoyuan commented on Sep 3, 2021

    @huoyaoyuan
    Member

    They are more about low-level optimization, when you know the hardware support for some specific type, and looks unsuitable for generic. The interface should contain primitive methods only.

  3. tannergooding commented on Sep 7, 2021

    @tannergooding
    Member

    They are more about low-level optimization, when you know the hardware support for some specific type, and looks unsuitable for generic. The interface should contain primitive methods only.

    The functions exist as more than just hardware optimizations and they are fully suitable for use in general algorithms, hence why they are on Math/MathF and not some other type.

    These were simply missed from the initial preview due to the functions being new in .NET 6.

  4. added
    api-ready-for-reviewAPI is ready for review, it is NOT ready for implementation
    and removed
    untriagedNew issue has not been triaged by the area owner
    on Sep 7, 2021
  5. added this to the 7.0.0 milestone on Sep 15, 2021
  6. bartonjs commented on Sep 21, 2021

    @bartonjs
    Member

    Video

    Looks good as proposed.

    namespace System
    {
        public interface IFloatingPoint<TSelf>
        {
    +        (TSelf Sin, TSelf Cos) SinCos(TSelf x);
    +        TSelf ReciprocalEstimate(TSelf x);
    +        TSelf ReciprocalSqrtEstimate(TSelf x);
        }
    }
  7. added
    api-approvedAPI was approved in API review, it can be implemented
    and removed
    api-ready-for-reviewAPI is ready for review, it is NOT ready for implementation
    on Sep 21, 2021
  8. added a commit that references this issue on Sep 23, 2021
    fc5964c
  9. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Sep 23, 2021
  10. danmoseley commented on Mar 8, 2022

    @danmoseley
    Contributor

    @lilinus are you interested in working on this one?

  11. tannergooding commented on Mar 8, 2022

    @tannergooding
    Member

    This is one that isn't easy to pick up at the moment since it impacts generic math.

    We're working through several parallel changes to get it in box before additional work/changes can happen here.

  12. lilinus commented on Mar 15, 2022

    @lilinus
    ContributorAuthor

    Sure, I can pick it up if @i3arnon who has a PR doesn't want to. Will keep an eye out for when generic math is potentially ready for this change.

  13. i3arnon commented on Mar 15, 2022

    @i3arnon
    Contributor

    @lilinus Thanks for the heads up.
    I indeed want it but AFAICT my existing PR is good enough at this moment.
    I can update it accordingly when the other generic math changes are done.

  14. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Mar 27, 2022
  15. ghost locked as resolved and limited conversation to collaborators on Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions