@series-inc/rundot-kinetix 0.0.0-bootstrap.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -0
- package/authoring.d.ts +30 -0
- package/index.d.ts +221 -0
- package/native/component_runtime.cpp +341 -0
- package/native/component_runtime.hpp +112 -0
- package/native/deterministic_math.cpp +594 -0
- package/native/deterministic_math.hpp +21 -0
- package/native/kinetix-f64-native-profile.cpp +406 -0
- package/native/kinetix-f64-native-profile.hpp +5 -0
- package/native/kinetix-fixed1000-native-profile.cpp +777 -0
- package/native/kinetix-fixed1000-native-profile.hpp +58 -0
- package/native/kinetix-fixed1000-physics.cpp +887 -0
- package/native/kinetix-fixed1000-physics.hpp +28 -0
- package/native/kinetix-installed-f64-renderer.cpp +344 -0
- package/native/kinetix-installed-f64-renderer.hpp +35 -0
- package/native/kinetix-installed-f64-runtime.cpp +1085 -0
- package/native/kinetix-installed-f64-runtime.hpp +141 -0
- package/native/kinetix-installed-fixed1000-data.hpp +77 -0
- package/native/kinetix-native-main.cpp +37 -0
- package/native/kinetix-native-runtime.cpp +20 -0
- package/native/kinetix-native-runtime.hpp +25 -0
- package/native/kinetix-render-projection.cpp +20 -0
- package/native/kinetix-render-projection.hpp +14 -0
- package/package.json +65 -0
- package/runtime.d.ts +76 -0
- package/scripts/build-native.mjs +67 -0
- package/scripts/emit-product-digests.mjs +33 -0
- package/scripts/preflight.mjs +76 -0
- package/src/index.mjs +57 -0
- package/src/kinetix-authoring.mjs +69 -0
- package/src/kinetix-baker.mjs +587 -0
- package/src/kinetix-deterministic-math.mjs +1044 -0
- package/src/kinetix-fixed1000-runtime-adapter.mjs +33 -0
- package/src/kinetix-fixed1000-runtime.mjs +954 -0
- package/src/kinetix-installed-f64-reference.mjs +157 -0
- package/src/kinetix-installed-f64-render-frames.mjs +53 -0
- package/src/kinetix-installed-f64-renderer.mjs +240 -0
- package/src/kinetix-installed-f64-runtime-adapter.mjs +68 -0
- package/src/kinetix-installed-f64-runtime.mjs +607 -0
- package/src/kinetix-installed-mechanics.mjs +377 -0
- package/src/kinetix-installed-systems.mjs +181 -0
- package/src/kinetix-native-product.mjs +72 -0
- package/src/kinetix-product-contract.mjs +121 -0
- package/src/kinetix-project-compiler.mjs +1017 -0
- package/src/kinetix-render-projection.mjs +28 -0
- package/src/kinetix-runtime-adapter-utils.mjs +168 -0
- package/src/kinetix-runtime-contract.mjs +54 -0
- package/src/kinetix-session-config.mjs +170 -0
- package/src/kinetix-source-snapshot.mjs +24 -0
- package/src/kinetix-survival-runtime-adapter.mjs +305 -0
- package/src/kinetix-survival-runtime.generated.mjs +1 -0
- package/src/kinetix-world-kernel.mjs +580 -0
- package/src/kinetix-world-runtime.mjs +171 -0
- package/src/runtime.mjs +14 -0
- package/src/shared/f64-bits.mjs +14 -0
- package/src/shared/kinetix-envelope-v1.mjs +589 -0
- package/src/shared/render-records-v1.mjs +168 -0
- package/src/shared/sha256.mjs +73 -0
|
@@ -0,0 +1,1044 @@
|
|
|
1
|
+
// Deterministic Math shim — the platform math contract for the console-native
|
|
2
|
+
// R3F lab (sim-driven parity phase 3+).
|
|
3
|
+
//
|
|
4
|
+
// JS engines agree bitwise on IEEE-754 arithmetic (+ - * / sqrt fma-free) but
|
|
5
|
+
// NOT on Math transcendentals: measured on 2026-07-06, Node 24 (V8 13.x) and
|
|
6
|
+
// Chromium 148 (V8 14.x) differ bitwise on sin, cos, tan, log, log10, asin,
|
|
7
|
+
// acos, sinh, cosh, tanh, expm1 — and JavaScriptCore differs again. Any
|
|
8
|
+
// game value that flows through these into vertex buffers or uniforms breaks
|
|
9
|
+
// bit-exact stream parity across hosts.
|
|
10
|
+
//
|
|
11
|
+
// Fix: replace the differing functions with fdlibm-style implementations
|
|
12
|
+
// built ONLY from operations that are deterministic across engines (IEEE
|
|
13
|
+
// arithmetic, sqrt, bit manipulation via typed arrays, and Math.pow — the
|
|
14
|
+
// sole remaining native transcendental, verified bit-identical across V8
|
|
15
|
+
// 13/14 and JavaScriptCore on 2026-07-09; log2/hypot/cbrt failed that JSC
|
|
16
|
+
// battery and are shimmed below). Accuracy stays within ~1-2 ulp of
|
|
17
|
+
// correctly-rounded; determinism is exact because every host runs this code.
|
|
18
|
+
//
|
|
19
|
+
// Single source of truth: the implementation lives in DETERMINISTIC_MATH_SOURCE
|
|
20
|
+
// (an installable IIFE string) so the browser capture harness can inject it
|
|
21
|
+
// via addInitScript and the headless host can eval the identical bytes.
|
|
22
|
+
|
|
23
|
+
export const DETERMINISTIC_MATH_SOURCE = `(() => {
|
|
24
|
+
if (globalThis.__deterministicMathInstalled) return;
|
|
25
|
+
globalThis.__deterministicMathInstalled = true;
|
|
26
|
+
|
|
27
|
+
const f64 = new Float64Array(1);
|
|
28
|
+
const u32 = new Uint32Array(f64.buffer);
|
|
29
|
+
// Little-endian assumed (x86_64/arm64); index 1 = high word.
|
|
30
|
+
const HI = (x) => { f64[0] = x; return u32[1] | 0; };
|
|
31
|
+
const LO = (x) => { f64[0] = x; return u32[0] | 0; };
|
|
32
|
+
const fromWords = (hi, lo) => { u32[1] = hi >>> 0; u32[0] = lo >>> 0; return f64[0]; };
|
|
33
|
+
const setHi = (x, hi) => { f64[0] = x; u32[1] = hi >>> 0; return f64[0]; };
|
|
34
|
+
const setLo = (x, lo) => { f64[0] = x; u32[0] = lo >>> 0; return f64[0]; };
|
|
35
|
+
|
|
36
|
+
const abs = Math.abs, sqrt = Math.sqrt, floor = Math.floor;
|
|
37
|
+
|
|
38
|
+
const two1023 = 8.98846567431157953865e+307;
|
|
39
|
+
function scalbn2(x, n) {
|
|
40
|
+
let hx = HI(x), lx = LO(x);
|
|
41
|
+
let k = (hx & 0x7ff00000) >> 20;
|
|
42
|
+
if (k === 0) {
|
|
43
|
+
if ((lx | (hx & 0x7fffffff)) === 0) return x;
|
|
44
|
+
x *= 18014398509481984.0;
|
|
45
|
+
hx = HI(x);
|
|
46
|
+
k = ((hx & 0x7ff00000) >> 20) - 54;
|
|
47
|
+
if (n < -50000) return 1e-300 * x;
|
|
48
|
+
}
|
|
49
|
+
if (k === 0x7ff) return x + x;
|
|
50
|
+
k = k + n;
|
|
51
|
+
if (k > 0x7fe) return 1e300 * (x > 0 ? 1e300 : -1e300);
|
|
52
|
+
if (k > 0) return setHi(x, (hx & 0x800fffff) | (k << 20));
|
|
53
|
+
if (k <= -54) {
|
|
54
|
+
if (n > 50000) return 1e300 * (x > 0 ? 1e300 : -1e300);
|
|
55
|
+
return 1e-300 * (x > 0 ? 1e-300 : -1e-300);
|
|
56
|
+
}
|
|
57
|
+
k += 54;
|
|
58
|
+
x = setHi(x, (hx & 0x800fffff) | (k << 20));
|
|
59
|
+
return x * 5.55112312578270211816e-17; // 2^-54
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ---- __kernel_sin / __kernel_cos / __kernel_tan (fdlibm) ----------------
|
|
63
|
+
const S1 = -1.66666666666666324348e-01, S2 = 8.33333333332248946124e-03,
|
|
64
|
+
S3 = -1.98412698298579493134e-04, S4 = 2.75573137070700676789e-06,
|
|
65
|
+
S5 = -2.50507602534068634195e-08, S6 = 1.58969099521155010221e-10;
|
|
66
|
+
function kernelSin(x, y, iy) {
|
|
67
|
+
const z = x * x;
|
|
68
|
+
const v = z * x;
|
|
69
|
+
const r = S2 + z * (S3 + z * (S4 + z * (S5 + z * S6)));
|
|
70
|
+
if (iy === 0) return x + v * (S1 + z * r);
|
|
71
|
+
return x - ((z * (0.5 * y - v * r) - y) - v * S1);
|
|
72
|
+
}
|
|
73
|
+
const C1 = 4.16666666666666019037e-02, C2 = -1.38888888888741095749e-03,
|
|
74
|
+
C3 = 2.48015872894767294178e-05, C4 = -2.75573143513906633035e-07,
|
|
75
|
+
C5 = 2.08757232129817482790e-09, C6 = -1.13596475577881948265e-11;
|
|
76
|
+
function kernelCos(x, y) {
|
|
77
|
+
const z = x * x;
|
|
78
|
+
const r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6)))));
|
|
79
|
+
const hz = 0.5 * z;
|
|
80
|
+
const w = 1.0 - hz;
|
|
81
|
+
return w + (((1.0 - w) - hz) + (z * r - x * y));
|
|
82
|
+
}
|
|
83
|
+
const T = [
|
|
84
|
+
3.33333333333334091986e-01, 1.33333333333201242699e-01, 5.39682539762260521377e-02,
|
|
85
|
+
2.18694882948595424599e-02, 8.86323982359930005737e-03, 3.59207910759131235356e-03,
|
|
86
|
+
1.45620945432529025516e-03, 5.88041240820264096874e-04, 2.46463134818469906812e-04,
|
|
87
|
+
7.81794442939557092300e-05, 7.14072491382608190305e-05, -1.85586374855275456654e-05,
|
|
88
|
+
2.59073051863633712884e-05,
|
|
89
|
+
];
|
|
90
|
+
const pio4 = 7.85398163397448278999e-01, pio4lo = 3.06161699786838301793e-17;
|
|
91
|
+
function kernelTan(x, y, iy) {
|
|
92
|
+
let z, r, v, w, s;
|
|
93
|
+
const hx = HI(x);
|
|
94
|
+
const ix = hx & 0x7fffffff;
|
|
95
|
+
if (ix >= 0x3FE59428) { // |x| >= 0.6744
|
|
96
|
+
if (hx < 0) { x = -x; y = -y; }
|
|
97
|
+
z = pio4 - x;
|
|
98
|
+
w = pio4lo - y;
|
|
99
|
+
x = z + w; y = 0.0;
|
|
100
|
+
}
|
|
101
|
+
z = x * x;
|
|
102
|
+
w = z * z;
|
|
103
|
+
r = T[1] + w * (T[3] + w * (T[5] + w * (T[7] + w * (T[9] + w * T[11]))));
|
|
104
|
+
v = z * (T[2] + w * (T[4] + w * (T[6] + w * (T[8] + w * (T[10] + w * T[12])))));
|
|
105
|
+
s = z * x;
|
|
106
|
+
r = y + z * (s * (r + v) + y);
|
|
107
|
+
r += T[0] * s;
|
|
108
|
+
w = x + r;
|
|
109
|
+
if (ix >= 0x3FE59428) {
|
|
110
|
+
v = iy;
|
|
111
|
+
return (1 - ((hx >> 30) & 2)) * (v - 2.0 * (x - (w * w / (w + v) - r)));
|
|
112
|
+
}
|
|
113
|
+
if (iy === 1) return w;
|
|
114
|
+
// compute -1/(x+r) accurately
|
|
115
|
+
z = w;
|
|
116
|
+
z = setLo(z, 0);
|
|
117
|
+
v = r - (z - x);
|
|
118
|
+
let t = -1.0 / w;
|
|
119
|
+
let a = t;
|
|
120
|
+
a = setLo(a, 0);
|
|
121
|
+
s = 1.0 + a * z;
|
|
122
|
+
return a + t * (s + a * v);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ---- __rem_pio2 (fdlibm, incl. Payne-Hanek for large args) ---------------
|
|
126
|
+
const twoOverPi = [
|
|
127
|
+
0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 0x95993C, 0x439041,
|
|
128
|
+
0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C,
|
|
129
|
+
0xFE1DEB, 0x1CB129, 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41,
|
|
130
|
+
0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, 0x97FFDE, 0x05980F,
|
|
131
|
+
0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D,
|
|
132
|
+
0x7527BA, 0xC7EBE5, 0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08,
|
|
133
|
+
0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, 0x91615E, 0xE61B08,
|
|
134
|
+
0x659985, 0x5F14A0, 0x68408D, 0xFFD880, 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9,
|
|
135
|
+
0x60E27B, 0xC08C6B,
|
|
136
|
+
];
|
|
137
|
+
const PIo2 = [
|
|
138
|
+
1.57079625129699707031e+00, 7.54978941586159635335e-08, 5.39030252995776476554e-15,
|
|
139
|
+
3.28200341580791294123e-22, 1.27065575308067607349e-29, 1.22933308981111328932e-36,
|
|
140
|
+
2.73370053816464559624e-44, 2.16741683877804819444e-51,
|
|
141
|
+
];
|
|
142
|
+
const two24 = 1.67772160000000000000e+07, twon24 = 5.96046447753906250000e-08;
|
|
143
|
+
function kernelRemPio2(x, y, e0, nx) {
|
|
144
|
+
// prec = 2 (double), jk = 4
|
|
145
|
+
const jk = 4, jp = 4;
|
|
146
|
+
let jx = nx - 1;
|
|
147
|
+
let jv = ((e0 - 3) / 24) | 0; if (jv < 0) jv = 0;
|
|
148
|
+
let q0 = e0 - 24 * (jv + 1);
|
|
149
|
+
const f = new Array(20).fill(0);
|
|
150
|
+
const q = new Array(20).fill(0);
|
|
151
|
+
const iq = new Array(20).fill(0);
|
|
152
|
+
const fw0 = new Array(20).fill(0);
|
|
153
|
+
let i, j, k, m, n, ih, z, fw, carry;
|
|
154
|
+
for (i = 0, j = jv - jx; i <= jx + jk; i++, j++) f[i] = j < 0 ? 0 : twoOverPi[j];
|
|
155
|
+
for (i = 0; i <= jk; i++) {
|
|
156
|
+
fw = 0;
|
|
157
|
+
for (j = 0; j <= jx; j++) fw += x[j] * f[jx + i - j];
|
|
158
|
+
q[i] = fw;
|
|
159
|
+
}
|
|
160
|
+
let jz = jk;
|
|
161
|
+
let recomputeNeeded = true;
|
|
162
|
+
while (recomputeNeeded) {
|
|
163
|
+
recomputeNeeded = false;
|
|
164
|
+
// distill q[] into iq[] reversingly
|
|
165
|
+
for (i = 0, j = jz, z = q[jz]; j > 0; i++, j--) {
|
|
166
|
+
fw = Math.floor(twon24 * z);
|
|
167
|
+
iq[i] = (z - two24 * fw) | 0;
|
|
168
|
+
z = q[j - 1] + fw;
|
|
169
|
+
}
|
|
170
|
+
z = scalbn2(z, q0);
|
|
171
|
+
z -= 8.0 * floor(z * 0.125);
|
|
172
|
+
n = z | 0;
|
|
173
|
+
z -= n;
|
|
174
|
+
ih = 0;
|
|
175
|
+
if (q0 > 0) {
|
|
176
|
+
i = (iq[jz - 1] >> (24 - q0));
|
|
177
|
+
n += i;
|
|
178
|
+
iq[jz - 1] -= i << (24 - q0);
|
|
179
|
+
ih = iq[jz - 1] >> (23 - q0);
|
|
180
|
+
} else if (q0 === 0) ih = iq[jz - 1] >> 23;
|
|
181
|
+
else if (z >= 0.5) ih = 2;
|
|
182
|
+
if (ih > 0) {
|
|
183
|
+
n += 1; carry = 0;
|
|
184
|
+
for (i = 0; i < jz; i++) {
|
|
185
|
+
j = iq[i];
|
|
186
|
+
if (carry === 0) {
|
|
187
|
+
if (j !== 0) { carry = 1; iq[i] = 0x1000000 - j; }
|
|
188
|
+
} else iq[i] = 0xffffff - j;
|
|
189
|
+
}
|
|
190
|
+
if (q0 > 0) {
|
|
191
|
+
switch (q0) {
|
|
192
|
+
case 1: iq[jz - 1] &= 0x7fffff; break;
|
|
193
|
+
case 2: iq[jz - 1] &= 0x3fffff; break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (ih === 2) {
|
|
197
|
+
z = 1.0 - z;
|
|
198
|
+
if (carry !== 0) z -= scalbn2(1.0, q0);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (z === 0) {
|
|
202
|
+
j = 0;
|
|
203
|
+
for (i = jz - 1; i >= jk; i--) j |= iq[i];
|
|
204
|
+
if (j === 0) {
|
|
205
|
+
for (k = 1; iq[jk - k] === 0; k++) { }
|
|
206
|
+
for (i = jz + 1; i <= jz + k; i++) {
|
|
207
|
+
f[jx + i] = twoOverPi[jv + i];
|
|
208
|
+
for (j = 0, fw = 0; j <= jx; j++) fw += x[j] * f[jx + i - j];
|
|
209
|
+
q[i] = fw;
|
|
210
|
+
}
|
|
211
|
+
jz += k;
|
|
212
|
+
recomputeNeeded = true;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (z === 0) {
|
|
217
|
+
jz -= 1; q0 -= 24;
|
|
218
|
+
while (iq[jz] === 0) { jz--; q0 -= 24; }
|
|
219
|
+
} else {
|
|
220
|
+
z = scalbn2(z, -q0);
|
|
221
|
+
if (z >= two24) {
|
|
222
|
+
fw = Math.floor(twon24 * z);
|
|
223
|
+
iq[jz] = (z - two24 * fw) | 0;
|
|
224
|
+
jz += 1; q0 += 24;
|
|
225
|
+
iq[jz] = fw | 0;
|
|
226
|
+
} else iq[jz] = z | 0;
|
|
227
|
+
}
|
|
228
|
+
fw = scalbn2(1.0, q0);
|
|
229
|
+
for (i = jz; i >= 0; i--) { q[i] = fw * iq[i]; fw *= twon24; }
|
|
230
|
+
for (i = jz; i >= 0; i--) {
|
|
231
|
+
for (fw = 0, k = 0; k <= jp && k <= jz - i; k++) fw += PIo2[k] * q[i + k];
|
|
232
|
+
fw0[jz - i] = fw;
|
|
233
|
+
}
|
|
234
|
+
// compress fw0 into y[] (prec 2)
|
|
235
|
+
fw = 0;
|
|
236
|
+
for (i = jz; i >= 0; i--) fw += fw0[i];
|
|
237
|
+
y[0] = ih === 0 ? fw : -fw;
|
|
238
|
+
fw = fw0[0] - fw;
|
|
239
|
+
for (i = 1; i <= jz; i++) fw += fw0[i];
|
|
240
|
+
y[1] = ih === 0 ? fw : -fw;
|
|
241
|
+
}
|
|
242
|
+
return n & 7;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const invpio2 = 6.36619772367581382433e-01;
|
|
246
|
+
const pio2_1 = 1.57079632673412561417e+00, pio2_1t = 6.07710050650619224932e-11;
|
|
247
|
+
const pio2_2 = 6.07710050630396597660e-11, pio2_2t = 2.02226624879595063154e-21;
|
|
248
|
+
const pio2_3 = 2.02226624871116645580e-21, pio2_3t = 8.47842766036889956997e-32;
|
|
249
|
+
const npio2_hw = [
|
|
250
|
+
0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C,
|
|
251
|
+
0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C,
|
|
252
|
+
0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A,
|
|
253
|
+
0x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C,
|
|
254
|
+
0x4043A28C, 0x40446B9C, 0x404534AC, 0x4045FDBB, 0x4046C6CB, 0x40478FDB,
|
|
255
|
+
0x404858EB, 0x404921FB,
|
|
256
|
+
];
|
|
257
|
+
function remPio2(x, y) {
|
|
258
|
+
const hx = HI(x);
|
|
259
|
+
const ix = hx & 0x7fffffff;
|
|
260
|
+
if (ix <= 0x3fe921fb) { y[0] = x; y[1] = 0; return 0; }
|
|
261
|
+
if (ix < 0x4002d97c) { // |x| < 3pi/4
|
|
262
|
+
if (hx > 0) {
|
|
263
|
+
let z = x - pio2_1;
|
|
264
|
+
if (ix !== 0x3ff921fb) { y[0] = z - pio2_1t; y[1] = (z - y[0]) - pio2_1t; }
|
|
265
|
+
else { z -= pio2_2; y[0] = z - pio2_2t; y[1] = (z - y[0]) - pio2_2t; }
|
|
266
|
+
return 1;
|
|
267
|
+
}
|
|
268
|
+
let z = x + pio2_1;
|
|
269
|
+
if (ix !== 0x3ff921fb) { y[0] = z + pio2_1t; y[1] = (z - y[0]) + pio2_1t; }
|
|
270
|
+
else { z += pio2_2; y[0] = z + pio2_2t; y[1] = (z - y[0]) + pio2_2t; }
|
|
271
|
+
return -1;
|
|
272
|
+
}
|
|
273
|
+
if (ix <= 0x413921fb) { // |x| <= 2^19 pi/2
|
|
274
|
+
const t = abs(x);
|
|
275
|
+
const n = (t * invpio2 + 0.5) | 0;
|
|
276
|
+
const fn = n;
|
|
277
|
+
let r = t - fn * pio2_1;
|
|
278
|
+
let w = fn * pio2_1t;
|
|
279
|
+
if (n < 32 && ix !== npio2_hw[n - 1]) {
|
|
280
|
+
y[0] = r - w;
|
|
281
|
+
} else {
|
|
282
|
+
const high = HI(x);
|
|
283
|
+
let j = ix >> 20;
|
|
284
|
+
y[0] = r - w;
|
|
285
|
+
let i = j - (((HI(y[0])) >> 20) & 0x7ff);
|
|
286
|
+
if (i > 16) {
|
|
287
|
+
let t2 = r;
|
|
288
|
+
w = fn * pio2_2;
|
|
289
|
+
r = t2 - w;
|
|
290
|
+
w = fn * pio2_2t - ((t2 - r) - w);
|
|
291
|
+
y[0] = r - w;
|
|
292
|
+
i = j - (((HI(y[0])) >> 20) & 0x7ff);
|
|
293
|
+
if (i > 49) {
|
|
294
|
+
let t3 = r;
|
|
295
|
+
w = fn * pio2_3;
|
|
296
|
+
r = t3 - w;
|
|
297
|
+
w = fn * pio2_3t - ((t3 - r) - w);
|
|
298
|
+
y[0] = r - w;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
y[1] = (r - y[0]) - w;
|
|
303
|
+
if (hx < 0) { y[0] = -y[0]; y[1] = -y[1]; return -n; }
|
|
304
|
+
return n;
|
|
305
|
+
}
|
|
306
|
+
if (ix >= 0x7ff00000) { y[0] = y[1] = x - x; return 0; }
|
|
307
|
+
// Payne-Hanek
|
|
308
|
+
const lx = LO(x);
|
|
309
|
+
const e0 = (ix >> 20) - 1046;
|
|
310
|
+
let z = setHi(0, ix - (e0 << 20));
|
|
311
|
+
z = setLo(z, lx);
|
|
312
|
+
const tx = [0, 0, 0];
|
|
313
|
+
for (let i = 0; i < 2; i++) { tx[i] = z | 0; z = (z - tx[i]) * two24; }
|
|
314
|
+
tx[2] = z;
|
|
315
|
+
let nx = 3;
|
|
316
|
+
while (nx > 0 && tx[nx - 1] === 0) nx--;
|
|
317
|
+
const n = kernelRemPio2(tx, y, e0, nx);
|
|
318
|
+
if (hx < 0) { y[0] = -y[0]; y[1] = -y[1]; return -n; }
|
|
319
|
+
return n;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function detSin(x) {
|
|
323
|
+
const ix = HI(x) & 0x7fffffff;
|
|
324
|
+
if (ix <= 0x3fe921fb) {
|
|
325
|
+
if (ix < 0x3e400000) { if ((x | 0) === 0 && x === x) return x; }
|
|
326
|
+
return kernelSin(x, 0, 0);
|
|
327
|
+
}
|
|
328
|
+
if (ix >= 0x7ff00000) return x - x;
|
|
329
|
+
const y = [0, 0];
|
|
330
|
+
const n = remPio2(x, y);
|
|
331
|
+
switch (n & 3) {
|
|
332
|
+
case 0: return kernelSin(y[0], y[1], 1);
|
|
333
|
+
case 1: return kernelCos(y[0], y[1]);
|
|
334
|
+
case 2: return -kernelSin(y[0], y[1], 1);
|
|
335
|
+
default: return -kernelCos(y[0], y[1]);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
function detCos(x) {
|
|
339
|
+
const ix = HI(x) & 0x7fffffff;
|
|
340
|
+
if (ix <= 0x3fe921fb) {
|
|
341
|
+
if (ix < 0x3e400000) return 1.0;
|
|
342
|
+
return kernelCos(x, 0);
|
|
343
|
+
}
|
|
344
|
+
if (ix >= 0x7ff00000) return x - x;
|
|
345
|
+
const y = [0, 0];
|
|
346
|
+
const n = remPio2(x, y);
|
|
347
|
+
switch (n & 3) {
|
|
348
|
+
case 0: return kernelCos(y[0], y[1]);
|
|
349
|
+
case 1: return -kernelSin(y[0], y[1], 1);
|
|
350
|
+
case 2: return -kernelCos(y[0], y[1]);
|
|
351
|
+
default: return kernelSin(y[0], y[1], 1);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function detTan(x) {
|
|
355
|
+
const ix = HI(x) & 0x7fffffff;
|
|
356
|
+
if (ix <= 0x3fe921fb) {
|
|
357
|
+
if (ix < 0x3e300000) { if ((x | 0) === 0 && x === x) return x; }
|
|
358
|
+
return kernelTan(x, 0, 1);
|
|
359
|
+
}
|
|
360
|
+
if (ix >= 0x7ff00000) return x - x;
|
|
361
|
+
const y = [0, 0];
|
|
362
|
+
const n = remPio2(x, y);
|
|
363
|
+
return kernelTan(y[0], y[1], 1 - ((n & 1) << 1));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// ---- log / log10 (fdlibm e_log) ------------------------------------------
|
|
367
|
+
const ln2_hi = 6.93147180369123816490e-01, ln2_lo = 1.90821492927058770002e-10;
|
|
368
|
+
const Lg1 = 6.666666666666735130e-01, Lg2 = 3.999999999940941908e-01,
|
|
369
|
+
Lg3 = 2.857142874366239149e-01, Lg4 = 2.222219843214978396e-01,
|
|
370
|
+
Lg5 = 1.818357216161805012e-01, Lg6 = 1.531383769920937332e-01,
|
|
371
|
+
Lg7 = 1.479819860511658591e-01;
|
|
372
|
+
const two54 = 1.80143985094819840000e+16;
|
|
373
|
+
function detLog(x) {
|
|
374
|
+
let hx = HI(x), lx = LO(x);
|
|
375
|
+
let k = 0;
|
|
376
|
+
if (hx < 0x00100000) {
|
|
377
|
+
if (((hx & 0x7fffffff) | lx) === 0) return -Infinity;
|
|
378
|
+
if (hx < 0) return (x - x) / 0;
|
|
379
|
+
k -= 54; x *= two54; hx = HI(x);
|
|
380
|
+
}
|
|
381
|
+
if (hx >= 0x7ff00000) return x + x;
|
|
382
|
+
k += (hx >> 20) - 1023;
|
|
383
|
+
hx &= 0x000fffff;
|
|
384
|
+
const i = (hx + 0x95f64) & 0x100000;
|
|
385
|
+
x = setHi(x, hx | (i ^ 0x3ff00000));
|
|
386
|
+
k += i >> 20;
|
|
387
|
+
const f = x - 1.0;
|
|
388
|
+
if ((0x000fffff & (2 + hx)) < 3) {
|
|
389
|
+
if (f === 0) { if (k === 0) return 0; return k * ln2_hi + k * ln2_lo; }
|
|
390
|
+
const R = f * f * (0.5 - 0.33333333333333333 * f);
|
|
391
|
+
if (k === 0) return f - R;
|
|
392
|
+
return k * ln2_hi - ((R - k * ln2_lo) - f);
|
|
393
|
+
}
|
|
394
|
+
const s = f / (2.0 + f);
|
|
395
|
+
const dk = k;
|
|
396
|
+
const z = s * s;
|
|
397
|
+
const ii = hx - 0x6147a;
|
|
398
|
+
const w = z * z;
|
|
399
|
+
const jj = 0x6b851 - hx;
|
|
400
|
+
const t1 = w * (Lg2 + w * (Lg4 + w * Lg6));
|
|
401
|
+
const t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
|
|
402
|
+
const ij = ii | jj;
|
|
403
|
+
const R = t2 + t1;
|
|
404
|
+
if (ij > 0) {
|
|
405
|
+
const hfsq = 0.5 * f * f;
|
|
406
|
+
if (k === 0) return f - (hfsq - s * (hfsq + R));
|
|
407
|
+
return dk * ln2_hi - ((hfsq - (s * (hfsq + R) + dk * ln2_lo)) - f);
|
|
408
|
+
}
|
|
409
|
+
if (k === 0) return f - s * (f - R);
|
|
410
|
+
return dk * ln2_hi - ((s * (f - R) - dk * ln2_lo) - f);
|
|
411
|
+
}
|
|
412
|
+
const ivln10 = 4.34294481903251816668e-01;
|
|
413
|
+
const log10_2hi = 3.01029995663611771306e-01, log10_2lo = 3.69423907715893078616e-13;
|
|
414
|
+
function detLog10(x) {
|
|
415
|
+
let hx = HI(x), lx = LO(x);
|
|
416
|
+
let k = 0;
|
|
417
|
+
if (hx < 0x00100000) {
|
|
418
|
+
if (((hx & 0x7fffffff) | lx) === 0) return -Infinity;
|
|
419
|
+
if (hx < 0) return (x - x) / 0;
|
|
420
|
+
k -= 54; x *= two54; hx = HI(x);
|
|
421
|
+
}
|
|
422
|
+
if (hx >= 0x7ff00000) return x + x;
|
|
423
|
+
k += (hx >> 20) - 1023;
|
|
424
|
+
const i = (k & 0x80000000) >>> 31;
|
|
425
|
+
hx = (hx & 0x000fffff) | ((0x3ff - i) << 20);
|
|
426
|
+
const y = k + i;
|
|
427
|
+
x = setHi(x, hx);
|
|
428
|
+
const z = y * log10_2lo + ivln10 * detLog(x);
|
|
429
|
+
return z + y * log10_2hi;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// ---- asin / acos (fdlibm) -------------------------------------------------
|
|
433
|
+
const pio2_hi = 1.57079632679489655800e+00, pio2_lo = 6.12323399573676603587e-17;
|
|
434
|
+
const pio4_hi = 7.85398163397448278999e-01;
|
|
435
|
+
const pS0 = 1.66666666666666657415e-01, pS1 = -3.25565818622400915405e-01,
|
|
436
|
+
pS2 = 2.01212532134862925881e-01, pS3 = -4.00555345006794114027e-02,
|
|
437
|
+
pS4 = 7.91534994289814532176e-04, pS5 = 3.47933107596021167570e-05,
|
|
438
|
+
qS1 = -2.40339491173441421878e+00, qS2 = 2.02094576023350569471e+00,
|
|
439
|
+
qS3 = -6.88283971605453293030e-01, qS4 = 7.70381505559019352791e-02;
|
|
440
|
+
function detAsin(x) {
|
|
441
|
+
const hx = HI(x);
|
|
442
|
+
const ix = hx & 0x7fffffff;
|
|
443
|
+
if (ix >= 0x3ff00000) {
|
|
444
|
+
if (((ix - 0x3ff00000) | LO(x)) === 0) return x * pio2_hi + x * pio2_lo;
|
|
445
|
+
return (x - x) / (x - x);
|
|
446
|
+
}
|
|
447
|
+
if (ix < 0x3fe00000) {
|
|
448
|
+
if (ix < 0x3e400000) return x;
|
|
449
|
+
const t = x * x;
|
|
450
|
+
const p = t * (pS0 + t * (pS1 + t * (pS2 + t * (pS3 + t * (pS4 + t * pS5)))));
|
|
451
|
+
const q = 1.0 + t * (qS1 + t * (qS2 + t * (qS3 + t * qS4)));
|
|
452
|
+
const w = p / q;
|
|
453
|
+
return x + x * w;
|
|
454
|
+
}
|
|
455
|
+
let w = 1.0 - abs(x);
|
|
456
|
+
let t = w * 0.5;
|
|
457
|
+
let p = t * (pS0 + t * (pS1 + t * (pS2 + t * (pS3 + t * (pS4 + t * pS5)))));
|
|
458
|
+
let q = 1.0 + t * (qS1 + t * (qS2 + t * (qS3 + t * qS4)));
|
|
459
|
+
const s = sqrt(t);
|
|
460
|
+
if (ix >= 0x3FEF3333) {
|
|
461
|
+
w = p / q;
|
|
462
|
+
t = pio2_hi - (2.0 * (s + s * w) - pio2_lo);
|
|
463
|
+
} else {
|
|
464
|
+
w = s;
|
|
465
|
+
w = setLo(w, 0);
|
|
466
|
+
const c = (t - w * w) / (s + w);
|
|
467
|
+
const r = p / q;
|
|
468
|
+
p = 2.0 * s * r - (pio2_lo - 2.0 * c);
|
|
469
|
+
q = pio4_hi - 2.0 * w;
|
|
470
|
+
t = pio4_hi - (p - q);
|
|
471
|
+
}
|
|
472
|
+
return hx > 0 ? t : -t;
|
|
473
|
+
}
|
|
474
|
+
function detAcos(x) {
|
|
475
|
+
const hx = HI(x);
|
|
476
|
+
const ix = hx & 0x7fffffff;
|
|
477
|
+
if (ix >= 0x3ff00000) {
|
|
478
|
+
if (((ix - 0x3ff00000) | LO(x)) === 0) return hx > 0 ? 0.0 : Math.PI;
|
|
479
|
+
return (x - x) / (x - x);
|
|
480
|
+
}
|
|
481
|
+
if (ix < 0x3fe00000) {
|
|
482
|
+
if (ix <= 0x3c600000) return pio2_hi + pio2_lo;
|
|
483
|
+
const z = x * x;
|
|
484
|
+
const p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5)))));
|
|
485
|
+
const q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4)));
|
|
486
|
+
const r = p / q;
|
|
487
|
+
return pio2_hi - (x - (pio2_lo - x * r));
|
|
488
|
+
}
|
|
489
|
+
if (hx < 0) {
|
|
490
|
+
const z = (1.0 + x) * 0.5;
|
|
491
|
+
const p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5)))));
|
|
492
|
+
const q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4)));
|
|
493
|
+
const s = sqrt(z);
|
|
494
|
+
const r = p / q;
|
|
495
|
+
const w = r * s - pio2_lo;
|
|
496
|
+
return Math.PI - 2.0 * (s + w);
|
|
497
|
+
}
|
|
498
|
+
const z = (1.0 - x) * 0.5;
|
|
499
|
+
const s = sqrt(z);
|
|
500
|
+
let df = s;
|
|
501
|
+
df = setLo(df, 0);
|
|
502
|
+
const c = (z - df * df) / (s + df);
|
|
503
|
+
const p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5)))));
|
|
504
|
+
const q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4)));
|
|
505
|
+
const r = p / q;
|
|
506
|
+
const w = r * s + c;
|
|
507
|
+
return 2.0 * (df + w);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// ---- expm1 (fdlibm s_expm1) ----------------------------------------------
|
|
511
|
+
const o_threshold = 7.09782712893383973096e+02;
|
|
512
|
+
const invln2 = 1.44269504088896338700e+00;
|
|
513
|
+
const Q1 = -3.33333333333331316428e-02, Q2 = 1.58730158725481460165e-03,
|
|
514
|
+
Q3 = -7.93650757867487942473e-05, Q4 = 4.00821782732936239552e-06,
|
|
515
|
+
Q5 = -2.01099218183624371326e-07;
|
|
516
|
+
function detExpm1(x) {
|
|
517
|
+
const hx = HI(x);
|
|
518
|
+
const xsb = hx & 0x80000000;
|
|
519
|
+
let y = xsb === 0 ? x : -x;
|
|
520
|
+
const ix = hx & 0x7fffffff;
|
|
521
|
+
if (ix >= 0x4043687A) {
|
|
522
|
+
if (ix >= 0x40862E42) {
|
|
523
|
+
if (ix >= 0x7ff00000) {
|
|
524
|
+
if (((ix & 0xfffff) | LO(x)) !== 0) return x + x;
|
|
525
|
+
return xsb === 0 ? x : -1.0;
|
|
526
|
+
}
|
|
527
|
+
if (x > o_threshold) return Infinity;
|
|
528
|
+
}
|
|
529
|
+
if (xsb !== 0) return -1.0 + 1e-300 * 1e-300 * 0; // x < -56*ln2: -1 (tiny inexact ignored)
|
|
530
|
+
}
|
|
531
|
+
let k, t, c = 0, hi, lo;
|
|
532
|
+
if (ix > 0x3fd62e42) {
|
|
533
|
+
if (ix < 0x3FF0A2B2) {
|
|
534
|
+
if (xsb === 0) { hi = x - 6.93147180369123816490e-01; lo = 1.90821492927058770002e-10; k = 1; }
|
|
535
|
+
else { hi = x + 6.93147180369123816490e-01; lo = -1.90821492927058770002e-10; k = -1; }
|
|
536
|
+
} else {
|
|
537
|
+
k = (invln2 * x + (xsb === 0 ? 0.5 : -0.5)) | 0;
|
|
538
|
+
t = k;
|
|
539
|
+
hi = x - t * 6.93147180369123816490e-01;
|
|
540
|
+
lo = t * 1.90821492927058770002e-10;
|
|
541
|
+
}
|
|
542
|
+
x = hi - lo;
|
|
543
|
+
c = (hi - x) - lo;
|
|
544
|
+
} else if (ix < 0x3c900000) {
|
|
545
|
+
return x;
|
|
546
|
+
} else k = 0;
|
|
547
|
+
const hfx = 0.5 * x;
|
|
548
|
+
const hxs = x * hfx;
|
|
549
|
+
const r1 = 1.0 + hxs * (Q1 + hxs * (Q2 + hxs * (Q3 + hxs * (Q4 + hxs * Q5))));
|
|
550
|
+
t = 3.0 - r1 * hfx;
|
|
551
|
+
let e = hxs * ((r1 - t) / (6.0 - x * t));
|
|
552
|
+
if (k === 0) return x - (x * e - hxs);
|
|
553
|
+
e = (x * (e - c) - c);
|
|
554
|
+
e -= hxs;
|
|
555
|
+
if (k === -1) return 0.5 * (x - e) - 0.5;
|
|
556
|
+
if (k === 1) {
|
|
557
|
+
if (x < -0.25) return -2.0 * (e - (x + 0.5));
|
|
558
|
+
return 1.0 + 2.0 * (x - e);
|
|
559
|
+
}
|
|
560
|
+
if (k <= -2 || k > 56) {
|
|
561
|
+
y = 1.0 - (e - x);
|
|
562
|
+
if (k === 1024) y = y * 2.0 * two1023;
|
|
563
|
+
else y = y * scalbn2(1.0, k);
|
|
564
|
+
return y - 1.0;
|
|
565
|
+
}
|
|
566
|
+
t = scalbn2(1.0, -k);
|
|
567
|
+
if (k < 20) {
|
|
568
|
+
y = (x - e + (1 - t)) * scalbn2(1.0, k);
|
|
569
|
+
} else {
|
|
570
|
+
y = (x - (e + t) + 1) * scalbn2(1.0, k);
|
|
571
|
+
}
|
|
572
|
+
return y;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// ---- exp (fdlibm e_exp — native exp diverges cross-engine on rare inputs)
|
|
576
|
+
const halF = [0.5, -0.5];
|
|
577
|
+
const u_threshold = -7.45133219101941108420e+02;
|
|
578
|
+
const ln2HI = [6.93147180369123816490e-01, -6.93147180369123816490e-01];
|
|
579
|
+
const ln2LO = [1.90821492927058770002e-10, -1.90821492927058770002e-10];
|
|
580
|
+
const P1 = 1.66666666666666019037e-01, P2 = -2.77777777770155933842e-03,
|
|
581
|
+
P3 = 6.61375632143793436117e-05, P4 = -1.65339022054652515390e-06,
|
|
582
|
+
P5 = 4.13813679705723846039e-08;
|
|
583
|
+
const twom1000 = 9.33263618503218878990e-302;
|
|
584
|
+
function detExp(x) {
|
|
585
|
+
let hx = HI(x);
|
|
586
|
+
const xsb = (hx >> 31) & 1;
|
|
587
|
+
hx &= 0x7fffffff;
|
|
588
|
+
if (hx >= 0x40862E42) {
|
|
589
|
+
if (hx >= 0x7ff00000) {
|
|
590
|
+
if (((hx & 0xfffff) | LO(x)) !== 0) return x + x;
|
|
591
|
+
return xsb === 0 ? x : 0.0;
|
|
592
|
+
}
|
|
593
|
+
if (x > o_threshold) return Infinity;
|
|
594
|
+
if (x < u_threshold) return 0;
|
|
595
|
+
}
|
|
596
|
+
let k = 0, hi = 0, lo = 0, t;
|
|
597
|
+
if (hx > 0x3fd62e42) {
|
|
598
|
+
if (hx < 0x3FF0A2B2) { hi = x - ln2HI[xsb]; lo = ln2LO[xsb]; k = 1 - xsb - xsb; }
|
|
599
|
+
else {
|
|
600
|
+
k = (invln2 * x + halF[xsb]) | 0;
|
|
601
|
+
t = k;
|
|
602
|
+
hi = x - t * ln2HI[0];
|
|
603
|
+
lo = t * ln2LO[0];
|
|
604
|
+
}
|
|
605
|
+
x = hi - lo;
|
|
606
|
+
} else if (hx < 0x3e300000) {
|
|
607
|
+
return 1.0 + x;
|
|
608
|
+
}
|
|
609
|
+
t = x * x;
|
|
610
|
+
const c = x - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));
|
|
611
|
+
if (k === 0) return 1.0 - ((x * c) / (c - 2.0) - x);
|
|
612
|
+
let y = 1.0 - ((lo - (x * c) / (2.0 - c)) - hi);
|
|
613
|
+
if (k >= -1021) return setHi(y, HI(y) + (k << 20));
|
|
614
|
+
y = setHi(y, HI(y) + ((k + 1000) << 20));
|
|
615
|
+
return y * twom1000;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// ---- sinh / cosh / tanh from expm1 + deterministic exp -------------------
|
|
619
|
+
const nativeExp = detExp;
|
|
620
|
+
function detSinh(x) {
|
|
621
|
+
const hx = HI(x);
|
|
622
|
+
const ix = hx & 0x7fffffff;
|
|
623
|
+
if (ix >= 0x7ff00000) return x + x;
|
|
624
|
+
const h = hx < 0 ? -0.5 : 0.5;
|
|
625
|
+
if (ix < 0x40360000) {
|
|
626
|
+
if (ix < 0x3e300000) return x;
|
|
627
|
+
const t = detExpm1(abs(x));
|
|
628
|
+
if (ix < 0x3ff00000) return h * (2.0 * t - t * t / (t + 1.0));
|
|
629
|
+
return h * (t + t / (t + 1.0));
|
|
630
|
+
}
|
|
631
|
+
if (ix < 0x40862E42) return h * nativeExp(abs(x));
|
|
632
|
+
const lx = LO(x);
|
|
633
|
+
if (ix < 0x408633CE || (ix === 0x408633CE && lx <= 0x8fb9f87d)) {
|
|
634
|
+
const w = nativeExp(0.5 * abs(x));
|
|
635
|
+
const t = h * w;
|
|
636
|
+
return t * w;
|
|
637
|
+
}
|
|
638
|
+
return x * 1e307 * 1e307;
|
|
639
|
+
}
|
|
640
|
+
function detCosh(x) {
|
|
641
|
+
const ix = HI(x) & 0x7fffffff;
|
|
642
|
+
if (ix >= 0x7ff00000) return x * x;
|
|
643
|
+
if (ix < 0x3fd62e43) {
|
|
644
|
+
const t = detExpm1(abs(x));
|
|
645
|
+
const w = 1.0 + t;
|
|
646
|
+
if (ix < 0x3c800000) return w;
|
|
647
|
+
return 1.0 + (t * t) / (w + w);
|
|
648
|
+
}
|
|
649
|
+
if (ix < 0x40360000) {
|
|
650
|
+
const t = nativeExp(abs(x));
|
|
651
|
+
return 0.5 * t + 0.5 / t;
|
|
652
|
+
}
|
|
653
|
+
if (ix < 0x40862E42) return 0.5 * nativeExp(abs(x));
|
|
654
|
+
const lx = LO(x);
|
|
655
|
+
if (ix < 0x408633CE || (ix === 0x408633CE && lx <= 0x8fb9f87d)) {
|
|
656
|
+
const w = nativeExp(0.5 * abs(x));
|
|
657
|
+
return (0.5 * w) * w;
|
|
658
|
+
}
|
|
659
|
+
return 1e307 * 1e307;
|
|
660
|
+
}
|
|
661
|
+
function detTanh(x) {
|
|
662
|
+
const hx = HI(x);
|
|
663
|
+
const ix = hx & 0x7fffffff;
|
|
664
|
+
if (ix >= 0x7ff00000) {
|
|
665
|
+
if (hx >= 0) return 1.0 / x + 1.0;
|
|
666
|
+
return 1.0 / x - 1.0;
|
|
667
|
+
}
|
|
668
|
+
let z;
|
|
669
|
+
if (ix < 0x40360000) {
|
|
670
|
+
if (ix < 0x3c800000) return x * (1.0 + x);
|
|
671
|
+
if (ix >= 0x3ff00000) {
|
|
672
|
+
const t = detExpm1(2.0 * abs(x));
|
|
673
|
+
z = 1.0 - 2.0 / (t + 2.0);
|
|
674
|
+
} else {
|
|
675
|
+
const t = detExpm1(-2.0 * abs(x));
|
|
676
|
+
z = -t / (t + 2.0);
|
|
677
|
+
}
|
|
678
|
+
} else z = 1.0 - 1e-300;
|
|
679
|
+
return hx >= 0 ? z : -z;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// ---- atan / atan2 (fdlibm s_atan / e_atan2) -------------------------------
|
|
683
|
+
const atanhi = [
|
|
684
|
+
4.63647609000806093515e-01, 7.85398163397448278999e-01,
|
|
685
|
+
9.82793723247329054082e-01, 1.57079632679489655800e+00,
|
|
686
|
+
];
|
|
687
|
+
const atanlo = [
|
|
688
|
+
2.26987774529616870924e-17, 3.06161699786838301793e-17,
|
|
689
|
+
1.39033110312309984516e-17, 6.12323399573676603587e-17,
|
|
690
|
+
];
|
|
691
|
+
const aT = [
|
|
692
|
+
3.33333333333329318027e-01, -1.99999999998764832476e-01, 1.42857142725034663711e-01,
|
|
693
|
+
-1.11111104054623557880e-01, 9.09088713343650656196e-02, -7.69187620504482999495e-02,
|
|
694
|
+
6.66107313738753120669e-02, -5.83357013379057348645e-02, 4.97687799461593236017e-02,
|
|
695
|
+
-3.65315727442169155270e-02, 1.62858201153657823623e-02,
|
|
696
|
+
];
|
|
697
|
+
function detAtan(x) {
|
|
698
|
+
const hx = HI(x);
|
|
699
|
+
const ix = hx & 0x7fffffff;
|
|
700
|
+
if (ix >= 0x44100000) {
|
|
701
|
+
if (ix > 0x7ff00000 || (ix === 0x7ff00000 && LO(x) !== 0)) return x + x;
|
|
702
|
+
return hx > 0 ? atanhi[3] + atanlo[3] : -atanhi[3] - atanlo[3];
|
|
703
|
+
}
|
|
704
|
+
let id;
|
|
705
|
+
if (ix < 0x3fdc0000) {
|
|
706
|
+
if (ix < 0x3e200000) return x;
|
|
707
|
+
id = -1;
|
|
708
|
+
} else {
|
|
709
|
+
x = abs(x);
|
|
710
|
+
if (ix < 0x3ff30000) {
|
|
711
|
+
if (ix < 0x3fe60000) { id = 0; x = (2.0 * x - 1.0) / (2.0 + x); }
|
|
712
|
+
else { id = 1; x = (x - 1.0) / (x + 1.0); }
|
|
713
|
+
} else {
|
|
714
|
+
if (ix < 0x40038000) { id = 2; x = (x - 1.5) / (1.0 + 1.5 * x); }
|
|
715
|
+
else { id = 3; x = -1.0 / x; }
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
const z = x * x;
|
|
719
|
+
const w = z * z;
|
|
720
|
+
const s1 = z * (aT[0] + w * (aT[2] + w * (aT[4] + w * (aT[6] + w * (aT[8] + w * aT[10])))));
|
|
721
|
+
const s2 = w * (aT[1] + w * (aT[3] + w * (aT[5] + w * (aT[7] + w * aT[9]))));
|
|
722
|
+
if (id < 0) return x - x * (s1 + s2);
|
|
723
|
+
const zz = atanhi[id] - ((x * (s1 + s2) - atanlo[id]) - x);
|
|
724
|
+
return hx < 0 ? -zz : zz;
|
|
725
|
+
}
|
|
726
|
+
const tiny_atan2 = 1.0e-300;
|
|
727
|
+
const pi_o_4 = 7.8539816339744827900e-01, pi_o_2 = 1.5707963267948965580e+00;
|
|
728
|
+
const detPi = 3.1415926535897931160e+00, pi_lo = 1.2246467991473531772e-16;
|
|
729
|
+
function detAtan2(y, x) {
|
|
730
|
+
const hx = HI(x), lx = LO(x), hy = HI(y), ly = LO(y);
|
|
731
|
+
const ix = hx & 0x7fffffff, iy = hy & 0x7fffffff;
|
|
732
|
+
if ((ix | ((lx | -lx) >>> 31)) > 0x7ff00000 || (iy | ((ly | -ly) >>> 31)) > 0x7ff00000) return x + y;
|
|
733
|
+
if (hx === 0x3ff00000 && lx === 0) return detAtan(y);
|
|
734
|
+
const m = ((hy >> 31) & 1) | ((hx >> 30) & 2);
|
|
735
|
+
if ((iy | ly) === 0) {
|
|
736
|
+
switch (m) {
|
|
737
|
+
case 0: case 1: return y;
|
|
738
|
+
case 2: return detPi + tiny_atan2;
|
|
739
|
+
default: return -detPi - tiny_atan2;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
if ((ix | lx) === 0) return hy < 0 ? -pi_o_2 - tiny_atan2 : pi_o_2 + tiny_atan2;
|
|
743
|
+
if (ix === 0x7ff00000) {
|
|
744
|
+
if (iy === 0x7ff00000) {
|
|
745
|
+
switch (m) {
|
|
746
|
+
case 0: return pi_o_4 + tiny_atan2;
|
|
747
|
+
case 1: return -pi_o_4 - tiny_atan2;
|
|
748
|
+
case 2: return 3.0 * pi_o_4 + tiny_atan2;
|
|
749
|
+
default: return -3.0 * pi_o_4 - tiny_atan2;
|
|
750
|
+
}
|
|
751
|
+
} else {
|
|
752
|
+
switch (m) {
|
|
753
|
+
case 0: return 0.0;
|
|
754
|
+
case 1: return -0.0;
|
|
755
|
+
case 2: return detPi + tiny_atan2;
|
|
756
|
+
default: return -detPi - tiny_atan2;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
if (iy === 0x7ff00000) return hy < 0 ? -pi_o_2 - tiny_atan2 : pi_o_2 + tiny_atan2;
|
|
761
|
+
const k = (iy - ix) >> 20;
|
|
762
|
+
let z;
|
|
763
|
+
if (k > 60) z = pi_o_2 + 0.5 * pi_lo;
|
|
764
|
+
else if (hx < 0 && k < -60) z = 0.0;
|
|
765
|
+
else z = detAtan(abs(y / x));
|
|
766
|
+
switch (m) {
|
|
767
|
+
case 0: return z;
|
|
768
|
+
case 1: return -z;
|
|
769
|
+
case 2: return detPi - (z - pi_lo);
|
|
770
|
+
default: return (z - pi_lo) - detPi;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// ---- log1p (fdlibm s_log1p) -----------------------------------------------
|
|
775
|
+
function detLog1p(x) {
|
|
776
|
+
const hx = HI(x);
|
|
777
|
+
const ax = hx & 0x7fffffff;
|
|
778
|
+
let k = 1, f = 0, hu = 0, c = 0, u;
|
|
779
|
+
if (hx < 0x3FDA827A) {
|
|
780
|
+
if (ax >= 0x3ff00000) {
|
|
781
|
+
if (x === -1.0) return -Infinity;
|
|
782
|
+
return (x - x) / (x - x);
|
|
783
|
+
}
|
|
784
|
+
if (ax < 0x3e200000) {
|
|
785
|
+
if (ax < 0x3c900000) return x;
|
|
786
|
+
return x - x * x * 0.5;
|
|
787
|
+
}
|
|
788
|
+
if (hx > 0 || hx <= (0xbfd2bec3 | 0)) { k = 0; f = x; hu = 1; }
|
|
789
|
+
}
|
|
790
|
+
if (k !== 0) {
|
|
791
|
+
if (hx < 0x43400000) {
|
|
792
|
+
u = 1.0 + x;
|
|
793
|
+
hu = HI(u);
|
|
794
|
+
k = (hu >> 20) - 1023;
|
|
795
|
+
c = k > 0 ? 1.0 - (u - x) : x - (u - 1.0);
|
|
796
|
+
c /= u;
|
|
797
|
+
} else {
|
|
798
|
+
u = x;
|
|
799
|
+
hu = HI(u);
|
|
800
|
+
k = (hu >> 20) - 1023;
|
|
801
|
+
c = 0;
|
|
802
|
+
}
|
|
803
|
+
hu &= 0x000fffff;
|
|
804
|
+
if (hu < 0x6a09e) {
|
|
805
|
+
u = setHi(u, hu | 0x3ff00000);
|
|
806
|
+
} else {
|
|
807
|
+
k += 1;
|
|
808
|
+
u = setHi(u, hu | 0x3fe00000);
|
|
809
|
+
hu = (0x00100000 - hu) >> 2;
|
|
810
|
+
}
|
|
811
|
+
f = u - 1.0;
|
|
812
|
+
}
|
|
813
|
+
const hfsq = 0.5 * f * f;
|
|
814
|
+
let R, s, z;
|
|
815
|
+
if (hu === 0) {
|
|
816
|
+
if (f === 0) {
|
|
817
|
+
if (k === 0) return 0;
|
|
818
|
+
c += k * ln2_lo;
|
|
819
|
+
return k * ln2_hi + c;
|
|
820
|
+
}
|
|
821
|
+
R = hfsq * (1.0 - 0.66666666666666666 * f);
|
|
822
|
+
if (k === 0) return f - R;
|
|
823
|
+
return k * ln2_hi - ((R - (k * ln2_lo + c)) - f);
|
|
824
|
+
}
|
|
825
|
+
s = f / (2.0 + f);
|
|
826
|
+
z = s * s;
|
|
827
|
+
R = z * (Lg1 + z * (Lg2 + z * (Lg3 + z * (Lg4 + z * (Lg5 + z * (Lg6 + z * Lg7))))));
|
|
828
|
+
if (k === 0) return f - (hfsq - s * (hfsq + R));
|
|
829
|
+
return k * ln2_hi - ((hfsq - (s * (hfsq + R) + (k * ln2_lo + c))) - f);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// ---- asinh / acosh / atanh (fdlibm, via deterministic log/log1p/sqrt) ----
|
|
833
|
+
const det_ln2 = 6.93147180559945286227e-01;
|
|
834
|
+
function detAsinh(x) {
|
|
835
|
+
const hx = HI(x);
|
|
836
|
+
const ix = hx & 0x7fffffff;
|
|
837
|
+
if (ix >= 0x7ff00000) return x + x;
|
|
838
|
+
if (ix < 0x3e300000) return x;
|
|
839
|
+
let w;
|
|
840
|
+
const t = abs(x);
|
|
841
|
+
if (ix > 0x41b00000) w = detLog(t) + det_ln2;
|
|
842
|
+
else if (ix > 0x40000000) w = detLog(2.0 * t + 1.0 / (sqrt(t * t + 1.0) + t));
|
|
843
|
+
else { const xx = t * t; w = detLog1p(t + xx / (1.0 + sqrt(1.0 + xx))); }
|
|
844
|
+
return hx > 0 ? w : -w;
|
|
845
|
+
}
|
|
846
|
+
function detAcosh(x) {
|
|
847
|
+
const hx = HI(x);
|
|
848
|
+
if (hx < 0x3ff00000) return (x - x) / (x - x);
|
|
849
|
+
if (hx >= 0x41b00000) {
|
|
850
|
+
if (hx >= 0x7ff00000) return x + x;
|
|
851
|
+
return detLog(x) + det_ln2;
|
|
852
|
+
}
|
|
853
|
+
if (((hx - 0x3ff00000) | LO(x)) === 0) return 0;
|
|
854
|
+
if (hx > 0x40000000) {
|
|
855
|
+
const t = x * x;
|
|
856
|
+
return detLog(2.0 * x - 1.0 / (x + sqrt(t - 1.0)));
|
|
857
|
+
}
|
|
858
|
+
const t = x - 1.0;
|
|
859
|
+
return detLog1p(t + sqrt(2.0 * t + t * t));
|
|
860
|
+
}
|
|
861
|
+
function detAtanh(x) {
|
|
862
|
+
const hx = HI(x);
|
|
863
|
+
const ix = hx & 0x7fffffff;
|
|
864
|
+
if (ix > 0x3ff00000 || (ix === 0x3ff00000 && LO(x) !== 0)) return (x - x) / (x - x);
|
|
865
|
+
if (ix === 0x3ff00000 && LO(x) === 0) return x / 0;
|
|
866
|
+
if (ix < 0x3e300000) return x;
|
|
867
|
+
const t0 = abs(x);
|
|
868
|
+
let t;
|
|
869
|
+
if (ix < 0x3fe00000) {
|
|
870
|
+
const t2 = t0 + t0;
|
|
871
|
+
t = 0.5 * detLog1p(t2 + t2 * t0 / (1.0 - t0));
|
|
872
|
+
} else {
|
|
873
|
+
t = 0.5 * detLog1p((t0 + t0) / (1.0 - t0));
|
|
874
|
+
}
|
|
875
|
+
return hx >= 0 ? t : -t;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// ---- log2 (FreeBSD e_log2 + k_log1p kernel) -------------------------------
|
|
879
|
+
// Added 2026-07-09: JavaScriptCore disagrees bitwise with V8 on log2, cbrt
|
|
880
|
+
// and hypot (5k-input battery); V8 13.x vs 14.x had agreed, so these three
|
|
881
|
+
// stayed native until the JSC port measured them.
|
|
882
|
+
const ivln2hi = 1.44269504072144627571e+00, ivln2lo = 1.67517131648865118353e-10;
|
|
883
|
+
function kLog1p(f) {
|
|
884
|
+
const s = f / (2.0 + f);
|
|
885
|
+
const z = s * s;
|
|
886
|
+
const w = z * z;
|
|
887
|
+
const t1 = w * (Lg2 + w * (Lg4 + w * Lg6));
|
|
888
|
+
const t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
|
|
889
|
+
const hfsq = 0.5 * f * f;
|
|
890
|
+
return s * (hfsq + (t2 + t1));
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
function detLog2(x) {
|
|
894
|
+
let hx = HI(x), lx = LO(x);
|
|
895
|
+
let k = 0;
|
|
896
|
+
if (hx < 0x00100000) {
|
|
897
|
+
if (((hx & 0x7fffffff) | lx) === 0) return -Infinity;
|
|
898
|
+
if (hx < 0) return (x - x) / 0;
|
|
899
|
+
k -= 54; x *= two54; hx = HI(x); lx = LO(x);
|
|
900
|
+
}
|
|
901
|
+
if (hx >= 0x7ff00000) return x + x;
|
|
902
|
+
if (hx === 0x3ff00000 && lx === 0) return 0.0;
|
|
903
|
+
k += (hx >> 20) - 1023;
|
|
904
|
+
hx &= 0x000fffff;
|
|
905
|
+
const i = (hx + 0x95f64) & 0x100000;
|
|
906
|
+
x = setHi(x, hx | (i ^ 0x3ff00000));
|
|
907
|
+
k += i >> 20;
|
|
908
|
+
const y = k;
|
|
909
|
+
const f = x - 1.0;
|
|
910
|
+
const hfsq = 0.5 * f * f;
|
|
911
|
+
const r = kLog1p(f);
|
|
912
|
+
let hi = f - hfsq;
|
|
913
|
+
hi = setLo(hi, 0);
|
|
914
|
+
const lo = (f - hi) - hfsq + r;
|
|
915
|
+
let valHi = hi * ivln2hi;
|
|
916
|
+
let valLo = (lo + hi) * ivln2lo + lo * ivln2hi;
|
|
917
|
+
const w = y + valHi;
|
|
918
|
+
valLo += (y - w) + valHi;
|
|
919
|
+
return valLo + w;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// ---- cbrt (FreeBSD s_cbrt) ------------------------------------------------
|
|
923
|
+
const cbrtB1 = 715094163, cbrtB2 = 696219795;
|
|
924
|
+
const cbrtP0 = 1.87595182427177009643, cbrtP1 = -1.88497979543377169875,
|
|
925
|
+
cbrtP2 = 1.621429720105354466140, cbrtP3 = -0.758397934778766047437,
|
|
926
|
+
cbrtP4 = 0.145996192886612446982;
|
|
927
|
+
|
|
928
|
+
function detCbrt(x) {
|
|
929
|
+
let hx = HI(x);
|
|
930
|
+
const sign = hx & 0x80000000;
|
|
931
|
+
hx &= 0x7fffffff;
|
|
932
|
+
if (hx >= 0x7ff00000) return x + x;
|
|
933
|
+
let t;
|
|
934
|
+
if (hx < 0x00100000) {
|
|
935
|
+
if ((hx | LO(x)) === 0) return x;
|
|
936
|
+
t = two54 * x;
|
|
937
|
+
t = setHi(t, (sign | ((((HI(t) & 0x7fffffff) / 3) | 0) + cbrtB2)) >>> 0);
|
|
938
|
+
} else {
|
|
939
|
+
t = fromWords((sign | (((hx / 3) | 0) + cbrtB1)) >>> 0, 0);
|
|
940
|
+
}
|
|
941
|
+
const r0 = (t * t) * (t / x);
|
|
942
|
+
t *= cbrtP0 + r0 * (cbrtP1 + r0 * (cbrtP2 + r0 * (cbrtP3 + r0 * cbrtP4)));
|
|
943
|
+
// round t to 23 bits, away from zero: bits = (bits + 0x80000000) & ~0x3fffffff
|
|
944
|
+
let tHi = HI(t), tLo = LO(t) >>> 0;
|
|
945
|
+
tHi = (tHi + (tLo >= 0x80000000 ? 1 : 0)) | 0;
|
|
946
|
+
tLo = (tLo + 0x80000000) >>> 0;
|
|
947
|
+
t = fromWords(tHi >>> 0, tLo & 0xc0000000);
|
|
948
|
+
const s = t * t;
|
|
949
|
+
let r = x / s;
|
|
950
|
+
const w = t + t;
|
|
951
|
+
r = (r - t) / (w + r);
|
|
952
|
+
return t + t * r;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
// ---- hypot (FreeBSD e_hypot, folded left for arity > 2) -------------------
|
|
956
|
+
function detHypot2(x, y) {
|
|
957
|
+
let ha = HI(x) & 0x7fffffff;
|
|
958
|
+
let hb = HI(y) & 0x7fffffff;
|
|
959
|
+
let a, b;
|
|
960
|
+
if (hb > ha) { a = y; b = x; const j = ha; ha = hb; hb = j; } else { a = x; b = y; }
|
|
961
|
+
a = abs(a); b = abs(b);
|
|
962
|
+
if (ha - hb > 0x3c00000) return a + b;
|
|
963
|
+
let k = 0;
|
|
964
|
+
if (ha > 0x5f300000) {
|
|
965
|
+
if (ha >= 0x7ff00000) {
|
|
966
|
+
let w = abs(x + 0.0) - abs(y + 0.0);
|
|
967
|
+
if (((ha & 0xfffff) | LO(a)) === 0) w = a;
|
|
968
|
+
if ((((hb ^ 0x7ff00000) | 0) | LO(b)) === 0) w = b;
|
|
969
|
+
return w;
|
|
970
|
+
}
|
|
971
|
+
ha -= 0x25800000; hb -= 0x25800000; k += 600;
|
|
972
|
+
a = setHi(a, ha >>> 0);
|
|
973
|
+
b = setHi(b, hb >>> 0);
|
|
974
|
+
}
|
|
975
|
+
if (hb < 0x20b00000) {
|
|
976
|
+
if (hb <= 0x000fffff) {
|
|
977
|
+
if ((hb | LO(b)) === 0) return a;
|
|
978
|
+
const scale = fromWords(0x7fd00000, 0);
|
|
979
|
+
b *= scale;
|
|
980
|
+
a *= scale;
|
|
981
|
+
k -= 1022;
|
|
982
|
+
ha = HI(a); hb = HI(b);
|
|
983
|
+
} else {
|
|
984
|
+
ha += 0x25800000; hb += 0x25800000; k -= 600;
|
|
985
|
+
a = setHi(a, ha >>> 0);
|
|
986
|
+
b = setHi(b, hb >>> 0);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
let w = a - b;
|
|
990
|
+
if (w > b) {
|
|
991
|
+
const t1 = fromWords(ha >>> 0, 0);
|
|
992
|
+
const t2 = a - t1;
|
|
993
|
+
w = sqrt(t1 * t1 - (b * (-b) - t2 * (a + t1)));
|
|
994
|
+
} else {
|
|
995
|
+
a = a + a;
|
|
996
|
+
const y1 = fromWords(hb >>> 0, 0);
|
|
997
|
+
const y2 = b - y1;
|
|
998
|
+
const t1 = fromWords((ha + 0x00100000) >>> 0, 0);
|
|
999
|
+
const t2 = a - t1;
|
|
1000
|
+
w = sqrt(t1 * y1 - (w * (-w) - (t1 * y2 + t2 * b)));
|
|
1001
|
+
}
|
|
1002
|
+
if (k !== 0) {
|
|
1003
|
+
const scale = setHi(1.0, (HI(1.0) + (k << 20)) >>> 0);
|
|
1004
|
+
return scale * w;
|
|
1005
|
+
}
|
|
1006
|
+
return w;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
function detHypot(...values) {
|
|
1010
|
+
// Left fold of the pairwise kernel: deterministic on every engine; for
|
|
1011
|
+
// arity > 2 this is NOT the same rounding as a simultaneous algorithm,
|
|
1012
|
+
// which is exactly why it must be pinned here.
|
|
1013
|
+
let w = 0.0;
|
|
1014
|
+
for (let i = 0; i < values.length; i += 1) w = detHypot2(w, +values[i]);
|
|
1015
|
+
return w;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
Math.exp = detExp;
|
|
1019
|
+
Math.atan = detAtan;
|
|
1020
|
+
Math.atan2 = detAtan2;
|
|
1021
|
+
Math.log1p = detLog1p;
|
|
1022
|
+
Math.asinh = detAsinh;
|
|
1023
|
+
Math.acosh = detAcosh;
|
|
1024
|
+
Math.atanh = detAtanh;
|
|
1025
|
+
Math.sin = detSin;
|
|
1026
|
+
Math.cos = detCos;
|
|
1027
|
+
Math.tan = detTan;
|
|
1028
|
+
Math.log = detLog;
|
|
1029
|
+
Math.log10 = detLog10;
|
|
1030
|
+
Math.asin = detAsin;
|
|
1031
|
+
Math.acos = detAcos;
|
|
1032
|
+
Math.sinh = detSinh;
|
|
1033
|
+
Math.cosh = detCosh;
|
|
1034
|
+
Math.tanh = detTanh;
|
|
1035
|
+
Math.expm1 = detExpm1;
|
|
1036
|
+
Math.log2 = detLog2;
|
|
1037
|
+
Math.cbrt = detCbrt;
|
|
1038
|
+
Math.hypot = detHypot;
|
|
1039
|
+
})();`;
|
|
1040
|
+
|
|
1041
|
+
export function installDeterministicMath() {
|
|
1042
|
+
// eslint-disable-next-line no-new-func
|
|
1043
|
+
new Function(DETERMINISTIC_MATH_SOURCE)();
|
|
1044
|
+
}
|