Skip to content

Commit 376df8a

Browse files
committed
FMA version
1 parent b5c4d60 commit 376df8a

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

Modules/mathmodule.c

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,10 +2835,6 @@ long_add_would_overflow(long a, long b)
28352835
Double and triple length extended precision floating point arithmetic
28362836
based on:
28372837
2838-
A Floating-Point Technique for Extending the Available Precision
2839-
by T. J. Dekker
2840-
https://csclub.uwaterloo.ca/~pbarfuss/dekker1971.pdf
2841-
28422838
Accurate Sum and Dot Product
28432839
by Takeshi Ogita, Siegfried M. Rump, and Shin’Ichi Oishi
28442840
https://doi.org/10.1137/030601818
@@ -2858,26 +2854,12 @@ twosum(double a, double b)
28582854
return (DoubleLength) {x, y};
28592855
}
28602856

2861-
static inline DoubleLength
2862-
dl_split(double x) {
2863-
// Rump Algorithm 3.2 Error-free splitting of a floating point number
2864-
// Dekker (5.5) and (5.6).
2865-
double t = x * 134217729.0; // Veltkamp constant = 2.0 ** 27 + 1
2866-
double hi = t - (t - x);
2867-
double lo = x - hi;
2868-
return (DoubleLength) {hi, lo};
2869-
}
2870-
28712857
static inline DoubleLength
28722858
dl_mul(double x, double y)
28732859
{
2874-
// Dekker (5.12) and mul12()
2875-
DoubleLength xx = dl_split(x);
2876-
DoubleLength yy = dl_split(y);
2877-
double p = xx.hi * yy.hi;
2878-
double q = xx.hi * yy.lo + xx.lo * yy.hi;
2879-
double z = p + q;
2880-
double zz = p - z + q + xx.lo * yy.lo;
2860+
// Rump Algorithm 3.5. Error-free transformation of a product
2861+
double z = x * y;
2862+
double zz = fma(x, y, -z);
28812863
return (DoubleLength) {z, zz};
28822864
}
28832865

0 commit comments

Comments
 (0)