@@ -2851,17 +2851,17 @@ typedef struct{ double hi; double lo; } DoubleLength;
2851
2851
static inline DoubleLength
2852
2852
twosum (double a , double b )
2853
2853
{
2854
- double s = a + b ;
2855
- double ap = s - b ;
2856
- double bp = s - a ;
2857
- double da = a - ap ;
2858
- double db = b - bp ;
2859
- double t = da + db ;
2860
- return (DoubleLength ) {s , t };
2854
+ // Rump Algorithm 3.1 Error-free transformation of the sum
2855
+ double x = a + b ;
2856
+ double z = x - a ;
2857
+ double y = (a - (x - z )) + (b - z );
2858
+ return (DoubleLength ) {x , y };
2861
2859
}
2862
2860
2863
2861
static inline DoubleLength
2864
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
2865
double t = x * 134217729.0 ; // Veltkamp constant = 2.0 ** 27 + 1
2866
2866
double hi = t - (t - x );
2867
2867
double lo = x - hi ;
@@ -2871,7 +2871,7 @@ dl_split(double x) {
2871
2871
static inline DoubleLength
2872
2872
dl_mul (double x , double y )
2873
2873
{
2874
- /* Dekker mul12(). Section ( 5.12) */
2874
+ // Dekker ( 5.12) and mul12()
2875
2875
DoubleLength xx = dl_split (x );
2876
2876
DoubleLength yy = dl_split (y );
2877
2877
double p = xx .hi * yy .hi ;
@@ -2881,24 +2881,19 @@ dl_mul(double x, double y)
2881
2881
return (DoubleLength ) {z , zz };
2882
2882
}
2883
2883
2884
- typedef struct { double hi ; double lo ; double tiny ; } TripleLength ;
2884
+ typedef struct { double hi ; double lo ; double tiny ; } TripleLength ;
2885
2885
2886
2886
static const TripleLength tl_zero = {0.0 , 0.0 , 0.0 };
2887
2887
2888
2888
static inline TripleLength
2889
- tl_add (TripleLength total , double x )
2889
+ tl_fma (TripleLength total , double x , double y )
2890
2890
{
2891
- DoubleLength s = twosum (x , total .hi );
2892
- DoubleLength t = twosum (s .lo , total .lo );
2893
- return (TripleLength ) {s .hi , t .hi , t .lo + total .tiny };
2894
- }
2895
-
2896
- static inline TripleLength
2897
- tl_fma (TripleLength total , double p , double q )
2898
- {
2899
- DoubleLength product = dl_mul (p , q );
2900
- total = tl_add (total , product .hi );
2901
- return tl_add (total , product .lo );
2891
+ // Rump Algorithm 5.10 with K=3 and using SumKVert
2892
+ DoubleLength pr = dl_mul (x , y );
2893
+ DoubleLength sm = twosum (total .hi , pr .hi );
2894
+ DoubleLength r1 = twosum (total .lo , pr .lo );
2895
+ DoubleLength r2 = twosum (r1 .hi , sm .lo );
2896
+ return (TripleLength ) {sm .hi , r2 .hi , total .tiny + r1 .lo + r2 .lo };
2902
2897
}
2903
2898
2904
2899
static inline double
0 commit comments