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 by Sun Microsystems, Inc. All rights reserved. | 4 // Copyright (C) 1993 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 // ==================================================== |
11 // | 11 // |
12 // The original source code covered by the above license above has been | 12 // The original source code covered by the above license above has been |
13 // modified significantly by Google Inc. | 13 // modified significantly by Google Inc. |
14 // Copyright 2014 the V8 project authors. All rights reserved. | 14 // Copyright 2014 the V8 project authors. All rights reserved. |
15 | 15 |
16 #include "src/v8.h" | 16 #include "src/v8.h" |
17 | 17 |
18 #include "src/double.h" | 18 #include "src/double.h" |
19 #include "src/third_party/fdlibm/fdlibm.h" | 19 #include "src/third_party/fdlibm/fdlibm.h" |
20 | 20 |
21 | 21 |
22 namespace v8 { | 22 namespace v8 { |
23 namespace fdlibm { | 23 namespace fdlibm { |
24 | 24 |
25 #ifdef _MSC_VER | 25 #ifdef _MSC_VER |
26 inline double scalbn(double x, int y) { return _scalb(x, y); } | 26 inline double scalbn(double x, int y) { return _scalb(x, y); } |
27 #endif // _MSC_VER | 27 #endif // _MSC_VER |
28 | 28 |
29 const double MathConstants::constants[] = { | 29 const double MathConstants::constants[] = { |
30 6.36619772367581382433e-01, // invpio2 0 | 30 6.36619772367581382433e-01, // invpio2 0 |
31 1.57079632673412561417e+00, // pio2_1 1 | 31 1.57079632673412561417e+00, // pio2_1 1 |
32 6.07710050650619224932e-11, // pio2_1t 2 | 32 6.07710050650619224932e-11, // pio2_1t 2 |
33 6.07710050630396597660e-11, // pio2_2 3 | 33 6.07710050630396597660e-11, // pio2_2 3 |
34 2.02226624879595063154e-21, // pio2_2t 4 | 34 2.02226624879595063154e-21, // pio2_2t 4 |
35 2.02226624871116645580e-21, // pio2_3 5 | 35 2.02226624871116645580e-21, // pio2_3 5 |
36 8.47842766036889956997e-32, // pio2_3t 6 | 36 8.47842766036889956997e-32, // pio2_3t 6 |
37 -1.66666666666666324348e-01, // S1 7 coefficients for sin | 37 -1.66666666666666324348e-01, // S1 7 coefficients for sin |
38 8.33333333332248946124e-03, // 8 | 38 8.33333333332248946124e-03, // 8 |
39 -1.98412698298579493134e-04, // 9 | 39 -1.98412698298579493134e-04, // 9 |
40 2.75573137070700676789e-06, // 10 | 40 2.75573137070700676789e-06, // 10 |
41 -2.50507602534068634195e-08, // 11 | 41 -2.50507602534068634195e-08, // 11 |
42 1.58969099521155010221e-10, // S6 12 | 42 1.58969099521155010221e-10, // S6 12 |
43 4.16666666666666019037e-02, // C1 13 coefficients for cos | 43 4.16666666666666019037e-02, // C1 13 coefficients for cos |
44 -1.38888888888741095749e-03, // 14 | 44 -1.38888888888741095749e-03, // 14 |
45 2.48015872894767294178e-05, // 15 | 45 2.48015872894767294178e-05, // 15 |
46 -2.75573143513906633035e-07, // 16 | 46 -2.75573143513906633035e-07, // 16 |
47 2.08757232129817482790e-09, // 17 | 47 2.08757232129817482790e-09, // 17 |
48 -1.13596475577881948265e-11, // C6 18 | 48 -1.13596475577881948265e-11, // C6 18 |
49 3.33333333333334091986e-01, // T0 19 coefficients for tan | 49 3.33333333333334091986e-01, // T0 19 coefficients for tan |
50 1.33333333333201242699e-01, // 20 | 50 1.33333333333201242699e-01, // 20 |
51 5.39682539762260521377e-02, // 21 | 51 5.39682539762260521377e-02, // 21 |
52 2.18694882948595424599e-02, // 22 | 52 2.18694882948595424599e-02, // 22 |
53 8.86323982359930005737e-03, // 23 | 53 8.86323982359930005737e-03, // 23 |
54 3.59207910759131235356e-03, // 24 | 54 3.59207910759131235356e-03, // 24 |
55 1.45620945432529025516e-03, // 25 | 55 1.45620945432529025516e-03, // 25 |
56 5.88041240820264096874e-04, // 26 | 56 5.88041240820264096874e-04, // 26 |
57 2.46463134818469906812e-04, // 27 | 57 2.46463134818469906812e-04, // 27 |
58 7.81794442939557092300e-05, // 28 | 58 7.81794442939557092300e-05, // 28 |
59 7.14072491382608190305e-05, // 29 | 59 7.14072491382608190305e-05, // 29 |
60 -1.85586374855275456654e-05, // 30 | 60 -1.85586374855275456654e-05, // 30 |
61 2.59073051863633712884e-05, // T12 31 | 61 2.59073051863633712884e-05, // T12 31 |
62 7.85398163397448278999e-01, // pio4 32 | 62 7.85398163397448278999e-01, // pio4 32 |
63 3.06161699786838301793e-17, // pio4lo 33 | 63 3.06161699786838301793e-17, // pio4lo 33 |
64 6.93147180369123816490e-01, // ln2_hi 34 | 64 6.93147180369123816490e-01, // ln2_hi 34 |
65 1.90821492927058770002e-10, // ln2_lo 35 | 65 1.90821492927058770002e-10, // ln2_lo 35 |
66 1.80143985094819840000e+16, // 2^54 36 | 66 1.80143985094819840000e+16, // 2^54 36 |
67 6.666666666666666666e-01, // 2/3 37 | 67 6.666666666666666666e-01, // 2/3 37 |
68 6.666666666666735130e-01, // LP1 38 coefficients for log1p | 68 6.666666666666735130e-01, // LP1 38 coefficients for log1p |
69 3.999999999940941908e-01, // 39 | 69 3.999999999940941908e-01, // 39 |
70 2.857142874366239149e-01, // 40 | 70 2.857142874366239149e-01, // 40 |
71 2.222219843214978396e-01, // 41 | 71 2.222219843214978396e-01, // 41 |
72 1.818357216161805012e-01, // 42 | 72 1.818357216161805012e-01, // 42 |
73 1.531383769920937332e-01, // 43 | 73 1.531383769920937332e-01, // 43 |
74 1.479819860511658591e-01, // LP7 44 | 74 1.479819860511658591e-01, // LP7 44 |
75 7.09782712893383973096e+02, // 45 overflow threshold for expm1 | 75 7.09782712893383973096e+02, // 45 overflow threshold for expm1 |
76 1.44269504088896338700e+00, // 1/ln2 46 | 76 1.44269504088896338700e+00, // 1/ln2 46 |
77 -3.33333333333331316428e-02, // Q1 47 coefficients for expm1 | 77 -3.33333333333331316428e-02, // Q1 47 coefficients for expm1 |
78 1.58730158725481460165e-03, // 48 | 78 1.58730158725481460165e-03, // 48 |
79 -7.93650757867487942473e-05, // 49 | 79 -7.93650757867487942473e-05, // 49 |
80 4.00821782732936239552e-06, // 50 | 80 4.00821782732936239552e-06, // 50 |
81 -2.01099218183624371326e-07, // Q5 51 | 81 -2.01099218183624371326e-07, // Q5 51 |
82 710.4758600739439 // 52 overflow threshold sinh, cosh | 82 710.4758600739439, // 52 overflow threshold sinh, cosh |
| 83 4.34294481903251816668e-01, // ivln10 53 coefficients for log10 |
| 84 3.01029995663611771306e-01, // log10_2hi 54 |
| 85 3.69423907715893078616e-13 // log10_2lo 55 |
83 }; | 86 }; |
84 | 87 |
85 | 88 |
86 // Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi | 89 // Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi |
87 static const int two_over_pi[] = { | 90 static const int two_over_pi[] = { |
88 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 0x95993C, | 91 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 0x95993C, |
89 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, 0x424DD2, 0xE00649, | 92 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, 0x424DD2, 0xE00649, |
90 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, 0xA73EE8, 0x8235F5, 0x2EBB44, | 93 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, 0xA73EE8, 0x8235F5, 0x2EBB44, |
91 0x84E99C, 0x7026B4, 0x5F7E41, 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, | 94 0x84E99C, 0x7026B4, 0x5F7E41, 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, |
92 0xBDF928, 0x3B1FF8, 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, | 95 0xBDF928, 0x3B1FF8, 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 int n = __kernel_rem_pio2(tx, y, e0, nx); | 275 int n = __kernel_rem_pio2(tx, y, e0, nx); |
273 if (hx < 0) { | 276 if (hx < 0) { |
274 y[0] = -y[0]; | 277 y[0] = -y[0]; |
275 y[1] = -y[1]; | 278 y[1] = -y[1]; |
276 return -n; | 279 return -n; |
277 } | 280 } |
278 return n; | 281 return n; |
279 } | 282 } |
280 } | 283 } |
281 } // namespace v8::internal | 284 } // namespace v8::internal |
OLD | NEW |