1//===-- Common constants for math functions ---------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "common_constants.h"
10#include "src/__support/FPUtil/triple_double.h"
11#include "src/__support/number_pair.h"
12
13namespace LIBC_NAMESPACE {
14
15// Lookup table for (1/f) where f = 1 + n*2^(-7), n = 0..127.
16const double ONE_OVER_F[128] = {
17 0x1.0000000000000p+0, 0x1.fc07f01fc07f0p-1, 0x1.f81f81f81f820p-1,
18 0x1.f44659e4a4271p-1, 0x1.f07c1f07c1f08p-1, 0x1.ecc07b301ecc0p-1,
19 0x1.e9131abf0b767p-1, 0x1.e573ac901e574p-1, 0x1.e1e1e1e1e1e1ep-1,
20 0x1.de5d6e3f8868ap-1, 0x1.dae6076b981dbp-1, 0x1.d77b654b82c34p-1,
21 0x1.d41d41d41d41dp-1, 0x1.d0cb58f6ec074p-1, 0x1.cd85689039b0bp-1,
22 0x1.ca4b3055ee191p-1, 0x1.c71c71c71c71cp-1, 0x1.c3f8f01c3f8f0p-1,
23 0x1.c0e070381c0e0p-1, 0x1.bdd2b899406f7p-1, 0x1.bacf914c1bad0p-1,
24 0x1.b7d6c3dda338bp-1, 0x1.b4e81b4e81b4fp-1, 0x1.b2036406c80d9p-1,
25 0x1.af286bca1af28p-1, 0x1.ac5701ac5701bp-1, 0x1.a98ef606a63bep-1,
26 0x1.a6d01a6d01a6dp-1, 0x1.a41a41a41a41ap-1, 0x1.a16d3f97a4b02p-1,
27 0x1.9ec8e951033d9p-1, 0x1.9c2d14ee4a102p-1, 0x1.999999999999ap-1,
28 0x1.970e4f80cb872p-1, 0x1.948b0fcd6e9e0p-1, 0x1.920fb49d0e229p-1,
29 0x1.8f9c18f9c18fap-1, 0x1.8d3018d3018d3p-1, 0x1.8acb90f6bf3aap-1,
30 0x1.886e5f0abb04ap-1, 0x1.8618618618618p-1, 0x1.83c977ab2beddp-1,
31 0x1.8181818181818p-1, 0x1.7f405fd017f40p-1, 0x1.7d05f417d05f4p-1,
32 0x1.7ad2208e0ecc3p-1, 0x1.78a4c8178a4c8p-1, 0x1.767dce434a9b1p-1,
33 0x1.745d1745d1746p-1, 0x1.724287f46debcp-1, 0x1.702e05c0b8170p-1,
34 0x1.6e1f76b4337c7p-1, 0x1.6c16c16c16c17p-1, 0x1.6a13cd1537290p-1,
35 0x1.6816816816817p-1, 0x1.661ec6a5122f9p-1, 0x1.642c8590b2164p-1,
36 0x1.623fa77016240p-1, 0x1.6058160581606p-1, 0x1.5e75bb8d015e7p-1,
37 0x1.5c9882b931057p-1, 0x1.5ac056b015ac0p-1, 0x1.58ed2308158edp-1,
38 0x1.571ed3c506b3ap-1, 0x1.5555555555555p-1, 0x1.5390948f40febp-1,
39 0x1.51d07eae2f815p-1, 0x1.5015015015015p-1, 0x1.4e5e0a72f0539p-1,
40 0x1.4cab88725af6ep-1, 0x1.4afd6a052bf5bp-1, 0x1.49539e3b2d067p-1,
41 0x1.47ae147ae147bp-1, 0x1.460cbc7f5cf9ap-1, 0x1.446f86562d9fbp-1,
42 0x1.42d6625d51f87p-1, 0x1.4141414141414p-1, 0x1.3fb013fb013fbp-1,
43 0x1.3e22cbce4a902p-1, 0x1.3c995a47babe7p-1, 0x1.3b13b13b13b14p-1,
44 0x1.3991c2c187f63p-1, 0x1.3813813813814p-1, 0x1.3698df3de0748p-1,
45 0x1.3521cfb2b78c1p-1, 0x1.33ae45b57bcb2p-1, 0x1.323e34a2b10bfp-1,
46 0x1.30d190130d190p-1, 0x1.2f684bda12f68p-1, 0x1.2e025c04b8097p-1,
47 0x1.2c9fb4d812ca0p-1, 0x1.2b404ad012b40p-1, 0x1.29e4129e4129ep-1,
48 0x1.288b01288b013p-1, 0x1.27350b8812735p-1, 0x1.25e22708092f1p-1,
49 0x1.2492492492492p-1, 0x1.23456789abcdfp-1, 0x1.21fb78121fb78p-1,
50 0x1.20b470c67c0d9p-1, 0x1.1f7047dc11f70p-1, 0x1.1e2ef3b3fb874p-1,
51 0x1.1cf06ada2811dp-1, 0x1.1bb4a4046ed29p-1, 0x1.1a7b9611a7b96p-1,
52 0x1.19453808ca29cp-1, 0x1.1811811811812p-1, 0x1.16e0689427379p-1,
53 0x1.15b1e5f75270dp-1, 0x1.1485f0e0acd3bp-1, 0x1.135c81135c811p-1,
54 0x1.12358e75d3033p-1, 0x1.1111111111111p-1, 0x1.0fef010fef011p-1,
55 0x1.0ecf56be69c90p-1, 0x1.0db20a88f4696p-1, 0x1.0c9714fbcda3bp-1,
56 0x1.0b7e6ec259dc8p-1, 0x1.0a6810a6810a7p-1, 0x1.0953f39010954p-1,
57 0x1.0842108421084p-1, 0x1.073260a47f7c6p-1, 0x1.0624dd2f1a9fcp-1,
58 0x1.05197f7d73404p-1, 0x1.0410410410410p-1, 0x1.03091b51f5e1ap-1,
59 0x1.0204081020408p-1, 0x1.0101010101010p-1};
60
61// Lookup table for log(f) = log(1 + n*2^(-7)) where n = 0..127.
62const double LOG_F[128] = {
63 0x0.0000000000000p+0, 0x1.fe02a6b106788p-8, 0x1.fc0a8b0fc03e3p-7,
64 0x1.7b91b07d5b11ap-6, 0x1.f829b0e783300p-6, 0x1.39e87b9febd5fp-5,
65 0x1.77458f632dcfcp-5, 0x1.b42dd711971bep-5, 0x1.f0a30c01162a6p-5,
66 0x1.16536eea37ae0p-4, 0x1.341d7961bd1d0p-4, 0x1.51b073f06183fp-4,
67 0x1.6f0d28ae56b4bp-4, 0x1.8c345d6319b20p-4, 0x1.a926d3a4ad563p-4,
68 0x1.c5e548f5bc743p-4, 0x1.e27076e2af2e5p-4, 0x1.fec9131dbeabap-4,
69 0x1.0d77e7cd08e59p-3, 0x1.1b72ad52f67a0p-3, 0x1.29552f81ff523p-3,
70 0x1.371fc201e8f74p-3, 0x1.44d2b6ccb7d1ep-3, 0x1.526e5e3a1b437p-3,
71 0x1.5ff3070a793d3p-3, 0x1.6d60fe719d21cp-3, 0x1.7ab890210d909p-3,
72 0x1.87fa06520c910p-3, 0x1.9525a9cf456b4p-3, 0x1.a23bc1fe2b563p-3,
73 0x1.af3c94e80bff2p-3, 0x1.bc286742d8cd6p-3, 0x1.c8ff7c79a9a21p-3,
74 0x1.d5c216b4fbb91p-3, 0x1.e27076e2af2e5p-3, 0x1.ef0adcbdc5936p-3,
75 0x1.fb9186d5e3e2ap-3, 0x1.0402594b4d040p-2, 0x1.0a324e27390e3p-2,
76 0x1.1058bf9ae4ad5p-2, 0x1.1675cababa60ep-2, 0x1.1c898c16999fap-2,
77 0x1.22941fbcf7965p-2, 0x1.2895a13de86a3p-2, 0x1.2e8e2bae11d30p-2,
78 0x1.347dd9a987d54p-2, 0x1.3a64c556945e9p-2, 0x1.404308686a7e3p-2,
79 0x1.4618bc21c5ec2p-2, 0x1.4be5f957778a0p-2, 0x1.51aad872df82dp-2,
80 0x1.5767717455a6cp-2, 0x1.5d1bdbf5809cap-2, 0x1.62c82f2b9c795p-2,
81 0x1.686c81e9b14aep-2, 0x1.6e08eaa2ba1e3p-2, 0x1.739d7f6bbd006p-2,
82 0x1.792a55fdd47a2p-2, 0x1.7eaf83b82afc3p-2, 0x1.842d1da1e8b17p-2,
83 0x1.89a3386c1425ap-2, 0x1.8f11e873662c7p-2, 0x1.947941c2116fap-2,
84 0x1.99d958117e08ap-2, 0x1.9f323ecbf984bp-2, 0x1.a484090e5bb0ap-2,
85 0x1.a9cec9a9a0849p-2, 0x1.af1293247786bp-2, 0x1.b44f77bcc8f62p-2,
86 0x1.b9858969310fbp-2, 0x1.beb4d9da71b7bp-2, 0x1.c3dd7a7cdad4dp-2,
87 0x1.c8ff7c79a9a21p-2, 0x1.ce1af0b85f3ebp-2, 0x1.d32fe7e00ebd5p-2,
88 0x1.d83e7258a2f3ep-2, 0x1.dd46a04c1c4a0p-2, 0x1.e24881a7c6c26p-2,
89 0x1.e744261d68787p-2, 0x1.ec399d2468cc0p-2, 0x1.f128f5faf06ecp-2,
90 0x1.f6123fa7028acp-2, 0x1.faf588f78f31ep-2, 0x1.ffd2e0857f498p-2,
91 0x1.02552a5a5d0fep-1, 0x1.04bdf9da926d2p-1, 0x1.0723e5c1cdf40p-1,
92 0x1.0986f4f573520p-1, 0x1.0be72e4252a82p-1, 0x1.0e44985d1cc8bp-1,
93 0x1.109f39e2d4c96p-1, 0x1.12f719593efbcp-1, 0x1.154c3d2f4d5e9p-1,
94 0x1.179eabbd899a0p-1, 0x1.19ee6b467c96ep-1, 0x1.1c3b81f713c24p-1,
95 0x1.1e85f5e7040d0p-1, 0x1.20cdcd192ab6dp-1, 0x1.23130d7bebf42p-1,
96 0x1.2555bce98f7cbp-1, 0x1.2795e1289b11ap-1, 0x1.29d37fec2b08ap-1,
97 0x1.2c0e9ed448e8bp-1, 0x1.2e47436e40268p-1, 0x1.307d7334f10bep-1,
98 0x1.32b1339121d71p-1, 0x1.34e289d9ce1d3p-1, 0x1.37117b54747b5p-1,
99 0x1.393e0d3562a19p-1, 0x1.3b68449fffc22p-1, 0x1.3d9026a7156fap-1,
100 0x1.3fb5b84d16f42p-1, 0x1.41d8fe84672aep-1, 0x1.43f9fe2f9ce67p-1,
101 0x1.4618bc21c5ec2p-1, 0x1.48353d1ea88dfp-1, 0x1.4a4f85db03ebbp-1,
102 0x1.4c679afccee39p-1, 0x1.4e7d811b75bb0p-1, 0x1.50913cc01686bp-1,
103 0x1.52a2d265bc5aap-1, 0x1.54b2467999497p-1, 0x1.56bf9d5b3f399p-1,
104 0x1.58cadb5cd7989p-1, 0x1.5ad404c359f2cp-1, 0x1.5cdb1dc6c1764p-1,
105 0x1.5ee02a9241675p-1, 0x1.60e32f44788d8p-1};
106
107// Range reduction constants for logarithms.
108// r(0) = 1, r(127) = 0.5
109// r(k) = 2^-8 * ceil(2^8 * (1 - 2^-8) / (1 + k*2^-7))
110// The constants are chosen so that v = fma(r, m_x, -1) is exact in single
111// precision, and -2^-8 <= v < 2^-7.
112// TODO(lntue): Add reference to how the constants are derived after the
113// resulting paper is ready.
114alignas(32) const float R[128] = {
115 0x1p0, 0x1.fcp-1, 0x1.f8p-1, 0x1.f4p-1, 0x1.fp-1, 0x1.ecp-1, 0x1.e8p-1,
116 0x1.e4p-1, 0x1.ep-1, 0x1.dep-1, 0x1.dap-1, 0x1.d6p-1, 0x1.d4p-1, 0x1.dp-1,
117 0x1.ccp-1, 0x1.cap-1, 0x1.c6p-1, 0x1.c4p-1, 0x1.cp-1, 0x1.bep-1, 0x1.bap-1,
118 0x1.b8p-1, 0x1.b4p-1, 0x1.b2p-1, 0x1.aep-1, 0x1.acp-1, 0x1.a8p-1, 0x1.a6p-1,
119 0x1.a4p-1, 0x1.ap-1, 0x1.9ep-1, 0x1.9cp-1, 0x1.98p-1, 0x1.96p-1, 0x1.94p-1,
120 0x1.92p-1, 0x1.9p-1, 0x1.8cp-1, 0x1.8ap-1, 0x1.88p-1, 0x1.86p-1, 0x1.84p-1,
121 0x1.8p-1, 0x1.7ep-1, 0x1.7cp-1, 0x1.7ap-1, 0x1.78p-1, 0x1.76p-1, 0x1.74p-1,
122 0x1.72p-1, 0x1.7p-1, 0x1.6ep-1, 0x1.6cp-1, 0x1.6ap-1, 0x1.68p-1, 0x1.66p-1,
123 0x1.64p-1, 0x1.62p-1, 0x1.6p-1, 0x1.5ep-1, 0x1.5cp-1, 0x1.5ap-1, 0x1.58p-1,
124 0x1.56p-1, 0x1.54p-1, 0x1.54p-1, 0x1.52p-1, 0x1.5p-1, 0x1.4ep-1, 0x1.4cp-1,
125 0x1.4ap-1, 0x1.4ap-1, 0x1.48p-1, 0x1.46p-1, 0x1.44p-1, 0x1.42p-1, 0x1.4p-1,
126 0x1.4p-1, 0x1.3ep-1, 0x1.3cp-1, 0x1.3ap-1, 0x1.3ap-1, 0x1.38p-1, 0x1.36p-1,
127 0x1.34p-1, 0x1.34p-1, 0x1.32p-1, 0x1.3p-1, 0x1.3p-1, 0x1.2ep-1, 0x1.2cp-1,
128 0x1.2cp-1, 0x1.2ap-1, 0x1.28p-1, 0x1.28p-1, 0x1.26p-1, 0x1.24p-1, 0x1.24p-1,
129 0x1.22p-1, 0x1.2p-1, 0x1.2p-1, 0x1.1ep-1, 0x1.1cp-1, 0x1.1cp-1, 0x1.1ap-1,
130 0x1.1ap-1, 0x1.18p-1, 0x1.16p-1, 0x1.16p-1, 0x1.14p-1, 0x1.14p-1, 0x1.12p-1,
131 0x1.1p-1, 0x1.1p-1, 0x1.0ep-1, 0x1.0ep-1, 0x1.0cp-1, 0x1.0cp-1, 0x1.0ap-1,
132 0x1.0ap-1, 0x1.08p-1, 0x1.08p-1, 0x1.06p-1, 0x1.06p-1, 0x1.04p-1, 0x1.04p-1,
133 0x1.02p-1, 0x1.0p-1};
134
135alignas(64) const double RD[128] = {
136 0x1p0, 0x1.fcp-1, 0x1.f8p-1, 0x1.f4p-1, 0x1.fp-1, 0x1.ecp-1, 0x1.e8p-1,
137 0x1.e4p-1, 0x1.ep-1, 0x1.dep-1, 0x1.dap-1, 0x1.d6p-1, 0x1.d4p-1, 0x1.dp-1,
138 0x1.ccp-1, 0x1.cap-1, 0x1.c6p-1, 0x1.c4p-1, 0x1.cp-1, 0x1.bep-1, 0x1.bap-1,
139 0x1.b8p-1, 0x1.b4p-1, 0x1.b2p-1, 0x1.aep-1, 0x1.acp-1, 0x1.a8p-1, 0x1.a6p-1,
140 0x1.a4p-1, 0x1.ap-1, 0x1.9ep-1, 0x1.9cp-1, 0x1.98p-1, 0x1.96p-1, 0x1.94p-1,
141 0x1.92p-1, 0x1.9p-1, 0x1.8cp-1, 0x1.8ap-1, 0x1.88p-1, 0x1.86p-1, 0x1.84p-1,
142 0x1.8p-1, 0x1.7ep-1, 0x1.7cp-1, 0x1.7ap-1, 0x1.78p-1, 0x1.76p-1, 0x1.74p-1,
143 0x1.72p-1, 0x1.7p-1, 0x1.6ep-1, 0x1.6cp-1, 0x1.6ap-1, 0x1.68p-1, 0x1.66p-1,
144 0x1.64p-1, 0x1.62p-1, 0x1.6p-1, 0x1.5ep-1, 0x1.5cp-1, 0x1.5ap-1, 0x1.58p-1,
145 0x1.56p-1, 0x1.54p-1, 0x1.54p-1, 0x1.52p-1, 0x1.5p-1, 0x1.4ep-1, 0x1.4cp-1,
146 0x1.4ap-1, 0x1.4ap-1, 0x1.48p-1, 0x1.46p-1, 0x1.44p-1, 0x1.42p-1, 0x1.4p-1,
147 0x1.4p-1, 0x1.3ep-1, 0x1.3cp-1, 0x1.3ap-1, 0x1.3ap-1, 0x1.38p-1, 0x1.36p-1,
148 0x1.34p-1, 0x1.34p-1, 0x1.32p-1, 0x1.3p-1, 0x1.3p-1, 0x1.2ep-1, 0x1.2cp-1,
149 0x1.2cp-1, 0x1.2ap-1, 0x1.28p-1, 0x1.28p-1, 0x1.26p-1, 0x1.24p-1, 0x1.24p-1,
150 0x1.22p-1, 0x1.2p-1, 0x1.2p-1, 0x1.1ep-1, 0x1.1cp-1, 0x1.1cp-1, 0x1.1ap-1,
151 0x1.1ap-1, 0x1.18p-1, 0x1.16p-1, 0x1.16p-1, 0x1.14p-1, 0x1.14p-1, 0x1.12p-1,
152 0x1.1p-1, 0x1.1p-1, 0x1.0ep-1, 0x1.0ep-1, 0x1.0cp-1, 0x1.0cp-1, 0x1.0ap-1,
153 0x1.0ap-1, 0x1.08p-1, 0x1.08p-1, 0x1.06p-1, 0x1.06p-1, 0x1.04p-1, 0x1.04p-1,
154 0x1.02p-1, 0x1.0p-1};
155
156// Compensated constants for exact logarithm range reduction when FMA is not
157// available.
158// Generated by Sollya with the formula: CD[i] = RD[i]*(1 + i*2^-7) - 1
159// for RD[i] defined on the table above.
160alignas(64) const double CD[128] = {
161 0.0, -0x1p-14, -0x1p-12, -0x1.2p-11, -0x1p-10, -0x1.9p-10,
162 -0x1.2p-9, -0x1.88p-9, -0x1p-8, -0x1.9p-11, -0x1.fp-10, -0x1.9cp-9,
163 -0x1p-12, -0x1.cp-10, -0x1.bp-9, -0x1.5p-11, -0x1.4p-9, 0x1p-14,
164 -0x1p-9, 0x1.ap-12, -0x1.ep-10, 0x1.8p-12, -0x1.1p-9, -0x1p-15,
165 -0x1.6p-9, -0x1.ap-11, -0x1.ep-9, -0x1.f8p-10, -0x1p-12, -0x1.cp-9,
166 -0x1.fp-10, -0x1.cp-12, -0x1p-8, -0x1.54p-9, -0x1.6p-10, -0x1.4p-13,
167 0x1p-10, -0x1.88p-9, -0x1.08p-9, -0x1.2p-10, -0x1p-12, 0x1.2p-11,
168 -0x1p-8, -0x1.acp-9, -0x1.6p-9, -0x1.1cp-9, -0x1.cp-10, -0x1.58p-10,
169 -0x1p-10, -0x1.7p-11, -0x1p-11, -0x1.6p-12, -0x1p-12, -0x1.cp-13,
170 -0x1p-12, -0x1.6p-12, -0x1p-11, -0x1.7p-11, -0x1p-10, -0x1.58p-10,
171 -0x1.cp-10, -0x1.1cp-9, -0x1.6p-9, -0x1.acp-9, -0x1p-8, 0x1.5p-10,
172 0x1.2p-11, -0x1p-12, -0x1.2p-10, -0x1.08p-9, -0x1.88p-9, 0x1.0cp-9,
173 0x1p-10, -0x1.4p-13, -0x1.6p-10, -0x1.54p-9, -0x1p-8, 0x1p-10,
174 -0x1.cp-12, -0x1.fp-10, -0x1.cp-9, 0x1.68p-10, -0x1p-12, -0x1.f8p-10,
175 -0x1.ep-9, 0x1.1p-10, -0x1.ap-11, -0x1.6p-9, 0x1p-9, -0x1p-15,
176 -0x1.1p-9, 0x1.48p-9, 0x1.8p-12, -0x1.ep-10, 0x1.6p-9, 0x1.ap-12,
177 -0x1p-9, 0x1.48p-9, 0x1p-14, -0x1.4p-9, 0x1p-9, -0x1.5p-11,
178 -0x1.bp-9, 0x1.1p-10, -0x1.cp-10, 0x1.54p-9, -0x1p-12, -0x1.9cp-9,
179 0x1.2p-10, -0x1.fp-10, 0x1.3p-9, -0x1.9p-11, -0x1p-8, 0x1p-12,
180 -0x1.88p-9, 0x1.28p-10, -0x1.2p-9, 0x1.fp-10, -0x1.9p-10, 0x1.4cp-9,
181 -0x1p-10, 0x1.9p-9, -0x1.2p-11, 0x1.c4p-9, -0x1p-12, 0x1.e8p-9,
182 -0x1p-14, -0x1p-8,
183};
184
185alignas(64) const double LOG_R[128] = {
186 0x0.0000000000000p0, 0x1.010157588de71p-7, 0x1.0205658935847p-6,
187 0x1.8492528c8cabfp-6, 0x1.0415d89e74444p-5, 0x1.466aed42de3eap-5,
188 0x1.894aa149fb343p-5, 0x1.ccb73cdddb2ccp-5, 0x1.08598b59e3a07p-4,
189 0x1.1973bd1465567p-4, 0x1.3bdf5a7d1ee64p-4, 0x1.5e95a4d9791cbp-4,
190 0x1.700d30aeac0e1p-4, 0x1.9335e5d594989p-4, 0x1.b6ac88dad5b1cp-4,
191 0x1.c885801bc4b23p-4, 0x1.ec739830a112p-4, 0x1.fe89139dbd566p-4,
192 0x1.1178e8227e47cp-3, 0x1.1aa2b7e23f72ap-3, 0x1.2d1610c86813ap-3,
193 0x1.365fcb0159016p-3, 0x1.4913d8333b561p-3, 0x1.527e5e4a1b58dp-3,
194 0x1.6574ebe8c133ap-3, 0x1.6f0128b756abcp-3, 0x1.823c16551a3c2p-3,
195 0x1.8beafeb38fe8cp-3, 0x1.95a5adcf7017fp-3, 0x1.a93ed3c8ad9e3p-3,
196 0x1.b31d8575bce3dp-3, 0x1.bd087383bd8adp-3, 0x1.d1037f2655e7bp-3,
197 0x1.db13db0d4894p-3, 0x1.e530effe71012p-3, 0x1.ef5ade4dcffe6p-3,
198 0x1.f991c6cb3b379p-3, 0x1.07138604d5862p-2, 0x1.0c42d676162e3p-2,
199 0x1.1178e8227e47cp-2, 0x1.16b5ccbacfb73p-2, 0x1.1bf99635a6b95p-2,
200 0x1.269621134db92p-2, 0x1.2bef07cdc9354p-2, 0x1.314f1e1d35ce4p-2,
201 0x1.36b6776be1117p-2, 0x1.3c25277333184p-2, 0x1.419b423d5e8c7p-2,
202 0x1.4718dc271c41bp-2, 0x1.4c9e09e172c3cp-2, 0x1.522ae0738a3d8p-2,
203 0x1.57bf753c8d1fbp-2, 0x1.5d5bddf595f3p-2, 0x1.630030b3aac49p-2,
204 0x1.68ac83e9c6a14p-2, 0x1.6e60ee6af1972p-2, 0x1.741d876c67bb1p-2,
205 0x1.79e26687cfb3ep-2, 0x1.7fafa3bd8151cp-2, 0x1.85855776dcbfbp-2,
206 0x1.8b639a88b2df5p-2, 0x1.914a8635bf68ap-2, 0x1.973a3431356aep-2,
207 0x1.9d32bea15ed3bp-2, 0x1.a33440224fa79p-2, 0x1.a33440224fa79p-2,
208 0x1.a93ed3c8ad9e3p-2, 0x1.af5295248cddp-2, 0x1.b56fa04462909p-2,
209 0x1.bb9611b80e2fbp-2, 0x1.c1c60693fa39ep-2, 0x1.c1c60693fa39ep-2,
210 0x1.c7ff9c74554c9p-2, 0x1.ce42f18064743p-2, 0x1.d490246defa6bp-2,
211 0x1.dae75484c9616p-2, 0x1.e148a1a2726cep-2, 0x1.e148a1a2726cep-2,
212 0x1.e7b42c3ddad73p-2, 0x1.ee2a156b413e5p-2, 0x1.f4aa7ee03192dp-2,
213 0x1.f4aa7ee03192dp-2, 0x1.fb358af7a4884p-2, 0x1.00e5ae5b207abp-1,
214 0x1.04360be7603adp-1, 0x1.04360be7603adp-1, 0x1.078bf0533c568p-1,
215 0x1.0ae76e2d054fap-1, 0x1.0ae76e2d054fap-1, 0x1.0e4898611cce1p-1,
216 0x1.11af823c75aa8p-1, 0x1.11af823c75aa8p-1, 0x1.151c3f6f29612p-1,
217 0x1.188ee40f23ca6p-1, 0x1.188ee40f23ca6p-1, 0x1.1c07849ae6007p-1,
218 0x1.1f8635fc61659p-1, 0x1.1f8635fc61659p-1, 0x1.230b0d8bebc98p-1,
219 0x1.269621134db92p-1, 0x1.269621134db92p-1, 0x1.2a2786d0ec107p-1,
220 0x1.2dbf557b0df43p-1, 0x1.2dbf557b0df43p-1, 0x1.315da4434068bp-1,
221 0x1.315da4434068bp-1, 0x1.35028ad9d8c86p-1, 0x1.38ae2171976e7p-1,
222 0x1.38ae2171976e7p-1, 0x1.3c6080c36bfb5p-1, 0x1.3c6080c36bfb5p-1,
223 0x1.4019c2125ca93p-1, 0x1.43d9ff2f923c5p-1, 0x1.43d9ff2f923c5p-1,
224 0x1.47a1527e8a2d3p-1, 0x1.47a1527e8a2d3p-1, 0x1.4b6fd6f970c1fp-1,
225 0x1.4b6fd6f970c1fp-1, 0x1.4f45a835a4e19p-1, 0x1.4f45a835a4e19p-1,
226 0x1.5322e26867857p-1, 0x1.5322e26867857p-1, 0x1.5707a26bb8c66p-1,
227 0x1.5707a26bb8c66p-1, 0x1.5af405c3649ep-1, 0x1.5af405c3649ep-1,
228 0x1.5ee82aa24192p-1, 0x0.000000000000p0};
229
230alignas(64) const double LOG2_R[128] = {
231 0x0.0000000000000p+0, 0x1.72c7ba20f7327p-7, 0x1.743ee861f3556p-6,
232 0x1.184b8e4c56af8p-5, 0x1.77394c9d958d5p-5, 0x1.d6ebd1f1febfep-5,
233 0x1.1bb32a600549dp-4, 0x1.4c560fe68af88p-4, 0x1.7d60496cfbb4cp-4,
234 0x1.960caf9abb7cap-4, 0x1.c7b528b70f1c5p-4, 0x1.f9c95dc1d1165p-4,
235 0x1.097e38ce60649p-3, 0x1.22dadc2ab3497p-3, 0x1.3c6fb650cde51p-3,
236 0x1.494f863b8df35p-3, 0x1.633a8bf437ce1p-3, 0x1.7046031c79f85p-3,
237 0x1.8a8980abfbd32p-3, 0x1.97c1cb13c7ec1p-3, 0x1.b2602497d5346p-3,
238 0x1.bfc67a7fff4ccp-3, 0x1.dac22d3e441d3p-3, 0x1.e857d3d361368p-3,
239 0x1.01d9bbcfa61d4p-2, 0x1.08bce0d95fa38p-2, 0x1.169c05363f158p-2,
240 0x1.1d982c9d52708p-2, 0x1.249cd2b13cd6cp-2, 0x1.32bfee370ee68p-2,
241 0x1.39de8e1559f6fp-2, 0x1.4106017c3eca3p-2, 0x1.4f6fbb2cec598p-2,
242 0x1.56b22e6b578e5p-2, 0x1.5dfdcf1eeae0ep-2, 0x1.6552b49986277p-2,
243 0x1.6cb0f6865c8eap-2, 0x1.7b89f02cf2aadp-2, 0x1.8304d90c11fd3p-2,
244 0x1.8a8980abfbd32p-2, 0x1.921800924dd3bp-2, 0x1.99b072a96c6b2p-2,
245 0x1.a8ff971810a5ep-2, 0x1.b0b67f4f4681p-2, 0x1.b877c57b1b07p-2,
246 0x1.c043859e2fdb3p-2, 0x1.c819dc2d45fe4p-2, 0x1.cffae611ad12bp-2,
247 0x1.d7e6c0abc3579p-2, 0x1.dfdd89d586e2bp-2, 0x1.e7df5fe538ab3p-2,
248 0x1.efec61b011f85p-2, 0x1.f804ae8d0cd02p-2, 0x1.0014332be0033p-1,
249 0x1.042bd4b9a7c99p-1, 0x1.08494c66b8efp-1, 0x1.0c6caaf0c5597p-1,
250 0x1.1096015dee4dap-1, 0x1.14c560fe68af9p-1, 0x1.18fadb6e2d3c2p-1,
251 0x1.1d368296b5255p-1, 0x1.217868b0c37e8p-1, 0x1.25c0a0463bebp-1,
252 0x1.2a0f3c340705cp-1, 0x1.2e644fac04fd8p-1, 0x1.2e644fac04fd8p-1,
253 0x1.32bfee370ee68p-1, 0x1.37222bb70747cp-1, 0x1.3b8b1c68fa6edp-1,
254 0x1.3ffad4e74f1d6p-1, 0x1.44716a2c08262p-1, 0x1.44716a2c08262p-1,
255 0x1.48eef19317991p-1, 0x1.4d7380dcc422dp-1, 0x1.51ff2e30214bcp-1,
256 0x1.5692101d9b4a6p-1, 0x1.5b2c3da19723bp-1, 0x1.5b2c3da19723bp-1,
257 0x1.5fcdce2727ddbp-1, 0x1.6476d98ad990ap-1, 0x1.6927781d932a8p-1,
258 0x1.6927781d932a8p-1, 0x1.6ddfc2a78fc63p-1, 0x1.729fd26b707c8p-1,
259 0x1.7767c12967a45p-1, 0x1.7767c12967a45p-1, 0x1.7c37a9227e7fbp-1,
260 0x1.810fa51bf65fdp-1, 0x1.810fa51bf65fdp-1, 0x1.85efd062c656dp-1,
261 0x1.8ad846cf369a4p-1, 0x1.8ad846cf369a4p-1, 0x1.8fc924c89ac84p-1,
262 0x1.94c287492c4dbp-1, 0x1.94c287492c4dbp-1, 0x1.99c48be2063c8p-1,
263 0x1.9ecf50bf43f13p-1, 0x1.9ecf50bf43f13p-1, 0x1.a3e2f4ac43f6p-1,
264 0x1.a8ff971810a5ep-1, 0x1.a8ff971810a5ep-1, 0x1.ae255819f022dp-1,
265 0x1.b35458761d479p-1, 0x1.b35458761d479p-1, 0x1.b88cb9a2ab521p-1,
266 0x1.b88cb9a2ab521p-1, 0x1.bdce9dcc96187p-1, 0x1.c31a27dd00b4ap-1,
267 0x1.c31a27dd00b4ap-1, 0x1.c86f7b7ea4a89p-1, 0x1.c86f7b7ea4a89p-1,
268 0x1.cdcebd2373995p-1, 0x1.d338120a6dd9dp-1, 0x1.d338120a6dd9dp-1,
269 0x1.d8aba045b01c8p-1, 0x1.d8aba045b01c8p-1, 0x1.de298ec0bac0dp-1,
270 0x1.de298ec0bac0dp-1, 0x1.e3b20546f554ap-1, 0x1.e3b20546f554ap-1,
271 0x1.e9452c8a71028p-1, 0x1.e9452c8a71028p-1, 0x1.eee32e2aeccbfp-1,
272 0x1.eee32e2aeccbfp-1, 0x1.f48c34bd1e96fp-1, 0x1.f48c34bd1e96fp-1,
273 0x1.fa406bd2443dfp-1, 0x1.0000000000000p0};
274
275// Generated by Sollya with:
276// for i from 0 to 127 do {
277// r = 2^-8 * ceil( 2^8 * (1 - 2^(-8)) / (1 + i*2^-7) );
278// b = nearestint(log(r)*2^43) * 2^-43;
279// c = round(log(r) - b, D, RN);
280// print("{", -c, ",", -b, "},");
281// };
282// We replace LOG_R[0] with log10(1.0) == 0.0
283alignas(64) const NumberPair<double> LOG_R_DD[128] = {
284 {.lo: 0.0, .hi: 0.0},
285 {.lo: -0x1.0c76b999d2be8p-46, .hi: 0x1.010157589p-7},
286 {.lo: -0x1.3dc5b06e2f7d2p-45, .hi: 0x1.0205658938p-6},
287 {.lo: -0x1.aa0ba325a0c34p-45, .hi: 0x1.8492528c9p-6},
288 {.lo: 0x1.111c05cf1d753p-47, .hi: 0x1.0415d89e74p-5},
289 {.lo: -0x1.c167375bdfd28p-45, .hi: 0x1.466aed42ep-5},
290 {.lo: -0x1.97995d05a267dp-46, .hi: 0x1.894aa149fcp-5},
291 {.lo: -0x1.a68f247d82807p-46, .hi: 0x1.ccb73cdddcp-5},
292 {.lo: -0x1.7e5dd7009902cp-46, .hi: 0x1.08598b59e4p-4},
293 {.lo: -0x1.5325d560d9e9bp-45, .hi: 0x1.1973bd1466p-4},
294 {.lo: 0x1.cc85ea5db4ed7p-45, .hi: 0x1.3bdf5a7d1ep-4},
295 {.lo: -0x1.c69063c5d1d1ep-45, .hi: 0x1.5e95a4d97ap-4},
296 {.lo: 0x1.c1e8da99ded32p-49, .hi: 0x1.700d30aeacp-4},
297 {.lo: 0x1.3115c3abd47dap-45, .hi: 0x1.9335e5d594p-4},
298 {.lo: -0x1.390802bf768e5p-46, .hi: 0x1.b6ac88dad6p-4},
299 {.lo: 0x1.646d1c65aacd3p-45, .hi: 0x1.c885801bc4p-4},
300 {.lo: -0x1.dc068afe645ep-45, .hi: 0x1.ec739830a2p-4},
301 {.lo: -0x1.534d64fa10afdp-45, .hi: 0x1.fe89139dbep-4},
302 {.lo: 0x1.1ef78ce2d07f2p-45, .hi: 0x1.1178e8227ep-3},
303 {.lo: 0x1.ca78e44389934p-45, .hi: 0x1.1aa2b7e23fp-3},
304 {.lo: 0x1.39d6ccb81b4a1p-47, .hi: 0x1.2d1610c868p-3},
305 {.lo: 0x1.62fa8234b7289p-51, .hi: 0x1.365fcb0159p-3},
306 {.lo: 0x1.5837954fdb678p-45, .hi: 0x1.4913d8333bp-3},
307 {.lo: 0x1.633e8e5697dc7p-45, .hi: 0x1.527e5e4a1bp-3},
308 {.lo: 0x1.9cf8b2c3c2e78p-46, .hi: 0x1.6574ebe8c1p-3},
309 {.lo: -0x1.5118de59c21e1p-45, .hi: 0x1.6f0128b757p-3},
310 {.lo: 0x1.e0ddb9a631e83p-46, .hi: 0x1.823c16551ap-3},
311 {.lo: -0x1.73d54aae92cd1p-47, .hi: 0x1.8beafeb39p-3},
312 {.lo: 0x1.7f22858a0ff6fp-47, .hi: 0x1.95a5adcf7p-3},
313 {.lo: -0x1.8724350562169p-45, .hi: 0x1.a93ed3c8aep-3},
314 {.lo: -0x1.c358d4eace1aap-47, .hi: 0x1.b31d8575bdp-3},
315 {.lo: -0x1.d4bc4595412b6p-45, .hi: 0x1.bd087383bep-3},
316 {.lo: -0x1.84a7e75b6f6e4p-47, .hi: 0x1.d1037f2656p-3},
317 {.lo: -0x1.aff2af715b035p-45, .hi: 0x1.db13db0d49p-3},
318 {.lo: 0x1.212276041f43p-51, .hi: 0x1.e530effe71p-3},
319 {.lo: -0x1.a211565bb8e11p-51, .hi: 0x1.ef5ade4ddp-3},
320 {.lo: 0x1.bcbecca0cdf3p-46, .hi: 0x1.f991c6cb3bp-3},
321 {.lo: 0x1.89cdb16ed4e91p-48, .hi: 0x1.07138604d58p-2},
322 {.lo: 0x1.7188b163ceae9p-45, .hi: 0x1.0c42d67616p-2},
323 {.lo: -0x1.c210e63a5f01cp-45, .hi: 0x1.1178e8227e8p-2},
324 {.lo: 0x1.b9acdf7a51681p-45, .hi: 0x1.16b5ccbacf8p-2},
325 {.lo: 0x1.ca6ed5147bdb7p-45, .hi: 0x1.1bf99635a68p-2},
326 {.lo: 0x1.c93c1df5bb3b6p-45, .hi: 0x1.269621134d8p-2},
327 {.lo: 0x1.a9cfa4a5004f4p-45, .hi: 0x1.2bef07cdc9p-2},
328 {.lo: -0x1.8e27ad3213cb8p-45, .hi: 0x1.314f1e1d36p-2},
329 {.lo: 0x1.16ecdb0f177c8p-46, .hi: 0x1.36b6776be1p-2},
330 {.lo: 0x1.83b54b606bd5cp-46, .hi: 0x1.3c25277333p-2},
331 {.lo: 0x1.8e436ec90e09dp-47, .hi: 0x1.419b423d5e8p-2},
332 {.lo: -0x1.f27ce0967d675p-45, .hi: 0x1.4718dc271c8p-2},
333 {.lo: -0x1.e20891b0ad8a4p-45, .hi: 0x1.4c9e09e173p-2},
334 {.lo: 0x1.ebe708164c759p-45, .hi: 0x1.522ae0738ap-2},
335 {.lo: 0x1.fadedee5d40efp-46, .hi: 0x1.57bf753c8dp-2},
336 {.lo: -0x1.a0b2a08a465dcp-47, .hi: 0x1.5d5bddf596p-2},
337 {.lo: -0x1.db623e731aep-45, .hi: 0x1.630030b3abp-2},
338 {.lo: 0x1.0a0d32756ebap-45, .hi: 0x1.68ac83e9c68p-2},
339 {.lo: 0x1.721657c222d87p-46, .hi: 0x1.6e60ee6af18p-2},
340 {.lo: 0x1.d8b0949dc60b3p-45, .hi: 0x1.741d876c678p-2},
341 {.lo: 0x1.9ec7d2efd1778p-45, .hi: 0x1.79e26687cf8p-2},
342 {.lo: -0x1.72090c812566ap-45, .hi: 0x1.7fafa3bd818p-2},
343 {.lo: 0x1.fd56f3333778ap-45, .hi: 0x1.85855776dc8p-2},
344 {.lo: -0x1.05ae1e5e7047p-45, .hi: 0x1.8b639a88b3p-2},
345 {.lo: -0x1.766b52ee6307dp-46, .hi: 0x1.914a8635bf8p-2},
346 {.lo: -0x1.52313a502d9fp-46, .hi: 0x1.973a3431358p-2},
347 {.lo: -0x1.6279e10d0c0bp-45, .hi: 0x1.9d32bea15fp-2},
348 {.lo: 0x1.3c6457f9d79f5p-45, .hi: 0x1.a33440224f8p-2},
349 {.lo: 0x1.3c6457f9d79f5p-45, .hi: 0x1.a33440224f8p-2},
350 {.lo: 0x1.e36f2bea77a5dp-46, .hi: 0x1.a93ed3c8ad8p-2},
351 {.lo: -0x1.17cc552774458p-45, .hi: 0x1.af5295248dp-2},
352 {.lo: 0x1.095252d841995p-46, .hi: 0x1.b56fa044628p-2},
353 {.lo: 0x1.7d85bf40a666dp-45, .hi: 0x1.bb9611b80ep-2},
354 {.lo: 0x1.cec807fe8e18p-45, .hi: 0x1.c1c60693fap-2},
355 {.lo: 0x1.cec807fe8e18p-45, .hi: 0x1.c1c60693fap-2},
356 {.lo: -0x1.9b6ddc15249aep-45, .hi: 0x1.c7ff9c74558p-2},
357 {.lo: -0x1.797c33ec7a6bp-47, .hi: 0x1.ce42f180648p-2},
358 {.lo: 0x1.35bafe9a767a8p-45, .hi: 0x1.d490246def8p-2},
359 {.lo: -0x1.ea42d60dc616ap-46, .hi: 0x1.dae75484c98p-2},
360 {.lo: -0x1.326b207322938p-46, .hi: 0x1.e148a1a2728p-2},
361 {.lo: -0x1.326b207322938p-46, .hi: 0x1.e148a1a2728p-2},
362 {.lo: -0x1.465505372bd08p-45, .hi: 0x1.e7b42c3ddbp-2},
363 {.lo: 0x1.f27f45a470251p-45, .hi: 0x1.ee2a156b41p-2},
364 {.lo: 0x1.2cde56f014a8bp-46, .hi: 0x1.f4aa7ee0318p-2},
365 {.lo: 0x1.2cde56f014a8bp-46, .hi: 0x1.f4aa7ee0318p-2},
366 {.lo: 0x1.085fa3c164935p-47, .hi: 0x1.fb358af7a48p-2},
367 {.lo: -0x1.53ba3b1727b1cp-47, .hi: 0x1.00e5ae5b208p-1},
368 {.lo: -0x1.4c45fe79539ep-47, .hi: 0x1.04360be7604p-1},
369 {.lo: -0x1.4c45fe79539ep-47, .hi: 0x1.04360be7604p-1},
370 {.lo: 0x1.6812241edf5fdp-45, .hi: 0x1.078bf0533c4p-1},
371 {.lo: 0x1.f486b887e7e27p-46, .hi: 0x1.0ae76e2d054p-1},
372 {.lo: 0x1.f486b887e7e27p-46, .hi: 0x1.0ae76e2d054p-1},
373 {.lo: 0x1.c299807801742p-46, .hi: 0x1.0e4898611ccp-1},
374 {.lo: -0x1.58647bb9ddcb2p-45, .hi: 0x1.11af823c75cp-1},
375 {.lo: -0x1.58647bb9ddcb2p-45, .hi: 0x1.11af823c75cp-1},
376 {.lo: -0x1.edd97a293ae49p-45, .hi: 0x1.151c3f6f298p-1},
377 {.lo: 0x1.4cc4ef8ab465p-46, .hi: 0x1.188ee40f23cp-1},
378 {.lo: 0x1.4cc4ef8ab465p-46, .hi: 0x1.188ee40f23cp-1},
379 {.lo: 0x1.cacdeed70e667p-51, .hi: 0x1.1c07849ae6p-1},
380 {.lo: -0x1.a7242c9fe81d3p-45, .hi: 0x1.1f8635fc618p-1},
381 {.lo: -0x1.a7242c9fe81d3p-45, .hi: 0x1.1f8635fc618p-1},
382 {.lo: 0x1.2fc066e48667bp-46, .hi: 0x1.230b0d8bebcp-1},
383 {.lo: -0x1.b61f10522625p-47, .hi: 0x1.269621134dcp-1},
384 {.lo: -0x1.b61f10522625p-47, .hi: 0x1.269621134dcp-1},
385 {.lo: 0x1.06d2be797882dp-45, .hi: 0x1.2a2786d0ecp-1},
386 {.lo: -0x1.7a6e507b9dc11p-46, .hi: 0x1.2dbf557b0ep-1},
387 {.lo: -0x1.7a6e507b9dc11p-46, .hi: 0x1.2dbf557b0ep-1},
388 {.lo: -0x1.74e93c5a0ed9cp-45, .hi: 0x1.315da443408p-1},
389 {.lo: -0x1.74e93c5a0ed9cp-45, .hi: 0x1.315da443408p-1},
390 {.lo: 0x1.0b83f9527e6acp-46, .hi: 0x1.35028ad9d8cp-1},
391 {.lo: -0x1.18b7abb5569a4p-45, .hi: 0x1.38ae2171978p-1},
392 {.lo: -0x1.18b7abb5569a4p-45, .hi: 0x1.38ae2171978p-1},
393 {.lo: -0x1.2b7367cfe13c2p-47, .hi: 0x1.3c6080c36cp-1},
394 {.lo: -0x1.2b7367cfe13c2p-47, .hi: 0x1.3c6080c36cp-1},
395 {.lo: -0x1.6ce7930f0c74cp-45, .hi: 0x1.4019c2125ccp-1},
396 {.lo: -0x1.d984f481051f7p-48, .hi: 0x1.43d9ff2f924p-1},
397 {.lo: -0x1.d984f481051f7p-48, .hi: 0x1.43d9ff2f924p-1},
398 {.lo: -0x1.2cb6af94d60aap-45, .hi: 0x1.47a1527e8a4p-1},
399 {.lo: -0x1.2cb6af94d60aap-45, .hi: 0x1.47a1527e8a4p-1},
400 {.lo: 0x1.f7115ed4c541cp-49, .hi: 0x1.4b6fd6f970cp-1},
401 {.lo: 0x1.f7115ed4c541cp-49, .hi: 0x1.4b6fd6f970cp-1},
402 {.lo: -0x1.e6c516d93b8fbp-45, .hi: 0x1.4f45a835a5p-1},
403 {.lo: -0x1.e6c516d93b8fbp-45, .hi: 0x1.4f45a835a5p-1},
404 {.lo: 0x1.5ccc45d257531p-47, .hi: 0x1.5322e268678p-1},
405 {.lo: 0x1.5ccc45d257531p-47, .hi: 0x1.5322e268678p-1},
406 {.lo: 0x1.9980bff3303ddp-47, .hi: 0x1.5707a26bb8cp-1},
407 {.lo: 0x1.9980bff3303ddp-47, .hi: 0x1.5707a26bb8cp-1},
408 {.lo: 0x1.dfa63ac10c9fbp-45, .hi: 0x1.5af405c3648p-1},
409 {.lo: 0x1.dfa63ac10c9fbp-45, .hi: 0x1.5af405c3648p-1},
410 {.lo: 0x1.202380cda46bep-45, .hi: 0x1.5ee82aa2418p-1},
411 {.lo: 0.0, .hi: 0.0},
412};
413
414// Logarithm range reduction - Step 2:
415// r(k) = 2^-16 round(2^16 / (1 + k*2^-14)) for k = -2^6 .. 2^7.
416// Output range:
417// [-0x1.3ffcp-15, 0x1.3e3dp-15]
418// We store S2[i] = 2^16 (r(i - 2^6) - 1).
419alignas(64) const int S2[193] = {
420 0x101, 0xfd, 0xf9, 0xf5, 0xf1, 0xed, 0xe9, 0xe5, 0xe1,
421 0xdd, 0xd9, 0xd5, 0xd1, 0xcd, 0xc9, 0xc5, 0xc1, 0xbd,
422 0xb9, 0xb4, 0xb0, 0xac, 0xa8, 0xa4, 0xa0, 0x9c, 0x98,
423 0x94, 0x90, 0x8c, 0x88, 0x84, 0x80, 0x7c, 0x78, 0x74,
424 0x70, 0x6c, 0x68, 0x64, 0x60, 0x5c, 0x58, 0x54, 0x50,
425 0x4c, 0x48, 0x44, 0x40, 0x3c, 0x38, 0x34, 0x30, 0x2c,
426 0x28, 0x24, 0x20, 0x1c, 0x18, 0x14, 0x10, 0xc, 0x8,
427 0x4, 0x0, -0x4, -0x8, -0xc, -0x10, -0x14, -0x18, -0x1c,
428 -0x20, -0x24, -0x28, -0x2c, -0x30, -0x34, -0x38, -0x3c, -0x40,
429 -0x44, -0x48, -0x4c, -0x50, -0x54, -0x58, -0x5c, -0x60, -0x64,
430 -0x68, -0x6c, -0x70, -0x74, -0x78, -0x7c, -0x80, -0x84, -0x88,
431 -0x8c, -0x90, -0x94, -0x98, -0x9c, -0xa0, -0xa4, -0xa8, -0xac,
432 -0xb0, -0xb4, -0xb7, -0xbb, -0xbf, -0xc3, -0xc7, -0xcb, -0xcf,
433 -0xd3, -0xd7, -0xdb, -0xdf, -0xe3, -0xe7, -0xeb, -0xef, -0xf3,
434 -0xf7, -0xfb, -0xff, -0x103, -0x107, -0x10b, -0x10f, -0x113, -0x117,
435 -0x11b, -0x11f, -0x123, -0x127, -0x12b, -0x12f, -0x133, -0x137, -0x13a,
436 -0x13e, -0x142, -0x146, -0x14a, -0x14e, -0x152, -0x156, -0x15a, -0x15e,
437 -0x162, -0x166, -0x16a, -0x16e, -0x172, -0x176, -0x17a, -0x17e, -0x182,
438 -0x186, -0x18a, -0x18e, -0x192, -0x195, -0x199, -0x19d, -0x1a1, -0x1a5,
439 -0x1a9, -0x1ad, -0x1b1, -0x1b5, -0x1b9, -0x1bd, -0x1c1, -0x1c5, -0x1c9,
440 -0x1cd, -0x1d1, -0x1d5, -0x1d9, -0x1dd, -0x1e0, -0x1e4, -0x1e8, -0x1ec,
441 -0x1f0, -0x1f4, -0x1f8, -0x1fc};
442
443alignas(64) const double R2[193] = {
444 0x1.0101p0, 0x1.00fdp0, 0x1.00f9p0, 0x1.00f5p0, 0x1.00f1p0,
445 0x1.00edp0, 0x1.00e9p0, 0x1.00e5p0, 0x1.00e1p0, 0x1.00ddp0,
446 0x1.00d9p0, 0x1.00d5p0, 0x1.00d1p0, 0x1.00cdp0, 0x1.00c9p0,
447 0x1.00c5p0, 0x1.00c1p0, 0x1.00bdp0, 0x1.00b9p0, 0x1.00b4p0,
448 0x1.00bp0, 0x1.00acp0, 0x1.00a8p0, 0x1.00a4p0, 0x1.00ap0,
449 0x1.009cp0, 0x1.0098p0, 0x1.0094p0, 0x1.009p0, 0x1.008cp0,
450 0x1.0088p0, 0x1.0084p0, 0x1.008p0, 0x1.007cp0, 0x1.0078p0,
451 0x1.0074p0, 0x1.007p0, 0x1.006cp0, 0x1.0068p0, 0x1.0064p0,
452 0x1.006p0, 0x1.005cp0, 0x1.0058p0, 0x1.0054p0, 0x1.005p0,
453 0x1.004cp0, 0x1.0048p0, 0x1.0044p0, 0x1.004p0, 0x1.003cp0,
454 0x1.0038p0, 0x1.0034p0, 0x1.003p0, 0x1.002cp0, 0x1.0028p0,
455 0x1.0024p0, 0x1.002p0, 0x1.001cp0, 0x1.0018p0, 0x1.0014p0,
456 0x1.001p0, 0x1.000cp0, 0x1.0008p0, 0x1.0004p0, 0x1p0,
457 0x1.fff8p-1, 0x1.fffp-1, 0x1.ffe8p-1, 0x1.ffep-1, 0x1.ffd8p-1,
458 0x1.ffdp-1, 0x1.ffc8p-1, 0x1.ffcp-1, 0x1.ffb8p-1, 0x1.ffbp-1,
459 0x1.ffa8p-1, 0x1.ffap-1, 0x1.ff98p-1, 0x1.ff9p-1, 0x1.ff88p-1,
460 0x1.ff8p-1, 0x1.ff78p-1, 0x1.ff7p-1, 0x1.ff68p-1, 0x1.ff6p-1,
461 0x1.ff58p-1, 0x1.ff5p-1, 0x1.ff48p-1, 0x1.ff4p-1, 0x1.ff38p-1,
462 0x1.ff3p-1, 0x1.ff28p-1, 0x1.ff2p-1, 0x1.ff18p-1, 0x1.ff1p-1,
463 0x1.ff08p-1, 0x1.ffp-1, 0x1.fef8p-1, 0x1.fefp-1, 0x1.fee8p-1,
464 0x1.feep-1, 0x1.fed8p-1, 0x1.fedp-1, 0x1.fec8p-1, 0x1.fecp-1,
465 0x1.feb8p-1, 0x1.febp-1, 0x1.fea8p-1, 0x1.feap-1, 0x1.fe98p-1,
466 0x1.fe92p-1, 0x1.fe8ap-1, 0x1.fe82p-1, 0x1.fe7ap-1, 0x1.fe72p-1,
467 0x1.fe6ap-1, 0x1.fe62p-1, 0x1.fe5ap-1, 0x1.fe52p-1, 0x1.fe4ap-1,
468 0x1.fe42p-1, 0x1.fe3ap-1, 0x1.fe32p-1, 0x1.fe2ap-1, 0x1.fe22p-1,
469 0x1.fe1ap-1, 0x1.fe12p-1, 0x1.fe0ap-1, 0x1.fe02p-1, 0x1.fdfap-1,
470 0x1.fdf2p-1, 0x1.fdeap-1, 0x1.fde2p-1, 0x1.fddap-1, 0x1.fdd2p-1,
471 0x1.fdcap-1, 0x1.fdc2p-1, 0x1.fdbap-1, 0x1.fdb2p-1, 0x1.fdaap-1,
472 0x1.fda2p-1, 0x1.fd9ap-1, 0x1.fd92p-1, 0x1.fd8cp-1, 0x1.fd84p-1,
473 0x1.fd7cp-1, 0x1.fd74p-1, 0x1.fd6cp-1, 0x1.fd64p-1, 0x1.fd5cp-1,
474 0x1.fd54p-1, 0x1.fd4cp-1, 0x1.fd44p-1, 0x1.fd3cp-1, 0x1.fd34p-1,
475 0x1.fd2cp-1, 0x1.fd24p-1, 0x1.fd1cp-1, 0x1.fd14p-1, 0x1.fd0cp-1,
476 0x1.fd04p-1, 0x1.fcfcp-1, 0x1.fcf4p-1, 0x1.fcecp-1, 0x1.fce4p-1,
477 0x1.fcdcp-1, 0x1.fcd6p-1, 0x1.fccep-1, 0x1.fcc6p-1, 0x1.fcbep-1,
478 0x1.fcb6p-1, 0x1.fcaep-1, 0x1.fca6p-1, 0x1.fc9ep-1, 0x1.fc96p-1,
479 0x1.fc8ep-1, 0x1.fc86p-1, 0x1.fc7ep-1, 0x1.fc76p-1, 0x1.fc6ep-1,
480 0x1.fc66p-1, 0x1.fc5ep-1, 0x1.fc56p-1, 0x1.fc4ep-1, 0x1.fc46p-1,
481 0x1.fc4p-1, 0x1.fc38p-1, 0x1.fc3p-1, 0x1.fc28p-1, 0x1.fc2p-1,
482 0x1.fc18p-1, 0x1.fc1p-1, 0x1.fc08p-1,
483};
484
485// Logarithm range reduction - Step 3:
486// r(k) = 2^-21 round(2^21 / (1 + k*2^-21)) for k = -80 .. 80.
487// Output range:
488// [-0x1.01928p-22 , 0x1p-22]
489// We store S[i] = 2^21 (r(i - 80) - 1).
490alignas(64) const int S3[161] = {
491 0x50, 0x4f, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x48, 0x47, 0x46,
492 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3b,
493 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30,
494 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25,
495 0x24, 0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a,
496 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0xf,
497 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4,
498 0x3, 0x2, 0x1, 0x0, -0x1, -0x2, -0x3, -0x4, -0x5, -0x6, -0x7,
499 -0x8, -0x9, -0xa, -0xb, -0xc, -0xd, -0xe, -0xf, -0x10, -0x11, -0x12,
500 -0x13, -0x14, -0x15, -0x16, -0x17, -0x18, -0x19, -0x1a, -0x1b, -0x1c, -0x1d,
501 -0x1e, -0x1f, -0x20, -0x21, -0x22, -0x23, -0x24, -0x25, -0x26, -0x27, -0x28,
502 -0x29, -0x2a, -0x2b, -0x2c, -0x2d, -0x2e, -0x2f, -0x30, -0x31, -0x32, -0x33,
503 -0x34, -0x35, -0x36, -0x37, -0x38, -0x39, -0x3a, -0x3b, -0x3c, -0x3d, -0x3e,
504 -0x3f, -0x40, -0x41, -0x42, -0x43, -0x44, -0x45, -0x46, -0x47, -0x48, -0x49,
505 -0x4a, -0x4b, -0x4c, -0x4d, -0x4e, -0x4f, -0x50,
506};
507
508// Logarithm range reduction - Step 4
509// r(k) = 2^-28 round(2^28 / (1 + k*2^-28)) for k = -65 .. 64.
510// Output range:
511// [-0x1.0002143p-29 , 0x1p-29]
512// We store S[i] = 2^28 (r(i - 65) - 1).
513alignas(64) const int S4[130] = {
514 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37,
515 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c,
516 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21,
517 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16,
518 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0xf, 0xe, 0xd, 0xc, 0xb,
519 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0,
520 -0x1, -0x2, -0x3, -0x4, -0x5, -0x6, -0x7, -0x8, -0x9, -0xa, -0xb,
521 -0xc, -0xd, -0xe, -0xf, -0x10, -0x11, -0x12, -0x13, -0x14, -0x15, -0x16,
522 -0x17, -0x18, -0x19, -0x1a, -0x1b, -0x1c, -0x1d, -0x1e, -0x1f, -0x20, -0x21,
523 -0x22, -0x23, -0x24, -0x25, -0x26, -0x27, -0x28, -0x29, -0x2a, -0x2b, -0x2c,
524 -0x2d, -0x2e, -0x2f, -0x30, -0x31, -0x32, -0x33, -0x34, -0x35, -0x36, -0x37,
525 -0x38, -0x39, -0x3a, -0x3b, -0x3c, -0x3d, -0x3e, -0x3f, -0x40,
526};
527
528// Lookup table for exp(m) with m = -104, ..., 89.
529// -104 = floor(log(single precision's min denormal))
530// 89 = ceil(log(single precision's max normal))
531// Table is generated with Sollya as follow:
532// > display = hexadecimal;
533// > for i from -104 to 89 do { D(exp(i)); };
534const double EXP_M1[195] = {
535 0x1.f1e6b68529e33p-151, 0x1.525be4e4e601dp-149, 0x1.cbe0a45f75eb1p-148,
536 0x1.3884e838aea68p-146, 0x1.a8c1f14e2af5dp-145, 0x1.20a717e64a9bdp-143,
537 0x1.8851d84118908p-142, 0x1.0a9bdfb02d240p-140, 0x1.6a5bea046b42ep-139,
538 0x1.ec7f3b269efa8p-138, 0x1.4eafb87eab0f2p-136, 0x1.c6e2d05bbc000p-135,
539 0x1.35208867c2683p-133, 0x1.a425b317eeacdp-132, 0x1.1d8508fa8246ap-130,
540 0x1.840fbc08fdc8ap-129, 0x1.07b7112bc1ffep-127, 0x1.666d0dad2961dp-126,
541 0x1.e726c3f64d0fep-125, 0x1.4b0dc07cabf98p-123, 0x1.c1f2daf3b6a46p-122,
542 0x1.31c5957a47de2p-120, 0x1.9f96445648b9fp-119, 0x1.1a6baeadb4fd1p-117,
543 0x1.7fd974d372e45p-116, 0x1.04da4d1452919p-114, 0x1.62891f06b3450p-113,
544 0x1.e1dd273aa8a4ap-112, 0x1.4775e0840bfddp-110, 0x1.bd109d9d94bdap-109,
545 0x1.2e73f53fba844p-107, 0x1.9b138170d6bfep-106, 0x1.175af0cf60ec5p-104,
546 0x1.7baee1bffa80bp-103, 0x1.02057d1245cebp-101, 0x1.5eafffb34ba31p-100,
547 0x1.dca23bae16424p-99, 0x1.43e7fc88b8056p-97, 0x1.b83bf23a9a9ebp-96,
548 0x1.2b2b8dd05b318p-94, 0x1.969d47321e4ccp-93, 0x1.1452b7723aed2p-91,
549 0x1.778fe2497184cp-90, 0x1.fe7116182e9ccp-89, 0x1.5ae191a99585ap-87,
550 0x1.d775d87da854dp-86, 0x1.4063f8cc8bb98p-84, 0x1.b374b315f87c1p-83,
551 0x1.27ec458c65e3cp-81, 0x1.923372c67a074p-80, 0x1.1152eaeb73c08p-78,
552 0x1.737c5645114b5p-77, 0x1.f8e6c24b5592ep-76, 0x1.571db733a9d61p-74,
553 0x1.d257d547e083fp-73, 0x1.3ce9b9de78f85p-71, 0x1.aebabae3a41b5p-70,
554 0x1.24b6031b49bdap-68, 0x1.8dd5e1bb09d7ep-67, 0x1.0e5b73d1ff53dp-65,
555 0x1.6f741de1748ecp-64, 0x1.f36bd37f42f3ep-63, 0x1.536452ee2f75cp-61,
556 0x1.cd480a1b74820p-60, 0x1.39792499b1a24p-58, 0x1.aa0de4bf35b38p-57,
557 0x1.2188ad6ae3303p-55, 0x1.898471fca6055p-54, 0x1.0b6c3afdde064p-52,
558 0x1.6b7719a59f0e0p-51, 0x1.ee001eed62aa0p-50, 0x1.4fb547c775da8p-48,
559 0x1.c8464f7616468p-47, 0x1.36121e24d3bbap-45, 0x1.a56e0c2ac7f75p-44,
560 0x1.1e642baeb84a0p-42, 0x1.853f01d6d53bap-41, 0x1.0885298767e9ap-39,
561 0x1.67852a7007e42p-38, 0x1.e8a37a45fc32ep-37, 0x1.4c1078fe9228ap-35,
562 0x1.c3527e433fab1p-34, 0x1.32b48bf117da2p-32, 0x1.a0db0d0ddb3ecp-31,
563 0x1.1b48655f37267p-29, 0x1.81056ff2c5772p-28, 0x1.05a628c699fa1p-26,
564 0x1.639e3175a689dp-25, 0x1.e355bbaee85cbp-24, 0x1.4875ca227ec38p-22,
565 0x1.be6c6fdb01612p-21, 0x1.2f6053b981d98p-19, 0x1.9c54c3b43bc8bp-18,
566 0x1.18354238f6764p-16, 0x1.7cd79b5647c9bp-15, 0x1.02cf22526545ap-13,
567 0x1.5fc21041027adp-12, 0x1.de16b9c24a98fp-11, 0x1.44e51f113d4d6p-9,
568 0x1.b993fe00d5376p-8, 0x1.2c155b8213cf4p-6, 0x1.97db0ccceb0afp-5,
569 0x1.152aaa3bf81ccp-3, 0x1.78b56362cef38p-2, 0x1.0000000000000p+0,
570 0x1.5bf0a8b145769p+1, 0x1.d8e64b8d4ddaep+2, 0x1.415e5bf6fb106p+4,
571 0x1.b4c902e273a58p+5, 0x1.28d389970338fp+7, 0x1.936dc5690c08fp+8,
572 0x1.122885aaeddaap+10, 0x1.749ea7d470c6ep+11, 0x1.fa7157c470f82p+12,
573 0x1.5829dcf950560p+14, 0x1.d3c4488ee4f7fp+15, 0x1.3de1654d37c9ap+17,
574 0x1.b00b5916ac955p+18, 0x1.259ac48bf05d7p+20, 0x1.8f0ccafad2a87p+21,
575 0x1.0f2ebd0a80020p+23, 0x1.709348c0ea4f9p+24, 0x1.f4f22091940bdp+25,
576 0x1.546d8f9ed26e1p+27, 0x1.ceb088b68e804p+28, 0x1.3a6e1fd9eecfdp+30,
577 0x1.ab5adb9c43600p+31, 0x1.226af33b1fdc1p+33, 0x1.8ab7fb5475fb7p+34,
578 0x1.0c3d3920962c9p+36, 0x1.6c932696a6b5dp+37, 0x1.ef822f7f6731dp+38,
579 0x1.50bba3796379ap+40, 0x1.c9aae4631c056p+41, 0x1.370470aec28edp+43,
580 0x1.a6b765d8cdf6dp+44, 0x1.1f43fcc4b662cp+46, 0x1.866f34a725782p+47,
581 0x1.0953e2f3a1ef7p+49, 0x1.689e221bc8d5bp+50, 0x1.ea215a1d20d76p+51,
582 0x1.4d13fbb1a001ap+53, 0x1.c4b334617cc67p+54, 0x1.33a43d282a519p+56,
583 0x1.a220d397972ebp+57, 0x1.1c25c88df6862p+59, 0x1.8232558201159p+60,
584 0x1.0672a3c9eb871p+62, 0x1.64b41c6d37832p+63, 0x1.e4cf766fe49bep+64,
585 0x1.49767bc0483e3p+66, 0x1.bfc951eb8bb76p+67, 0x1.304d6aeca254bp+69,
586 0x1.9d97010884251p+70, 0x1.19103e4080b45p+72, 0x1.7e013cd114461p+73,
587 0x1.03996528e074cp+75, 0x1.60d4f6fdac731p+76, 0x1.df8c5af17ba3bp+77,
588 0x1.45e3076d61699p+79, 0x1.baed16a6e0da7p+80, 0x1.2cffdfebde1a1p+82,
589 0x1.9919cabefcb69p+83, 0x1.160345c9953e3p+85, 0x1.79dbc9dc53c66p+86,
590 0x1.00c810d464097p+88, 0x1.5d009394c5c27p+89, 0x1.da57de8f107a8p+90,
591 0x1.425982cf597cdp+92, 0x1.b61e5ca3a5e31p+93, 0x1.29bb825dfcf87p+95,
592 0x1.94a90db0d6fe2p+96, 0x1.12fec759586fdp+98, 0x1.75c1dc469e3afp+99,
593 0x1.fbfd219c43b04p+100, 0x1.5936d44e1a146p+102, 0x1.d531d8a7ee79cp+103,
594 0x1.3ed9d24a2d51bp+105, 0x1.b15cfe5b6e17bp+106, 0x1.268038c2c0e00p+108,
595 0x1.9044a73545d48p+109, 0x1.1002ab6218b38p+111, 0x1.71b3540cbf921p+112,
596 0x1.f6799ea9c414ap+113, 0x1.55779b984f3ebp+115, 0x1.d01a210c44aa4p+116,
597 0x1.3b63da8e91210p+118, 0x1.aca8d6b0116b8p+119, 0x1.234de9e0c74e9p+121,
598 0x1.8bec7503ca477p+122, 0x1.0d0eda9796b90p+124, 0x1.6db0118477245p+125,
599 0x1.f1056dc7bf22dp+126, 0x1.51c2cc3433801p+128, 0x1.cb108ffbec164p+129,
600};
601
602// Lookup table for exp(m * 2^(-7)) with m = 0, ..., 127.
603// Table is generated with Sollya as follow:
604// > display = hexadecimal;
605// > for i from 0 to 127 do { D(exp(i / 128)); };
606const double EXP_M2[128] = {
607 0x1.0000000000000p0, 0x1.0202015600446p0, 0x1.04080ab55de39p0,
608 0x1.06122436410ddp0, 0x1.08205601127edp0, 0x1.0a32a84e9c1f6p0,
609 0x1.0c49236829e8cp0, 0x1.0e63cfa7ab09dp0, 0x1.1082b577d34edp0,
610 0x1.12a5dd543ccc5p0, 0x1.14cd4fc989cd6p0, 0x1.16f9157587069p0,
611 0x1.192937074e0cdp0, 0x1.1b5dbd3f68122p0, 0x1.1d96b0eff0e79p0,
612 0x1.1fd41afcba45ep0, 0x1.2216045b6f5cdp0, 0x1.245c7613b8a9bp0,
613 0x1.26a7793f60164p0, 0x1.28f7170a755fdp0, 0x1.2b4b58b372c79p0,
614 0x1.2da4478b620c7p0, 0x1.3001ecf601af7p0, 0x1.32645269ea829p0,
615 0x1.34cb8170b5835p0, 0x1.373783a722012p0, 0x1.39a862bd3c106p0,
616 0x1.3c1e2876834aap0, 0x1.3e98deaa11dccp0, 0x1.41188f42c3e32p0,
617 0x1.439d443f5f159p0, 0x1.462707b2bac21p0, 0x1.48b5e3c3e8186p0,
618 0x1.4b49e2ae5ac67p0, 0x1.4de30ec211e60p0, 0x1.50817263c13cdp0,
619 0x1.5325180cfacf7p0, 0x1.55ce0a4c58c7cp0, 0x1.587c53c5a7af0p0,
620 0x1.5b2fff3210fd9p0, 0x1.5de9176045ff5p0, 0x1.60a7a734ab0e8p0,
621 0x1.636bb9a983258p0, 0x1.663559cf1bc7cp0, 0x1.690492cbf9433p0,
622 0x1.6bd96fdd034a2p0, 0x1.6eb3fc55b1e76p0, 0x1.719443a03acb9p0,
623 0x1.747a513dbef6ap0, 0x1.776630c678bc1p0, 0x1.7a57ede9ea23ep0,
624 0x1.7d4f946f0ba8dp0, 0x1.804d30347b546p0, 0x1.8350cd30ac390p0,
625 0x1.865a7772164c5p0, 0x1.896a3b1f66a0ep0, 0x1.8c802477b0010p0,
626 0x1.8f9c3fd29beafp0, 0x1.92be99a09bf00p0, 0x1.95e73e6b1b75ep0,
627 0x1.99163ad4b1dccp0, 0x1.9c4b9b995509bp0, 0x1.9f876d8e8c566p0,
628 0x1.a2c9bda3a3e78p0, 0x1.a61298e1e069cp0, 0x1.a9620c6cb3374p0,
629 0x1.acb82581eee54p0, 0x1.b014f179fc3b8p0, 0x1.b3787dc80f95fp0,
630 0x1.b6e2d7fa5eb18p0, 0x1.ba540dba56e56p0, 0x1.bdcc2cccd3c85p0,
631 0x1.c14b431256446p0, 0x1.c4d15e873c193p0, 0x1.c85e8d43f7cd0p0,
632 0x1.cbf2dd7d490f2p0, 0x1.cf8e5d84758a9p0, 0x1.d3311bc7822b4p0,
633 0x1.d6db26d16cd67p0, 0x1.da8c8d4a66969p0, 0x1.de455df80e3c0p0,
634 0x1.e205a7bdab73ep0, 0x1.e5cd799c6a54ep0, 0x1.e99ce2b397649p0,
635 0x1.ed73f240dc142p0, 0x1.f152b7a07bb76p0, 0x1.f539424d90f5ep0,
636 0x1.f927a1e24bb76p0, 0x1.fd1de6182f8c9p0, 0x1.008e0f64294abp1,
637 0x1.02912df5ce72ap1, 0x1.049856cd84339p1, 0x1.06a39207f0a09p1,
638 0x1.08b2e7d2035cfp1, 0x1.0ac6606916501p1, 0x1.0cde041b0e9aep1,
639 0x1.0ef9db467dcf8p1, 0x1.1119ee5ac36b6p1, 0x1.133e45d82e952p1,
640 0x1.1566ea50201d7p1, 0x1.1793e4652cc50p1, 0x1.19c53ccb3fc6bp1,
641 0x1.1bfafc47bda73p1, 0x1.1e352bb1a74adp1, 0x1.2073d3f1bd518p1,
642 0x1.22b6fe02a3b9cp1, 0x1.24feb2f105cb8p1, 0x1.274afbdbba4a6p1,
643 0x1.299be1f3e7f1cp1, 0x1.2bf16e7d2a38cp1, 0x1.2e4baacdb6614p1,
644 0x1.30aaa04e80d05p1, 0x1.330e587b62b28p1, 0x1.3576dce33feadp1,
645 0x1.37e437282d4eep1, 0x1.3a5670ff972edp1, 0x1.3ccd9432682b4p1,
646 0x1.3f49aa9d30590p1, 0x1.41cabe304cb34p1, 0x1.4450d8f00edd4p1,
647 0x1.46dc04f4e5338p1, 0x1.496c4c6b832dap1, 0x1.4c01b9950a111p1,
648 0x1.4e9c56c731f5dp1, 0x1.513c2e6c731d7p1, 0x1.53e14b042f9cap1,
649 0x1.568bb722dd593p1, 0x1.593b7d72305bbp1,
650};
651
652// Lookup table for 2^(k * 2^-6) with k = 0..63.
653// Generated by Sollya with:
654// > display=hexadecimal;
655// > prec = 500;
656// > for i from 0 to 63 do {
657// a = 2^(i * 2^-6);
658// b = round(a, D, RN);
659// c = round(a - b, D, RN);
660// d = round(a - b - c, D, RN);
661// print("{", d, ",", c, ",", b, "},");
662// };
663const fputil::TripleDouble EXP2_MID1[64] = {
664 {.lo: 0, .mid: 0, .hi: 0x1p0},
665 {.lo: -0x1.9085b0a3d74d5p-110, .mid: -0x1.19083535b085dp-56, .hi: 0x1.02c9a3e778061p0},
666 {.lo: 0x1.05ff94f8d257ep-110, .mid: 0x1.d73e2a475b465p-55, .hi: 0x1.059b0d3158574p0},
667 {.lo: 0x1.15820d96b414fp-111, .mid: 0x1.186be4bb284ffp-57, .hi: 0x1.0874518759bc8p0},
668 {.lo: -0x1.67c9bd6ebf74cp-108, .mid: 0x1.8a62e4adc610bp-54, .hi: 0x1.0b5586cf9890fp0},
669 {.lo: -0x1.5aa76994e9ddbp-113, .mid: 0x1.03a1727c57b53p-59, .hi: 0x1.0e3ec32d3d1a2p0},
670 {.lo: 0x1.9d58b988f562dp-109, .mid: -0x1.6c51039449b3ap-54, .hi: 0x1.11301d0125b51p0},
671 {.lo: -0x1.2fe7bb4c76416p-108, .mid: -0x1.32fbf9af1369ep-54, .hi: 0x1.1429aaea92dep0},
672 {.lo: 0x1.4f2406aa13ffp-109, .mid: -0x1.19041b9d78a76p-55, .hi: 0x1.172b83c7d517bp0},
673 {.lo: 0x1.ad36183926ae8p-111, .mid: 0x1.e5b4c7b4968e4p-55, .hi: 0x1.1a35beb6fcb75p0},
674 {.lo: 0x1.ea62d0881b918p-110, .mid: 0x1.e016e00a2643cp-54, .hi: 0x1.1d4873168b9aap0},
675 {.lo: -0x1.781dbc16f1ea4p-111, .mid: 0x1.dc775814a8495p-55, .hi: 0x1.2063b88628cd6p0},
676 {.lo: -0x1.4d89f9af532ep-109, .mid: 0x1.9b07eb6c70573p-54, .hi: 0x1.2387a6e756238p0},
677 {.lo: 0x1.277393a461b77p-110, .mid: 0x1.2bd339940e9d9p-55, .hi: 0x1.26b4565e27cddp0},
678 {.lo: 0x1.de5448560469p-111, .mid: 0x1.612e8afad1255p-55, .hi: 0x1.29e9df51fdee1p0},
679 {.lo: -0x1.ee9d8f8cb9307p-110, .mid: 0x1.0024754db41d5p-54, .hi: 0x1.2d285a6e4030bp0},
680 {.lo: 0x1.7b7b2f09cd0d9p-110, .mid: 0x1.6f46ad23182e4p-55, .hi: 0x1.306fe0a31b715p0},
681 {.lo: -0x1.406a2ea6cfc6bp-108, .mid: 0x1.32721843659a6p-54, .hi: 0x1.33c08b26416ffp0},
682 {.lo: 0x1.87e3e12516bfap-108, .mid: -0x1.63aeabf42eae2p-54, .hi: 0x1.371a7373aa9cbp0},
683 {.lo: 0x1.9b0b1ff17c296p-111, .mid: -0x1.5e436d661f5e3p-56, .hi: 0x1.3a7db34e59ff7p0},
684 {.lo: -0x1.808ba68fa8fb7p-109, .mid: 0x1.ada0911f09ebcp-55, .hi: 0x1.3dea64c123422p0},
685 {.lo: -0x1.32b43eafc6518p-114, .mid: -0x1.ef3691c309278p-58, .hi: 0x1.4160a21f72e2ap0},
686 {.lo: -0x1.0ac312de3d922p-114, .mid: 0x1.89b7a04ef80dp-59, .hi: 0x1.44e086061892dp0},
687 {.lo: 0x1.e1eebae743acp-111, .mid: 0x1.3c1a3b69062fp-56, .hi: 0x1.486a2b5c13cdp0},
688 {.lo: 0x1.c06c7745c2b39p-113, .mid: 0x1.d4397afec42e2p-56, .hi: 0x1.4bfdad5362a27p0},
689 {.lo: -0x1.1aa1fd7b685cdp-112, .mid: -0x1.4b309d25957e3p-54, .hi: 0x1.4f9b2769d2ca7p0},
690 {.lo: 0x1.fa733951f214cp-111, .mid: -0x1.07abe1db13cadp-55, .hi: 0x1.5342b569d4f82p0},
691 {.lo: -0x1.ff86852a613ffp-111, .mid: 0x1.9bb2c011d93adp-54, .hi: 0x1.56f4736b527dap0},
692 {.lo: -0x1.744ee506fdafep-109, .mid: 0x1.6324c054647adp-54, .hi: 0x1.5ab07dd485429p0},
693 {.lo: -0x1.95f9ab75fa7d6p-108, .mid: 0x1.ba6f93080e65ep-54, .hi: 0x1.5e76f15ad2148p0},
694 {.lo: 0x1.5d8e757cfb991p-111, .mid: -0x1.383c17e40b497p-54, .hi: 0x1.6247eb03a5585p0},
695 {.lo: 0x1.4a337f4dc0a3bp-108, .mid: -0x1.bb60987591c34p-54, .hi: 0x1.6623882552225p0},
696 {.lo: 0x1.57d3e3adec175p-108, .mid: -0x1.bdd3413b26456p-54, .hi: 0x1.6a09e667f3bcdp0},
697 {.lo: 0x1.a59f88abbe778p-115, .mid: -0x1.bbe3a683c88abp-57, .hi: 0x1.6dfb23c651a2fp0},
698 {.lo: -0x1.269796953a4c3p-109, .mid: -0x1.16e4786887a99p-55, .hi: 0x1.71f75e8ec5f74p0},
699 {.lo: -0x1.8f8e7fa19e5e8p-108, .mid: -0x1.0245957316dd3p-54, .hi: 0x1.75feb564267c9p0},
700 {.lo: -0x1.4217a932d10d4p-113, .mid: -0x1.41577ee04992fp-55, .hi: 0x1.7a11473eb0187p0},
701 {.lo: 0x1.70a1427f8fcdfp-112, .mid: 0x1.05d02ba15797ep-56, .hi: 0x1.7e2f336cf4e62p0},
702 {.lo: 0x1.0f6ad65cbbac1p-112, .mid: -0x1.d4c1dd41532d8p-54, .hi: 0x1.82589994cce13p0},
703 {.lo: -0x1.f16f65181d921p-109, .mid: -0x1.fc6f89bd4f6bap-54, .hi: 0x1.868d99b4492edp0},
704 {.lo: -0x1.30644a7836333p-110, .mid: 0x1.6e9f156864b27p-54, .hi: 0x1.8ace5422aa0dbp0},
705 {.lo: 0x1.3bf26d2b85163p-114, .mid: 0x1.5cc13a2e3976cp-55, .hi: 0x1.8f1ae99157736p0},
706 {.lo: 0x1.697e257ac0db2p-111, .mid: -0x1.75fc781b57ebcp-57, .hi: 0x1.93737b0cdc5e5p0},
707 {.lo: 0x1.7edb9d7144b6fp-108, .mid: -0x1.d185b7c1b85d1p-54, .hi: 0x1.97d829fde4e5p0},
708 {.lo: 0x1.6376b7943085cp-110, .mid: 0x1.c7c46b071f2bep-56, .hi: 0x1.9c49182a3f09p0},
709 {.lo: 0x1.354084551b4fbp-109, .mid: -0x1.359495d1cd533p-54, .hi: 0x1.a0c667b5de565p0},
710 {.lo: -0x1.bfd7adfd63f48p-111, .mid: -0x1.d2f6edb8d41e1p-54, .hi: 0x1.a5503b23e255dp0},
711 {.lo: 0x1.8b16ae39e8cb9p-109, .mid: 0x1.0fac90ef7fd31p-54, .hi: 0x1.a9e6b5579fdbfp0},
712 {.lo: 0x1.a7fbc3ae675eap-108, .mid: 0x1.7a1cd345dcc81p-54, .hi: 0x1.ae89f995ad3adp0},
713 {.lo: 0x1.2babc0edda4d9p-111, .mid: -0x1.2805e3084d708p-57, .hi: 0x1.b33a2b84f15fbp0},
714 {.lo: 0x1.aa64481e1ab72p-111, .mid: -0x1.5584f7e54ac3bp-56, .hi: 0x1.b7f76f2fb5e47p0},
715 {.lo: 0x1.9a164050e1258p-109, .mid: 0x1.23dd07a2d9e84p-55, .hi: 0x1.bcc1e904bc1d2p0},
716 {.lo: 0x1.99e51125928dap-110, .mid: 0x1.11065895048ddp-55, .hi: 0x1.c199bdd85529cp0},
717 {.lo: -0x1.fc44c329d5cb2p-109, .mid: 0x1.2884dff483cadp-54, .hi: 0x1.c67f12e57d14bp0},
718 {.lo: 0x1.d8765566b032ep-110, .mid: 0x1.503cbd1e949dbp-56, .hi: 0x1.cb720dcef9069p0},
719 {.lo: -0x1.e7044039da0f6p-108, .mid: -0x1.cbc3743797a9cp-54, .hi: 0x1.d072d4a07897cp0},
720 {.lo: -0x1.ab053b05531fcp-111, .mid: 0x1.2ed02d75b3707p-55, .hi: 0x1.d5818dcfba487p0},
721 {.lo: 0x1.7f6246f0ec615p-108, .mid: 0x1.c2300696db532p-54, .hi: 0x1.da9e603db3285p0},
722 {.lo: 0x1.b7225a944efd6p-108, .mid: -0x1.1a5cd4f184b5cp-54, .hi: 0x1.dfc97337b9b5fp0},
723 {.lo: 0x1.1e92cb3c2d278p-109, .mid: 0x1.39e8980a9cc8fp-55, .hi: 0x1.e502ee78b3ff6p0},
724 {.lo: -0x1.fc0f242bbf3dep-109, .mid: -0x1.e9c23179c2893p-54, .hi: 0x1.ea4afa2a490dap0},
725 {.lo: 0x1.f6dd5d229ff69p-108, .mid: 0x1.dc7f486a4b6bp-54, .hi: 0x1.efa1bee615a27p0},
726 {.lo: -0x1.4019bffc80ef3p-110, .mid: 0x1.9d3e12dd8a18bp-54, .hi: 0x1.f50765b6e454p0},
727 {.lo: 0x1.dc060c36f7651p-112, .mid: 0x1.74853f3a5931ep-55, .hi: 0x1.fa7c1819e90d8p0},
728};
729
730// Lookup table for 2^(k * 2^-12) with k = 0..63.
731// Generated by Sollya with:
732// > display=hexadecimal;
733// > prec = 500;
734// > for i from 0 to 63 do {
735// a = 2^(i * 2^-12);
736// b = round(a, D, RN);
737// c = round(a - b, D, RN);
738// d = round(a - b - c, D, RN);
739// print("{", d, ",", c, ",", b, "},");
740// };
741const fputil::TripleDouble EXP2_MID2[64] = {
742 {.lo: 0, .mid: 0, .hi: 0x1p0},
743 {.lo: 0x1.39726694630e3p-108, .mid: 0x1.ae8e38c59c72ap-54, .hi: 0x1.000b175effdc7p0},
744 {.lo: 0x1.e5e06ddd31156p-112, .mid: -0x1.7b5d0d58ea8f4p-58, .hi: 0x1.00162f3904052p0},
745 {.lo: 0x1.5a0768b51f609p-111, .mid: 0x1.4115cb6b16a8ep-54, .hi: 0x1.0021478e11ce6p0},
746 {.lo: 0x1.d008403605217p-111, .mid: -0x1.d7c96f201bb2fp-55, .hi: 0x1.002c605e2e8cfp0},
747 {.lo: 0x1.89bc16f765708p-109, .mid: 0x1.84711d4c35e9fp-54, .hi: 0x1.003779a95f959p0},
748 {.lo: -0x1.4535b7f8c1e2dp-109, .mid: -0x1.0484245243777p-55, .hi: 0x1.0042936faa3d8p0},
749 {.lo: -0x1.8ba92f6b25456p-108, .mid: -0x1.4b237da2025f9p-54, .hi: 0x1.004dadb113dap0},
750 {.lo: -0x1.30c72e81f4294p-113, .mid: -0x1.5e00e62d6b30dp-56, .hi: 0x1.0058c86da1c0ap0},
751 {.lo: -0x1.34a5384e6f0b9p-110, .mid: 0x1.a1d6cedbb9481p-54, .hi: 0x1.0063e3a559473p0},
752 {.lo: 0x1.f8d0580865d2ep-108, .mid: -0x1.4acf197a00142p-54, .hi: 0x1.006eff583fc3dp0},
753 {.lo: -0x1.002bcb3ae9a99p-111, .mid: -0x1.eaf2ea42391a5p-57, .hi: 0x1.007a1b865a8cap0},
754 {.lo: 0x1.c3c5aedee9851p-111, .mid: 0x1.da93f90835f75p-56, .hi: 0x1.0085382faef83p0},
755 {.lo: 0x1.7217851d1ec6ep-109, .mid: -0x1.6a79084ab093cp-55, .hi: 0x1.00905554425d4p0},
756 {.lo: -0x1.80cbca335a7c3p-110, .mid: 0x1.86364f8fbe8f8p-54, .hi: 0x1.009b72f41a12bp0},
757 {.lo: -0x1.706bd4eb22595p-110, .mid: -0x1.82e8e14e3110ep-55, .hi: 0x1.00a6910f3b6fdp0},
758 {.lo: -0x1.b55dd523f3c08p-111, .mid: -0x1.4f6b2a7609f71p-55, .hi: 0x1.00b1afa5abcbfp0},
759 {.lo: 0x1.90a1e207cced1p-110, .mid: -0x1.e1a258ea8f71bp-56, .hi: 0x1.00bcceb7707ecp0},
760 {.lo: 0x1.78d0472db37c5p-110, .mid: 0x1.4362ca5bc26f1p-56, .hi: 0x1.00c7ee448ee02p0},
761 {.lo: -0x1.bcd4db3cb52fep-109, .mid: 0x1.095a56c919d02p-54, .hi: 0x1.00d30e4d0c483p0},
762 {.lo: -0x1.cf1b131575ec2p-112, .mid: -0x1.406ac4e81a645p-57, .hi: 0x1.00de2ed0ee0f5p0},
763 {.lo: -0x1.6aaa1fa7ff913p-112, .mid: 0x1.b5a6902767e09p-54, .hi: 0x1.00e94fd0398ep0},
764 {.lo: 0x1.68f236dff3218p-110, .mid: -0x1.91b2060859321p-54, .hi: 0x1.00f4714af41d3p0},
765 {.lo: -0x1.e8bb58067e60ap-109, .mid: 0x1.427068ab22306p-55, .hi: 0x1.00ff93412315cp0},
766 {.lo: 0x1.d4cd5e1d71fdfp-108, .mid: 0x1.c1d0660524e08p-54, .hi: 0x1.010ab5b2cbd11p0},
767 {.lo: 0x1.e4ecf350ebe88p-108, .mid: -0x1.e7bdfb3204be8p-54, .hi: 0x1.0115d89ff3a8bp0},
768 {.lo: 0x1.6a2aa2c89c4f8p-109, .mid: 0x1.843aa8b9cbbc6p-55, .hi: 0x1.0120fc089ff63p0},
769 {.lo: 0x1.1ca368a20ed05p-110, .mid: -0x1.34104ee7edae9p-56, .hi: 0x1.012c1fecd613bp0},
770 {.lo: 0x1.edb1095d925cfp-114, .mid: -0x1.2b6aeb6176892p-56, .hi: 0x1.0137444c9b5b5p0},
771 {.lo: -0x1.488c78eded75fp-111, .mid: 0x1.a8cd33b8a1bb3p-56, .hi: 0x1.01426927f5278p0},
772 {.lo: -0x1.7480f5ea1b3c9p-113, .mid: 0x1.2edc08e5da99ap-56, .hi: 0x1.014d8e7ee8d2fp0},
773 {.lo: -0x1.ae45989a04dd5p-111, .mid: 0x1.57ba2dc7e0c73p-55, .hi: 0x1.0158b4517bb88p0},
774 {.lo: 0x1.bf48007d80987p-109, .mid: 0x1.b61299ab8cdb7p-54, .hi: 0x1.0163da9fb3335p0},
775 {.lo: 0x1.1aa91a059292cp-109, .mid: -0x1.90565902c5f44p-54, .hi: 0x1.016f0169949edp0},
776 {.lo: 0x1.b6663292855f5p-110, .mid: 0x1.70fc41c5c2d53p-55, .hi: 0x1.017a28af25567p0},
777 {.lo: 0x1.e7fbca6793d94p-108, .mid: 0x1.4b9a6e145d76cp-54, .hi: 0x1.018550706ab62p0},
778 {.lo: -0x1.5b9f5c7de3b93p-110, .mid: -0x1.008eff5142bf9p-56, .hi: 0x1.019078ad6a19fp0},
779 {.lo: 0x1.4638bf2f6acabp-110, .mid: -0x1.77669f033c7dep-54, .hi: 0x1.019ba16628de2p0},
780 {.lo: -0x1.ab237b9a069c5p-109, .mid: -0x1.09bb78eeead0ap-54, .hi: 0x1.01a6ca9aac5f3p0},
781 {.lo: 0x1.3ab358be97cefp-108, .mid: 0x1.371231477ece5p-54, .hi: 0x1.01b1f44af9f9ep0},
782 {.lo: -0x1.4027b2294bb64p-110, .mid: 0x1.5e7626621eb5bp-56, .hi: 0x1.01bd1e77170b4p0},
783 {.lo: 0x1.656394426c99p-111, .mid: -0x1.bc72b100828a5p-54, .hi: 0x1.01c8491f08f08p0},
784 {.lo: 0x1.bf9785189bdd8p-111, .mid: -0x1.ce39cbbab8bbep-57, .hi: 0x1.01d37442d507p0},
785 {.lo: 0x1.7c12f86114fe3p-109, .mid: 0x1.16996709da2e2p-55, .hi: 0x1.01de9fe280ac8p0},
786 {.lo: -0x1.653d5d24b5d28p-109, .mid: -0x1.c11f5239bf535p-55, .hi: 0x1.01e9cbfe113efp0},
787 {.lo: 0x1.04a0cdc1d86d7p-109, .mid: 0x1.e1d4eb5edc6b3p-55, .hi: 0x1.01f4f8958c1c6p0},
788 {.lo: 0x1.c678c46149782p-109, .mid: -0x1.afb99946ee3fp-54, .hi: 0x1.020025a8f6a35p0},
789 {.lo: 0x1.48524e1e9df7p-108, .mid: -0x1.8f06d8a148a32p-54, .hi: 0x1.020b533856324p0},
790 {.lo: 0x1.9953ea727ff0bp-109, .mid: -0x1.2bf310fc54eb6p-55, .hi: 0x1.02168143b0281p0},
791 {.lo: -0x1.ccfbbec22d28ep-108, .mid: -0x1.c95a035eb4175p-54, .hi: 0x1.0221afcb09e3ep0},
792 {.lo: 0x1.9e2bb6e181de1p-108, .mid: -0x1.491793e46834dp-54, .hi: 0x1.022cdece68c4fp0},
793 {.lo: 0x1.f17609ae29308p-110, .mid: -0x1.3e8d0d9c49091p-56, .hi: 0x1.02380e4dd22adp0},
794 {.lo: -0x1.c7dc2c476bfb8p-110, .mid: -0x1.314aa16278aa3p-54, .hi: 0x1.02433e494b755p0},
795 {.lo: -0x1.fab994971d4a3p-109, .mid: 0x1.48daf888e9651p-55, .hi: 0x1.024e6ec0da046p0},
796 {.lo: 0x1.848b62cbdd0afp-109, .mid: 0x1.56dc8046821f4p-55, .hi: 0x1.02599fb483385p0},
797 {.lo: -0x1.bf603ba715d0cp-109, .mid: 0x1.45b42356b9d47p-54, .hi: 0x1.0264d1244c719p0},
798 {.lo: 0x1.89434e751e1aap-110, .mid: -0x1.082ef51b61d7ep-56, .hi: 0x1.027003103b10ep0},
799 {.lo: -0x1.03b54fd64e8acp-110, .mid: 0x1.2106ed0920a34p-56, .hi: 0x1.027b357854772p0},
800 {.lo: 0x1.7785ea0acc486p-109, .mid: -0x1.fd4cf26ea5d0fp-54, .hi: 0x1.0286685c9e059p0},
801 {.lo: -0x1.ce447fdb35ff9p-109, .mid: -0x1.09f8775e78084p-54, .hi: 0x1.02919bbd1d1d8p0},
802 {.lo: 0x1.5b884aab5642ap-112, .mid: 0x1.64cbba902ca27p-58, .hi: 0x1.029ccf99d720ap0},
803 {.lo: -0x1.cfb3e46d7c1cp-108, .mid: 0x1.4383ef231d207p-54, .hi: 0x1.02a803f2d170dp0},
804 {.lo: -0x1.0d40cee4b81afp-112, .mid: 0x1.4a47a505b3a47p-54, .hi: 0x1.02b338c811703p0},
805 {.lo: 0x1.6ae7d36d7c1f7p-109, .mid: 0x1.e47120223467fp-54, .hi: 0x1.02be6e199c811p0},
806};
807
808} // namespace LIBC_NAMESPACE
809

source code of libc/src/math/generic/common_constants.cpp