

@@ 66,6 +66,32 @@ const struct log2_data __log2_data = { 



0x1.a6225e117f92ep3, 



#endif 



}, 



/* Algorithm: 







x = 2^k z 



log2(x) = k + log2(c) + log2(z/c) 



log2(z/c) = poly(z/c  1) 







where z is in [1.6p1; 1.6p0] which is split into N subintervals and z falls 



into the ith one, then table entries are computed as 







tab[i].invc = 1/c 



tab[i].logc = (double)log2(c) 



tab2[i].chi = (double)c 



tab2[i].clo = (double)(c  (double)c) 







where c is near the center of the subinterval and is chosen by trying +2^29 



floating point invc candidates around 1/center and selecting one for which 







1) the rounding error in 0x1.8p10 + logc is 0, 



2) the rounding error in z  chi  clo is < 0x1p64 and 



3) the rounding error in (double)log2(c) is minimized (< 0x1p68). 







Note: 1) ensures that k + logc can be computed without rounding error, 2) 



ensures that z/c  1 can be computed as (z  chi  clo)*invc with close to a 



single rounding error when there is no fast fma for z*invc  1, 3) ensures 



that logc + poly(z/c  1) has small error, however near x == 1 when 



log2(x) < 0x1p4, this is not enough so that is special cased. */ 



.tab = { 



#if N == 64 



{0x1.724286bb1acf8p+0, 0x1.1095feecdb000p1}, 


