operators refactoring
.NET Test / .NET tests (push) Successful in 2m11s

This commit is contained in:
2026-09-24 00:39:59 +04:00
parent 3de9457fdc
commit ac93744579
26 changed files with 651 additions and 334 deletions
@@ -11,7 +11,7 @@ public class PreciseMathInvSqrtTests
public void IrrationalInverseRootsRetainMoreThanBinary64Precision(double value)
{
DoubleDouble input = new(value);
DoubleDouble actual = DDMath.InvSqrt(input);
DoubleDouble actual = DoubleDouble.InvSqrt(input);
actual.Low.ShouldNotBe(0.0);
AssertInvSqrtBound(input, actual);
}
@@ -23,7 +23,7 @@ public class PreciseMathInvSqrtTests
double.NaN, -1.0, -double.Epsilon, double.MinValue];
foreach (double value in values)
{
DoubleDouble actual = DDMath.InvSqrt(new DoubleDouble(value));
DoubleDouble actual = DoubleDouble.InvSqrt(new DoubleDouble(value));
// Binary64 is an independent oracle only for these special values.
double expected = 1.0 / Math.Sqrt(value);
BitConverter.DoubleToInt64Bits(actual.High).ShouldBe(
@@ -33,7 +33,7 @@ public class PreciseMathInvSqrtTests
}
DoubleDouble negative = DoubleDouble.FromComponents(-1.0, Math.ScaleB(1.0, -54));
DoubleDouble.IsNaN(DDMath.InvSqrt(negative)).ShouldBeTrue();
DoubleDouble.IsNaN(DoubleDouble.InvSqrt(negative)).ShouldBeTrue();
}
[Fact]
@@ -42,7 +42,7 @@ public class PreciseMathInvSqrtTests
// 1/sqrt(2^(2k)) = 2^-k exactly, including the minimum subnormal input.
for (int exponent = -1074; exponent <= 1022; exponent += 2)
{
DoubleDouble actual = DDMath.InvSqrt(new DoubleDouble(Math.ScaleB(1.0, exponent)));
DoubleDouble actual = DoubleDouble.InvSqrt(new DoubleDouble(Math.ScaleB(1.0, exponent)));
actual.High.ShouldBe(Math.ScaleB(1.0, -(exponent / 2)));
BitConverter.DoubleToInt64Bits(actual.Low).ShouldBe(0L);
}
@@ -54,7 +54,7 @@ public class PreciseMathInvSqrtTests
foreach (double low in new[] { Math.ScaleB(1.0, -54), -Math.ScaleB(1.0, -54) })
{
DoubleDouble input = DoubleDouble.FromComponents(1.0, low);
DoubleDouble actual = DDMath.InvSqrt(input);
DoubleDouble actual = DoubleDouble.InvSqrt(input);
actual.High.ShouldBe(1.0);
Math.Sign(actual.Low).ShouldBe(-Math.Sign(low));
AssertInvSqrtBound(input, actual);
@@ -78,7 +78,7 @@ public class PreciseMathInvSqrtTests
if (boundary > 0.0)
{
DoubleDouble input = new(boundary);
AssertInvSqrtBound(input, DDMath.InvSqrt(input));
AssertInvSqrtBound(input, DoubleDouble.InvSqrt(input));
}
}
foreach (double residual in new[] { 0.0, low, -low, double.Epsilon, -double.Epsilon })
@@ -86,7 +86,7 @@ public class PreciseMathInvSqrtTests
DoubleDouble input = DoubleDouble.FromComponents(high, residual);
if (input.High > 0.0)
{
AssertInvSqrtBound(input, DDMath.InvSqrt(input));
AssertInvSqrtBound(input, DoubleDouble.InvSqrt(input));
}
}
}
@@ -103,7 +103,7 @@ public class PreciseMathInvSqrtTests
DoubleDouble.FromComponents(0.0, double.Epsilon)];
foreach (DoubleDouble input in boundaries)
{
AssertInvSqrtBound(input, DDMath.InvSqrt(input));
AssertInvSqrtBound(input, DoubleDouble.InvSqrt(input));
}
}
@@ -123,7 +123,7 @@ public class PreciseMathInvSqrtTests
DoubleDouble input = DoubleDouble.FromComponents(high, low);
if (DoubleDouble.IsFinite(input) && input.High > 0.0)
{
AssertInvSqrtBound(input, DDMath.InvSqrt(input));
AssertInvSqrtBound(input, DoubleDouble.InvSqrt(input));
}
}
}
@@ -140,7 +140,7 @@ public class PreciseMathInvSqrtTests
foreach (double sign in new[] { -1.0, 1.0 })
{
double low = Math.ScaleB(sign, exponent);
DoubleDouble actual = DDMath.InvSqrt(DoubleDouble.FromComponents(1.0, low));
DoubleDouble actual = DoubleDouble.InvSqrt(DoubleDouble.FromComponents(1.0, low));
actual.High.ShouldBe(1.0);
actual.Low.ShouldBe(Math.ScaleB(-sign, exponent - 1));
DoubleDouble.IsCanonical(actual).ShouldBeTrue();