Expand description
Error-free transformations: floating-point sums and products together with their exact rounding errors.
Every function returns a pair (x, y) where x is the correctly rounded
floating-point result of the operation and y its rounding error, so that
x + y equals the real result exactly. This holds under the requirement
documented on each function, assuming the default round-to-nearest-even
mode. NaN and infinite inputs are not supported.
The algorithms are those of Knuth, Dekker and Veltkamp as presented by
Shewchuk, “Adaptive Precision Floating-Point Arithmetic and Fast Robust
Geometric Predicates” (1997). When the target has a hardware fused
multiply-add (see HAS_FMA), the exact product uses it instead.
Constants§
- HAS_FMA
- True when
two_productuses a fused multiply-add on this target. - PRODUCT_
OPERAND_ MAX 2^480, the largest magnitude in the product domain. Seein_product_domain.- PRODUCT_
OPERAND_ MIN 2^-480, the smallest nonzero magnitude in the product domain. Seein_product_domain.
Functions§
- fast_
two_ sum - Computes
a + band its rounding error, faster thantwo_sumwhen the magnitudes are known to be ordered (Dekker’s fast-two-sum). - in_
product_ domain - Returns
trueifxlies in the product domain: it is zero of either sign, or its magnitude is inPRODUCT_OPERAND_MIN..=PRODUCT_OPERAND_MAX, that is2^-480 ..= 2^480. - two_
diff - Computes
a - band its rounding error. - two_
product - Computes
a * band its rounding error with the crate’s selected implementation:two_product_fmawhenHAS_FMAis true, andtwo_product_dekkerotherwise. Both give equal values. - two_
product_ dekker - Computes
a * band its rounding error with Dekker’s algorithm, using only additions and multiplications. - two_
square - Computes
a * aand its rounding error: withtwo_product_fmawhenHAS_FMAis true, and otherwise with fewer operations thantwo_product_dekker. - two_sum
- Computes
a + band its rounding error (Knuth’s two-sum).