uxarray.utils.computing._fast_two_sum#
- uxarray.utils.computing._fast_two_sum(a, b)#
Compute a fast error-free transformation of the sum of two floating- point numbers.
This function is a faster alternative to _two_sum for computing the sum of two floating-point numbers a and b, such that a + b = x + y exactly. Note: |a| must be no less than |b|.
- Parameters:
- Returns:
The rounded sum of a and b, and the error term. The error term represents the difference between the exact sum and the rounded sum.
- Return type:
- Raises:
ValueError – If |a| < |b|.
Examples
>>> _fast_two_sum(2.0, 1.0) (3.0, 0.0)
>>> _fast_two_sum(1.0, 2.0) Traceback (most recent call last): ... ValueError: |a| must be greater than or equal to |b|.
T. J. Dekker. A Floating-Point Technique for Extending the Available Precision. Numerische Mathematik, 18(3), 224–242,1971. 10.1007/BF01397083. Available at: https://doi.org/10.1007/BF01397083.