This commit is contained in:
@@ -17,10 +17,10 @@ public class PreciseMathLogTests
|
||||
foreach (double value in values)
|
||||
{
|
||||
DoubleDouble expected = new(Math.Log(value));
|
||||
AssertBits(DDMath.Log(new DoubleDouble(value)), expected.High, 0.0);
|
||||
AssertBits(DoubleDouble.Log(new DoubleDouble(value)), expected.High, 0.0);
|
||||
}
|
||||
DoubleDouble negative = DoubleDouble.FromComponents(-1.0, Math.ScaleB(1.0, -54));
|
||||
AssertBits(DDMath.Log(negative), double.NaN, 0.0);
|
||||
AssertBits(DoubleDouble.Log(negative), double.NaN, 0.0);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -31,7 +31,7 @@ public class PreciseMathLogTests
|
||||
// 2200 digits and checked with Fraction. No binary64 log supplies the oracle.
|
||||
DoubleDouble input = DoubleDouble.FromComponents(high, low);
|
||||
(Units(input.High) + Units(input.Low)).ShouldBe(Units(high) + Units(low));
|
||||
DoubleDouble actual = DDMath.Log(input);
|
||||
DoubleDouble actual = DoubleDouble.Log(input);
|
||||
AssertReferenceBound(actual, reference, 1, $"{label}: ({high:R}, {low:R})");
|
||||
if (input == DoubleDouble.One)
|
||||
{
|
||||
@@ -51,7 +51,7 @@ public class PreciseMathLogTests
|
||||
for (int exponent = -1074; exponent <= 1023; ++exponent)
|
||||
{
|
||||
DoubleDouble input = new(Math.ScaleB(1.0, exponent));
|
||||
AssertReferenceBound(DDMath.Log(input), LogReferenceData.Ln2, exponent, $"2^{exponent}");
|
||||
AssertReferenceBound(DoubleDouble.Log(input), LogReferenceData.Ln2, exponent, $"2^{exponent}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class PreciseMathLogTests
|
||||
{
|
||||
// The legacy Log(1e308) formed u+value and overflowed. The finite
|
||||
// kernel must reduce the mantissa before constructing its denominator.
|
||||
DoubleDouble actual = DDMath.Log(new DoubleDouble(input));
|
||||
DoubleDouble actual = DoubleDouble.Log(new DoubleDouble(input));
|
||||
DoubleDouble.IsFinite(actual).ShouldBeTrue();
|
||||
actual.Low.ShouldNotBe(0.0);
|
||||
DoubleDouble.IsCanonical(actual).ShouldBeTrue();
|
||||
@@ -75,12 +75,12 @@ public class PreciseMathLogTests
|
||||
{
|
||||
foreach (double sign in new[] { -1.0, 1.0 })
|
||||
{
|
||||
AssertBits(DDMath.Log(DoubleDouble.FromComponents(1.0, sign * double.Epsilon)),
|
||||
AssertBits(DoubleDouble.Log(DoubleDouble.FromComponents(1.0, sign * double.Epsilon)),
|
||||
sign * double.Epsilon, 0.0);
|
||||
double delta = sign * Math.ScaleB(1.0, -500);
|
||||
// ln(1+d) = d-d^2/2+O(d^3). Here the cubic tail is below half
|
||||
// the minimum subnormal, so these two binary components are exact.
|
||||
AssertBits(DDMath.Log(DoubleDouble.FromComponents(1.0, delta)),
|
||||
AssertBits(DoubleDouble.Log(DoubleDouble.FromComponents(1.0, delta)),
|
||||
delta, -Math.ScaleB(1.0, -1001));
|
||||
}
|
||||
}
|
||||
@@ -89,8 +89,8 @@ public class PreciseMathLogTests
|
||||
public void ArbitraryPairsAreNormalizedByThePublicFactoryBeforeLog()
|
||||
{
|
||||
DoubleDouble positive = DoubleDouble.FromComponents(0.0, 2.0);
|
||||
AssertReferenceBound(DDMath.Log(positive), LogReferenceData.Ln2, 1, "zero-high public construction");
|
||||
AssertBits(DDMath.Log(DoubleDouble.FromComponents(0.0, -2.0)), double.NaN, 0.0);
|
||||
AssertReferenceBound(DoubleDouble.Log(positive), LogReferenceData.Ln2, 1, "zero-high public construction");
|
||||
AssertBits(DoubleDouble.Log(DoubleDouble.FromComponents(0.0, -2.0)), double.NaN, 0.0);
|
||||
}
|
||||
|
||||
private static void AssertReferenceBound(DoubleDouble actual, string reference, int factor, string context)
|
||||
|
||||
Reference in New Issue
Block a user