Add reciprocal and SinCos methods to IFloatingPoint
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...
Tagging subscribers to this area: @dotnet/area-system-numerics See info in area-owners.md if you want to be subscribed.
Issue Details
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);
...
}
}
| Author: | lilinus |
|---|---|
| Assignees: | - |
| Labels: |
|
| Milestone: | - |
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.
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.
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);
}
}
@lilinus are you interested in working on this one?
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.
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.
@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.