未验证 提交 ef4773c3 编写于 作者: B Bar Arnon 提交者: GitHub

Add reciprocal and SinCos methods to IFloatingPoint (#59521)

上级 20761d0b
......@@ -676,6 +676,12 @@ public static TInteger ILogB<TInteger>(double x)
/// <inheritdoc cref="IFloatingPoint{TSelf}.Pow(TSelf, TSelf)" />
public static double Pow(double x, double y) => Math.Pow(x, y);
/// <inheritdoc cref="IFloatingPoint{TSelf}.ReciprocalEstimate(TSelf)" />
public static double ReciprocalEstimate(double x) => Math.ReciprocalEstimate(x);
/// <inheritdoc cref="IFloatingPoint{TSelf}.ReciprocalSqrtEstimate(TSelf)" />
public static double ReciprocalSqrtEstimate(double x) => Math.ReciprocalSqrtEstimate(x);
/// <inheritdoc cref="IFloatingPoint{TSelf}.Round(TSelf)" />
public static double Round(double x) => Math.Round(x);
......@@ -697,6 +703,9 @@ public static double ScaleB<TInteger>(double x, TInteger n)
/// <inheritdoc cref="IFloatingPoint{TSelf}.Sin(TSelf)" />
public static double Sin(double x) => Math.Sin(x);
/// <inheritdoc cref="IFloatingPoint{TSelf}.SinCos(TSelf)" />
public static (double Sin, double Cos) SinCos(double x) => Math.SinCos(x);
/// <inheritdoc cref="IFloatingPoint{TSelf}.Sinh(TSelf)" />
public static double Sinh(double x) => Math.Sinh(x);
......
......@@ -899,6 +899,12 @@ public static TInteger ILogB<TInteger>(Half x)
/// <inheritdoc cref="IFloatingPoint{TSelf}.Pow(TSelf, TSelf)" />
public static Half Pow(Half x, Half y) => (Half)MathF.Pow((float)x, (float)y);
/// <inheritdoc cref="IFloatingPoint{TSelf}.ReciprocalEstimate(TSelf)" />
public static Half ReciprocalEstimate(Half x) => (Half)MathF.ReciprocalEstimate((float)x);
/// <inheritdoc cref="IFloatingPoint{TSelf}.ReciprocalSqrtEstimate(TSelf)" />
public static Half ReciprocalSqrtEstimate(Half x) => (Half)MathF.ReciprocalSqrtEstimate((float)x);
/// <inheritdoc cref="IFloatingPoint{TSelf}.Round(TSelf)" />
public static Half Round(Half x) => (Half)MathF.Round((float)x);
......@@ -920,6 +926,13 @@ public static Half ScaleB<TInteger>(Half x, TInteger n)
/// <inheritdoc cref="IFloatingPoint{TSelf}.Sin(TSelf)" />
public static Half Sin(Half x) => (Half)MathF.Sin((float)x);
/// <inheritdoc cref="IFloatingPoint{TSelf}.SinCos(TSelf)" />
public static (Half Sin, Half Cos) SinCos(Half x)
{
var (sin, cos) = MathF.SinCos((float)x);
return ((Half)sin, (Half)cos);
}
/// <inheritdoc cref="IFloatingPoint{TSelf}.Sinh(TSelf)" />
public static Half Sinh(Half x) => (Half)MathF.Sinh((float)x);
......
......@@ -215,6 +215,16 @@ public interface IFloatingPoint<TSelf>
/// <returns><see cref="E" /> raised to the power of <paramref name="x" />.</returns>
static abstract TSelf Pow(TSelf x, TSelf y);
/// <summary>Computes an estimate of the reciprocal of a value.</summary>
/// <param name="x">The value whose estimate of the reciprocal is to be computed.</param>
/// <returns>An estimate of the reciprocal of <paramref name="x" />.</returns>
static abstract TSelf ReciprocalEstimate(TSelf x);
/// <summary>Computes an estimate of the reciprocal square root of a value.</summary>
/// <param name="x">The value whose estimate of the reciprocal square root is to be computed.</param>
/// <returns>An estimate of the reciprocal square root of <paramref name="x" />.</returns>
static abstract TSelf ReciprocalSqrtEstimate(TSelf x);
/// <summary>Rounds a value to the nearest integer using the default rounding mode (<see cref="MidpointRounding.ToEven" />).</summary>
/// <param name="x">The value to round.</param>
/// <returns>The result of rounding <paramref name="x" /> to the nearest integer using the default rounding mode.</returns>
......@@ -253,6 +263,11 @@ public interface IFloatingPoint<TSelf>
/// <returns>The sine of <paramref name="x" />.</returns>
static abstract TSelf Sin(TSelf x);
/// <summary>Computes the sine and cosine of a value.</summary>
/// <param name="x">The value, in radians, whose sine and cosine are to be computed.</param>
/// <returns>The sine and cosine of <paramref name="x" />.</returns>
static abstract (TSelf Sin, TSelf Cos) SinCos(TSelf x);
/// <summary>Computes the hyperbolic sine of a value.</summary>
/// <param name="x">The value, in radians, whose hyperbolic sine is to be computed.</param>
/// <returns>The hyperbolic sine of <paramref name="x" />.</returns>
......
......@@ -671,6 +671,12 @@ public static TInteger ILogB<TInteger>(float x)
/// <inheritdoc cref="IFloatingPoint{TSelf}.Pow(TSelf, TSelf)" />
public static float Pow(float x, float y) => MathF.Pow(x, y);
/// <inheritdoc cref="IFloatingPoint{TSelf}.ReciprocalEstimate(TSelf)" />
public static float ReciprocalEstimate(float x) => MathF.ReciprocalEstimate(x);
/// <inheritdoc cref="IFloatingPoint{TSelf}.ReciprocalSqrtEstimate(TSelf)" />
public static float ReciprocalSqrtEstimate(float x) => MathF.ReciprocalSqrtEstimate(x);
/// <inheritdoc cref="IFloatingPoint{TSelf}.Round(TSelf)" />
public static float Round(float x) => MathF.Round(x);
......@@ -692,6 +698,9 @@ public static float ScaleB<TInteger>(float x, TInteger n)
/// <inheritdoc cref="IFloatingPoint{TSelf}.Sin(TSelf)" />
public static float Sin(float x) => MathF.Sin(x);
/// <inheritdoc cref="IFloatingPoint{TSelf}.SinCos(TSelf)" />
public static (float Sin, float Cos) SinCos(float x) => MathF.SinCos(x);
/// <inheritdoc cref="IFloatingPoint{TSelf}.Sinh(TSelf)" />
public static float Sinh(float x) => MathF.Sinh(x);
......
......@@ -2070,6 +2070,8 @@ public partial class DivideByZeroException : System.ArithmeticException
public static System.Double Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider? provider) { throw null; }
public static System.Double Parse(string s, System.IFormatProvider? provider) { throw null; }
public static System.Double Pow(System.Double x, System.Double y) { throw null; }
public static System.Double ReciprocalEstimate(System.Double x) { throw null; }
public static System.Double ReciprocalSqrtEstimate(System.Double x) { throw null; }
public static System.Double Round(System.Double x) { throw null; }
public static System.Double Round(System.Double x, System.MidpointRounding mode) { throw null; }
public static System.Double Round<TInteger>(System.Double x, TInteger digits) where TInteger : IBinaryInteger<TInteger> { throw null; }
......@@ -2077,6 +2079,7 @@ public partial class DivideByZeroException : System.ArithmeticException
public static System.Double ScaleB<TInteger>(System.Double x, TInteger n) where TInteger : IBinaryInteger<TInteger> { throw null; }
public static System.Double Sign(System.Double value) { throw null; }
public static System.Double Sin(System.Double x) { throw null; }
public static (System.Double Sin, System.Double Cos) SinCos(System.Double x) { throw null; }
public static System.Double Sinh(System.Double x) { throw null; }
public static System.Double Sqrt(System.Double x) { throw null; }
static System.Double System.IAdditionOperators<System.Double,System.Double,System.Double>.operator +(System.Double left, System.Double right) { throw null; }
......@@ -2649,6 +2652,8 @@ public partial class GopherStyleUriParser : System.UriParser
public static System.Half Parse(string s, System.Globalization.NumberStyles style = System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowExponent | System.Globalization.NumberStyles.AllowLeadingSign | System.Globalization.NumberStyles.AllowLeadingWhite | System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowTrailingWhite, System.IFormatProvider? provider = null) { throw null; }
public static System.Half Parse(string s, System.IFormatProvider? provider) { throw null; }
public static System.Half Pow(System.Half x, System.Half y) { throw null; }
public static System.Half ReciprocalEstimate(System.Half x) { throw null; }
public static System.Half ReciprocalSqrtEstimate(System.Half x) { throw null; }
public static System.Half Round(System.Half x) { throw null; }
public static System.Half Round(System.Half x, System.MidpointRounding mode) { throw null; }
public static System.Half Round<TInteger>(System.Half x, TInteger digits) where TInteger : IBinaryInteger<TInteger> { throw null; }
......@@ -2656,6 +2661,7 @@ public partial class GopherStyleUriParser : System.UriParser
public static System.Half ScaleB<TInteger>(System.Half x, TInteger n) where TInteger : IBinaryInteger<TInteger> { throw null; }
public static System.Half Sign(System.Half value) { throw null; }
public static System.Half Sin(System.Half x) { throw null; }
public static (System.Half Sin, System.Half Cos) SinCos(System.Half x) { throw null; }
public static System.Half Sinh(System.Half x) { throw null; }
public static System.Half Sqrt(System.Half x) { throw null; }
static System.Half System.IBitwiseOperators<System.Half,System.Half,System.Half>.operator &(System.Half left, System.Half right) { throw null; }
......@@ -2810,12 +2816,15 @@ public partial interface IFloatingPoint<TSelf> : System.ISignedNumber<TSelf>
static abstract TSelf MaxMagnitude(TSelf x, TSelf y);
static abstract TSelf MinMagnitude(TSelf x, TSelf y);
static abstract TSelf Pow(TSelf x, TSelf y);
static abstract TSelf ReciprocalEstimate(TSelf x);
static abstract TSelf ReciprocalSqrtEstimate(TSelf x);
static abstract TSelf Round(TSelf x);
static abstract TSelf Round<TInteger>(TSelf x, TInteger digits) where TInteger : IBinaryInteger<TInteger>;
static abstract TSelf Round(TSelf x, MidpointRounding mode);
static abstract TSelf Round<TInteger>(TSelf x, TInteger digits, MidpointRounding mode) where TInteger : IBinaryInteger<TInteger>;
static abstract TSelf ScaleB<TInteger>(TSelf x, TInteger n) where TInteger : IBinaryInteger<TInteger>;
static abstract TSelf Sin(TSelf x);
static abstract (TSelf Sin, TSelf Cos) SinCos(TSelf x);
static abstract TSelf Sinh(TSelf x);
static abstract TSelf Sqrt(TSelf x);
static abstract TSelf Tan(TSelf x);
......@@ -4369,6 +4378,8 @@ public sealed partial class SerializableAttribute : System.Attribute
public static System.Single Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider? provider) { throw null; }
public static System.Single Parse(string s, System.IFormatProvider? provider) { throw null; }
public static System.Single Pow(System.Single x, System.Single y) { throw null; }
public static System.Single ReciprocalEstimate(System.Single x) { throw null; }
public static System.Single ReciprocalSqrtEstimate(System.Single x) { throw null; }
public static System.Single Round(System.Single x) { throw null; }
public static System.Single Round(System.Single x, System.MidpointRounding mode) { throw null; }
public static System.Single Round<TInteger>(System.Single x, TInteger digits) where TInteger : IBinaryInteger<TInteger> { throw null; }
......@@ -4376,6 +4387,7 @@ public sealed partial class SerializableAttribute : System.Attribute
public static System.Single ScaleB<TInteger>(System.Single x, TInteger n) where TInteger : IBinaryInteger<TInteger> { throw null; }
public static System.Single Sign(System.Single value) { throw null; }
public static System.Single Sin(System.Single x) { throw null; }
public static (System.Single Sin, System.Single Cos) SinCos(System.Single x) { throw null; }
public static System.Single Sinh(System.Single x) { throw null; }
public static System.Single Sqrt(System.Single x) { throw null; }
static System.Single System.IAdditionOperators<System.Single,System.Single,System.Single>.operator +(System.Single left, System.Single right) { throw null; }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册