This commit is contained in:
@@ -16,12 +16,18 @@ public class DoubleDoubleExtensionsTests
|
||||
[InlineData("Exp2M1")]
|
||||
[InlineData("Exp10M1")]
|
||||
[InlineData("Log")]
|
||||
[InlineData("Log2")]
|
||||
[InlineData("Log10")]
|
||||
[InlineData("LogP1")]
|
||||
[InlineData("Log2P1")]
|
||||
[InlineData("Log10P1")]
|
||||
public void UnaryExtensionsPreserveStaticFunctionComponentBits(string operation)
|
||||
{
|
||||
// These are forwarding contracts, not accuracy oracles. The static
|
||||
// kernels have separate independent numerical-reference tests.
|
||||
foreach (DoubleDouble value in Values())
|
||||
{
|
||||
DoubleDouble original = value;
|
||||
(DoubleDouble expected, DoubleDouble actual) = operation switch
|
||||
{
|
||||
"Abs" => (DoubleDouble.Abs(value), value.Abs()),
|
||||
@@ -37,12 +43,49 @@ public class DoubleDoubleExtensionsTests
|
||||
"Exp2M1" => (DoubleDouble.Exp2M1(value), value.Exp2M1()),
|
||||
"Exp10M1" => (DoubleDouble.Exp10M1(value), value.Exp10M1()),
|
||||
"Log" => (DoubleDouble.Log(value), value.Log()),
|
||||
"Log2" => (DoubleDouble.Log2(value), value.Log2()),
|
||||
"Log10" => (DoubleDouble.Log10(value), value.Log10()),
|
||||
"LogP1" => (DoubleDouble.LogP1(value), value.LogP1()),
|
||||
"Log2P1" => (DoubleDouble.Log2P1(value), value.Log2P1()),
|
||||
"Log10P1" => (DoubleDouble.Log10P1(value), value.Log10P1()),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(operation))
|
||||
};
|
||||
AssertBits(expected, actual);
|
||||
AssertBits(original, value);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BaseLogarithmExtensionPreservesBothOperands()
|
||||
{
|
||||
DoubleDouble[] bases = [DoubleDouble.Zero, DoubleDouble.NegativeZero,
|
||||
DoubleDouble.One, DoubleDouble.NegativeOne, DoubleDouble.NaN,
|
||||
DoubleDouble.PositiveInfinity, DoubleDouble.NegativeInfinity,
|
||||
new(0.5), new(2.0), new(10.0), new(double.Epsilon), new(double.MaxValue),
|
||||
DoubleDouble.FromComponents(1.0, double.Epsilon),
|
||||
DoubleDouble.FromComponents(1.0, -double.Epsilon),
|
||||
DoubleDouble.FromComponents(2.0, Math.ScaleB(1.0, -54))];
|
||||
foreach (DoubleDouble value in Values())
|
||||
{
|
||||
foreach (DoubleDouble newBase in bases)
|
||||
{
|
||||
DoubleDouble originalValue = value;
|
||||
DoubleDouble originalBase = newBase;
|
||||
AssertBits(DoubleDouble.Log(value, newBase), value.Log(newBase));
|
||||
AssertBits(originalValue, value);
|
||||
AssertBits(originalBase, newBase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LogarithmExtensionsCanBeChainedWithoutChangingTheReceiver()
|
||||
{
|
||||
DoubleDouble value = new(8.0);
|
||||
AssertBits(new DoubleDouble(8.0), value.Log2().Exp2());
|
||||
AssertBits(new DoubleDouble(8.0), value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ExtensionsCanBeChainedWithoutChangingTheReceiver()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user