This commit is contained in:
@@ -84,6 +84,13 @@ The `DDMath` static class provides:
|
||||
- `Abs(DoubleDouble)`: preserves both components, maps either signed zero to
|
||||
positive zero and either infinity to positive infinity, and returns canonical NaN.
|
||||
It shares the existing `DoubleDouble.Abs` implementation.
|
||||
- `Reciprocal(DoubleDouble)`: returns exactly the same high and low component bits
|
||||
as `1.0 / value`. It specializes scalar/DD division for a numerator of one,
|
||||
omitting only redundant numerator checks while preserving both divisions,
|
||||
the FMA sequence, and normalization. Signed zeros map to signed infinities,
|
||||
signed infinities to signed zeros, and NaN to canonical NaN. The allocating exact boundary
|
||||
path handles extreme exponents; finite overflow produces signed infinity.
|
||||
No speedup over scalar/DD division has been measured.
|
||||
- `Sqrt(DoubleDouble)`: uses power-of-two scaling and an FMA-based Newton correction
|
||||
to retain extended precision, including for subnormal inputs, without squaring
|
||||
an unscaled estimate near the exponent limits. Signed zero and positive infinity
|
||||
@@ -122,6 +129,7 @@ using Just.PreciseMath;
|
||||
|
||||
DoubleDouble root = DDMath.Sqrt(new DoubleDouble(2.0));
|
||||
DoubleDouble inverseRoot = DDMath.InvSqrt(new DoubleDouble(2.0));
|
||||
DoubleDouble reciprocal = DDMath.Reciprocal(new DoubleDouble(3.0));
|
||||
DoubleDouble magnitude = DDMath.Abs(-root);
|
||||
DoubleDouble smallPower = DDMath.Pow(new DoubleDouble(2.0), -1024);
|
||||
DoubleDouble exponential = DDMath.Exp(new DoubleDouble(1.0));
|
||||
@@ -131,6 +139,13 @@ DoubleDouble preciseExponent = DoubleDouble.FromComponents(0.5, 1e-30);
|
||||
DoubleDouble precisePower = DDMath.Pow(new DoubleDouble(2.0), preciseExponent);
|
||||
```
|
||||
|
||||
Reciprocal tests check bitwise equivalence with `1.0 / value` and independently
|
||||
check exact rational error against `2^-100` relative plus one minimum binary64
|
||||
subnormal. They sample every binary64 exponent, both signs, dense and sparse lows,
|
||||
binade neighbors, and special values; selected powers of two and sparse corrections
|
||||
also have exact component checks. This preserves division's approximate-accuracy
|
||||
contract, not a guarantee of correctly rounded results.
|
||||
|
||||
Square-root and inverse-square-root tests compare the exact component sum against
|
||||
a `2^-100` relative error bound using integer inequalities. They include samples at every binary64
|
||||
exponent, boundary neighbors, both signs of the low component, and exact binary
|
||||
|
||||
Reference in New Issue
Block a user