OLD | NEW |
1 // The following is adapted from fdlibm (http://www.netlib.org/fdlibm), | 1 // The following is adapted from fdlibm (http://www.netlib.org/fdlibm), |
2 // | 2 // |
3 // ==================================================== | 3 // ==================================================== |
4 // Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved. | 4 // Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved. |
5 // | 5 // |
6 // Developed at SunSoft, a Sun Microsystems, Inc. business. | 6 // Developed at SunSoft, a Sun Microsystems, Inc. business. |
7 // Permission to use, copy, modify, and distribute this | 7 // Permission to use, copy, modify, and distribute this |
8 // software is freely granted, provided that this notice | 8 // software is freely granted, provided that this notice |
9 // is preserved. | 9 // is preserved. |
10 // ==================================================== | 10 // ==================================================== |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 KLOG2(3) + s2 * (KLOG2(4) + s2 * KLOG2(5)))))); | 1061 KLOG2(3) + s2 * (KLOG2(4) + s2 * KLOG2(5)))))); |
1062 r += s_l * (s_h + ss); | 1062 r += s_l * (s_h + ss); |
1063 s2 = s_h * s_h; | 1063 s2 = s_h * s_h; |
1064 t_h = %_ConstructDouble(%_DoubleHi(3.0 + s2 + r), 0); | 1064 t_h = %_ConstructDouble(%_DoubleHi(3.0 + s2 + r), 0); |
1065 t_l = r - ((t_h - 3.0) - s2); | 1065 t_l = r - ((t_h - 3.0) - s2); |
1066 // u + v = ss * (1 + ...) | 1066 // u + v = ss * (1 + ...) |
1067 u = s_h * t_h; | 1067 u = s_h * t_h; |
1068 v = s_l * t_h + t_l * ss; | 1068 v = s_l * t_h + t_l * ss; |
1069 | 1069 |
1070 // 2 / (3 * log(2)) * (ss + ...) | 1070 // 2 / (3 * log(2)) * (ss + ...) |
1071 p_h = %_ConstructDouble(%_DoubleHi(u + v), 0); | 1071 var p_h = %_ConstructDouble(%_DoubleHi(u + v), 0); |
1072 p_l = v - (p_h - u); | 1072 var p_l = v - (p_h - u); |
1073 z_h = CP_H * p_h; | 1073 var z_h = CP_H * p_h; |
1074 z_l = CP_L * p_h + p_l * CP + dp_l; | 1074 var z_l = CP_L * p_h + p_l * CP + dp_l; |
1075 | 1075 |
1076 // log2(ax) = (ss + ...) * 2 / (3 * log(2)) = n + dp_h + z_h + z_l | 1076 // log2(ax) = (ss + ...) * 2 / (3 * log(2)) = n + dp_h + z_h + z_l |
1077 var t = n; | 1077 var t = n; |
1078 var t1 = %_ConstructDouble(%_DoubleHi(((z_h + z_l) + dp_h) + t), 0); | 1078 var t1 = %_ConstructDouble(%_DoubleHi(((z_h + z_l) + dp_h) + t), 0); |
1079 var t2 = z_l - (((t1 - t) - dp_h) - z_h); | 1079 var t2 = z_l - (((t1 - t) - dp_h) - z_h); |
1080 | 1080 |
1081 // t1 + t2 = log2(ax), sum up because we do not care about extra precision. | 1081 // t1 + t2 = log2(ax), sum up because we do not care about extra precision. |
1082 return t1 + t2; | 1082 return t1 + t2; |
1083 } | 1083 } |
1084 | 1084 |
1085 //------------------------------------------------------------------- | 1085 //------------------------------------------------------------------- |
1086 | 1086 |
1087 utils.InstallFunctions(GlobalMath, DONT_ENUM, [ | 1087 utils.InstallFunctions(GlobalMath, DONT_ENUM, [ |
1088 "cos", MathCos, | 1088 "cos", MathCos, |
1089 "sin", MathSin, | 1089 "sin", MathSin, |
1090 "tan", MathTan, | 1090 "tan", MathTan, |
1091 "sinh", MathSinh, | 1091 "sinh", MathSinh, |
1092 "cosh", MathCosh, | 1092 "cosh", MathCosh, |
1093 "tanh", MathTanh, | 1093 "tanh", MathTanh, |
1094 "log10", MathLog10, | 1094 "log10", MathLog10, |
1095 "log2", MathLog2, | 1095 "log2", MathLog2, |
1096 "log1p", MathLog1p, | 1096 "log1p", MathLog1p, |
1097 "expm1", MathExpm1 | 1097 "expm1", MathExpm1 |
1098 ]); | 1098 ]); |
1099 | 1099 |
1100 %SetForceInlineFlag(MathSin); | 1100 %SetForceInlineFlag(MathSin); |
1101 %SetForceInlineFlag(MathCos); | 1101 %SetForceInlineFlag(MathCos); |
1102 | 1102 |
1103 }) | 1103 }) |
OLD | NEW |