@ohif/app 3.10.0-beta.0 → 3.10.0-beta.10
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/dist/{1185.bundle.a6e220f00576d6926fe7.js → 1185.bundle.e63cef8446357b933672.js} +76 -11
- package/dist/{1266.bundle.8fd38b710e91305721e5.js → 1266.bundle.6ffa84cbf1408fcfd010.js} +25 -0
- package/dist/1266.css +1 -1
- package/dist/{1520.bundle.60fd5dd97de96c329748.js → 1520.bundle.5ebd373bdb50045c845d.js} +19 -11
- package/dist/1801.css +1 -1
- package/dist/{1927.bundle.49539e3ab5b0aad1399c.js → 1927.bundle.c55edd5a362e7d79e23d.js} +1 -1
- package/dist/3198.css +1 -1
- package/dist/{3200.bundle.45b19ea468d6208f0e7e.js → 3200.bundle.efc18fabd0ffd53057ad.js} +2 -2
- package/dist/3200.css +1 -1
- package/dist/{3677.bundle.7d9110e8c5682b56a456.js → 3677.bundle.b3ac66bea976765cde72.js} +30 -18
- package/dist/{3970.bundle.31942cc0c12a008e7ba0.js → 3970.bundle.dc6cd064ae2aeabe09bd.js} +13 -3
- package/dist/4182.css +1 -1
- package/dist/{4571.bundle.3b1691730b3c57bf4d35.js → 4571.bundle.142e8f6150bf81f1b7d2.js} +129 -107
- package/dist/5139.css +1 -1
- package/dist/{5247.bundle.03fa8aac71d4e597d708.js → 5247.bundle.dc1f8916871daa28d1ec.js} +2 -2
- package/dist/{5252.bundle.5ec502c53a9cc877ed8d.js → 5252.bundle.bc5ffde6db3fa348763e.js} +43 -19
- package/dist/{5717.bundle.848e13f256818475f57f.js → 5717.bundle.ef66d725a6417d6c11ca.js} +395 -94
- package/dist/{5823.bundle.cb588e5e33eea80cd49f.js → 5823.bundle.c4aac836954d54e38b4e.js} +2 -9
- package/dist/717.css +1 -1
- package/dist/{1436.bundle.773756cd51b69e887bac.js → 8104.bundle.e1a5126a7f7ba0e15fae.js} +357 -112
- package/dist/8228.css +2 -2
- package/dist/{8523.bundle.648334132159465cdc41.js → 8523.bundle.c0ec85de98ba380ebeb4.js} +55 -13
- package/dist/{8558.bundle.3b0654ad2a52ac9786dd.js → 8558.bundle.34b846e3b0f870ea33cb.js} +1 -0
- package/dist/{5807.bundle.dac5ce36534a71c77723.js → 967.bundle.fee0d6c1e9e244ad5bb3.js} +1134 -1128
- package/dist/{149.bundle.b8d177954628f4631fc0.js → 9909.bundle.3d2b059390abcf2c925b.js} +161 -34
- package/dist/{app.bundle.e76165bb9c66e71db096.js → app.bundle.a1b3010c5d6c12837e17.js} +7928 -7884
- package/dist/app.bundle.css +18 -18
- package/dist/{histogram-worker.bundle.f0e060cf2637a2ca94b7.js → histogram-worker.bundle.85d57affe3baefc07925.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/{polySeg.bundle.b79ae514989e86301c71.js → polySeg.bundle.b69067365f2c2b916638.js} +1 -1
- package/dist/{suv-peak-worker.bundle.76dd4fdf82aaa2c3ad41.js → suv-peak-worker.bundle.cad6eeb6d738dc482be2.js} +3 -3
- package/dist/sw.js +1 -1
- package/package.json +19 -19
- /package/dist/{1374.bundle.f56c07364d8f6ed2d00e.js → 1374.bundle.833030ac08325d881c61.js} +0 -0
- /package/dist/{213.bundle.38caad239bcfec1d28fb.js → 213.bundle.f197401cd6547f6ff838.js} +0 -0
- /package/dist/{2424.bundle.c7b6d3475da1ffff744b.js → 2424.bundle.8dc654dd5b8a1ea90c90.js} +0 -0
- /package/dist/{2701.bundle.8c1ff2e0faaa7d2f4716.js → 2701.bundle.46f7148916e85e1cf4f4.js} +0 -0
- /package/dist/{2825.bundle.ba60e0011bcebdf7a413.js → 2825.bundle.96074384e8e37e0e021e.js} +0 -0
- /package/dist/{3121.bundle.d3e7092e305cf6cecdb5.js → 3121.bundle.67ff7e799683191bb324.js} +0 -0
- /package/dist/{3198.bundle.9b80ca2f1d99a7f9a4fe.js → 3198.bundle.4482082ca49ae5eea878.js} +0 -0
- /package/dist/{4202.bundle.5c8120ed4841da0af211.js → 4202.bundle.1311396ecdb6c0b09eb0.js} +0 -0
- /package/dist/{4834.bundle.4bfa1bd1d4a163de3350.js → 4834.bundle.7ee289df357aa46f131c.js} +0 -0
- /package/dist/{5139.bundle.b185b1df3847a2025829.js → 5139.bundle.d8f900bab68939cfd9fa.js} +0 -0
- /package/dist/{5261.bundle.74682659cce85f3ae592.js → 5261.bundle.54d7af66923a3bae707d.js} +0 -0
- /package/dist/{5687.bundle.3a558ac2eb26f5295668.js → 5687.bundle.0e0b349a72046c0e37bf.js} +0 -0
- /package/dist/{6939.bundle.9b79da82315a25f37d96.js → 6939.bundle.5e77a634e8784085c00e.js} +0 -0
- /package/dist/{7159.bundle.9f4856182f1eda29c59d.js → 7159.bundle.4ee84ebbce84383e30d4.js} +0 -0
- /package/dist/{717.bundle.62437bfeb54f01269abe.js → 717.bundle.06d5b435702c14013575.js} +0 -0
- /package/dist/{7197.bundle.db0d51e5529d88a4cd7f.js → 7197.bundle.d65cb32c7302143947d9.js} +0 -0
- /package/dist/{7955.bundle.699bffabae3a9915c326.js → 7955.bundle.408d0c295e30bc15ec21.js} +0 -0
- /package/dist/{8008.bundle.1ab47eccf7608fe14e92.js → 8008.bundle.6dd3113a5e440da583d1.js} +0 -0
- /package/dist/{8228.bundle.55ac03d7165248f47d4e.js → 8228.bundle.0c1f0d650adb9be44119.js} +0 -0
- /package/dist/{8259.bundle.4385bd89c3f7f4ced27c.js → 8259.bundle.61d6c45f3146ae624d3f.js} +0 -0
- /package/dist/{8295.bundle.4ecb27f9e58526f12bcb.js → 8295.bundle.14cddaccdcd3a7093398.js} +0 -0
- /package/dist/{9551.bundle.13a3eec1e003a46095bc.js → 9551.bundle.5fafcf2062ff29fcc7d4.js} +0 -0
- /package/dist/{9611.bundle.767595c93877e5166c03.js → 9611.bundle.bde27586a38e3b906f40.js} +0 -0
- /package/dist/{9862.bundle.7146682e56aa66130ae6.js → 9862.bundle.589cd2f5bf71e03152a1.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(self["webpackChunk"] = self["webpackChunk"] || []).push([[
|
|
1
|
+
(self["webpackChunk"] = self["webpackChunk"] || []).push([[967],{
|
|
2
2
|
|
|
3
3
|
/***/ 2682:
|
|
4
4
|
/***/ ((module) => {
|
|
@@ -85,898 +85,6 @@ module.exports = function (str) {
|
|
|
85
85
|
return result;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
/***/ }),
|
|
89
|
-
|
|
90
|
-
/***/ 67042:
|
|
91
|
-
/***/ (function(module) {
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @license Fraction.js v4.3.0 20/08/2023
|
|
95
|
-
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
|
|
96
|
-
*
|
|
97
|
-
* Copyright (c) 2023, Robert Eisele (robert@raw.org)
|
|
98
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
99
|
-
**/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
*
|
|
104
|
-
* This class offers the possibility to calculate fractions.
|
|
105
|
-
* You can pass a fraction in different formats. Either as array, as double, as string or as an integer.
|
|
106
|
-
*
|
|
107
|
-
* Array/Object form
|
|
108
|
-
* [ 0 => <numerator>, 1 => <denominator> ]
|
|
109
|
-
* [ n => <numerator>, d => <denominator> ]
|
|
110
|
-
*
|
|
111
|
-
* Integer form
|
|
112
|
-
* - Single integer value
|
|
113
|
-
*
|
|
114
|
-
* Double form
|
|
115
|
-
* - Single double value
|
|
116
|
-
*
|
|
117
|
-
* String form
|
|
118
|
-
* 123.456 - a simple double
|
|
119
|
-
* 123/456 - a string fraction
|
|
120
|
-
* 123.'456' - a double with repeating decimal places
|
|
121
|
-
* 123.(456) - synonym
|
|
122
|
-
* 123.45'6' - a double with repeating last place
|
|
123
|
-
* 123.45(6) - synonym
|
|
124
|
-
*
|
|
125
|
-
* Example:
|
|
126
|
-
*
|
|
127
|
-
* var f = new Fraction("9.4'31'");
|
|
128
|
-
* f.mul([-4, 3]).div(4.9);
|
|
129
|
-
*
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
(function(root) {
|
|
133
|
-
|
|
134
|
-
"use strict";
|
|
135
|
-
|
|
136
|
-
// Maximum search depth for cyclic rational numbers. 2000 should be more than enough.
|
|
137
|
-
// Example: 1/7 = 0.(142857) has 6 repeating decimal places.
|
|
138
|
-
// If MAX_CYCLE_LEN gets reduced, long cycles will not be detected and toString() only gets the first 10 digits
|
|
139
|
-
var MAX_CYCLE_LEN = 2000;
|
|
140
|
-
|
|
141
|
-
// Parsed data to avoid calling "new" all the time
|
|
142
|
-
var P = {
|
|
143
|
-
"s": 1,
|
|
144
|
-
"n": 0,
|
|
145
|
-
"d": 1
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
function assign(n, s) {
|
|
149
|
-
|
|
150
|
-
if (isNaN(n = parseInt(n, 10))) {
|
|
151
|
-
throw InvalidParameter();
|
|
152
|
-
}
|
|
153
|
-
return n * s;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Creates a new Fraction internally without the need of the bulky constructor
|
|
157
|
-
function newFraction(n, d) {
|
|
158
|
-
|
|
159
|
-
if (d === 0) {
|
|
160
|
-
throw DivisionByZero();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
var f = Object.create(Fraction.prototype);
|
|
164
|
-
f["s"] = n < 0 ? -1 : 1;
|
|
165
|
-
|
|
166
|
-
n = n < 0 ? -n : n;
|
|
167
|
-
|
|
168
|
-
var a = gcd(n, d);
|
|
169
|
-
|
|
170
|
-
f["n"] = n / a;
|
|
171
|
-
f["d"] = d / a;
|
|
172
|
-
return f;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function factorize(num) {
|
|
176
|
-
|
|
177
|
-
var factors = {};
|
|
178
|
-
|
|
179
|
-
var n = num;
|
|
180
|
-
var i = 2;
|
|
181
|
-
var s = 4;
|
|
182
|
-
|
|
183
|
-
while (s <= n) {
|
|
184
|
-
|
|
185
|
-
while (n % i === 0) {
|
|
186
|
-
n/= i;
|
|
187
|
-
factors[i] = (factors[i] || 0) + 1;
|
|
188
|
-
}
|
|
189
|
-
s+= 1 + 2 * i++;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (n !== num) {
|
|
193
|
-
if (n > 1)
|
|
194
|
-
factors[n] = (factors[n] || 0) + 1;
|
|
195
|
-
} else {
|
|
196
|
-
factors[num] = (factors[num] || 0) + 1;
|
|
197
|
-
}
|
|
198
|
-
return factors;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
var parse = function(p1, p2) {
|
|
202
|
-
|
|
203
|
-
var n = 0, d = 1, s = 1;
|
|
204
|
-
var v = 0, w = 0, x = 0, y = 1, z = 1;
|
|
205
|
-
|
|
206
|
-
var A = 0, B = 1;
|
|
207
|
-
var C = 1, D = 1;
|
|
208
|
-
|
|
209
|
-
var N = 10000000;
|
|
210
|
-
var M;
|
|
211
|
-
|
|
212
|
-
if (p1 === undefined || p1 === null) {
|
|
213
|
-
/* void */
|
|
214
|
-
} else if (p2 !== undefined) {
|
|
215
|
-
n = p1;
|
|
216
|
-
d = p2;
|
|
217
|
-
s = n * d;
|
|
218
|
-
|
|
219
|
-
if (n % 1 !== 0 || d % 1 !== 0) {
|
|
220
|
-
throw NonIntegerParameter();
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
} else
|
|
224
|
-
switch (typeof p1) {
|
|
225
|
-
|
|
226
|
-
case "object":
|
|
227
|
-
{
|
|
228
|
-
if ("d" in p1 && "n" in p1) {
|
|
229
|
-
n = p1["n"];
|
|
230
|
-
d = p1["d"];
|
|
231
|
-
if ("s" in p1)
|
|
232
|
-
n*= p1["s"];
|
|
233
|
-
} else if (0 in p1) {
|
|
234
|
-
n = p1[0];
|
|
235
|
-
if (1 in p1)
|
|
236
|
-
d = p1[1];
|
|
237
|
-
} else {
|
|
238
|
-
throw InvalidParameter();
|
|
239
|
-
}
|
|
240
|
-
s = n * d;
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
case "number":
|
|
244
|
-
{
|
|
245
|
-
if (p1 < 0) {
|
|
246
|
-
s = p1;
|
|
247
|
-
p1 = -p1;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (p1 % 1 === 0) {
|
|
251
|
-
n = p1;
|
|
252
|
-
} else if (p1 > 0) { // check for != 0, scale would become NaN (log(0)), which converges really slow
|
|
253
|
-
|
|
254
|
-
if (p1 >= 1) {
|
|
255
|
-
z = Math.pow(10, Math.floor(1 + Math.log(p1) / Math.LN10));
|
|
256
|
-
p1/= z;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// Using Farey Sequences
|
|
260
|
-
// http://www.johndcook.com/blog/2010/10/20/best-rational-approximation/
|
|
261
|
-
|
|
262
|
-
while (B <= N && D <= N) {
|
|
263
|
-
M = (A + C) / (B + D);
|
|
264
|
-
|
|
265
|
-
if (p1 === M) {
|
|
266
|
-
if (B + D <= N) {
|
|
267
|
-
n = A + C;
|
|
268
|
-
d = B + D;
|
|
269
|
-
} else if (D > B) {
|
|
270
|
-
n = C;
|
|
271
|
-
d = D;
|
|
272
|
-
} else {
|
|
273
|
-
n = A;
|
|
274
|
-
d = B;
|
|
275
|
-
}
|
|
276
|
-
break;
|
|
277
|
-
|
|
278
|
-
} else {
|
|
279
|
-
|
|
280
|
-
if (p1 > M) {
|
|
281
|
-
A+= C;
|
|
282
|
-
B+= D;
|
|
283
|
-
} else {
|
|
284
|
-
C+= A;
|
|
285
|
-
D+= B;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (B > N) {
|
|
289
|
-
n = C;
|
|
290
|
-
d = D;
|
|
291
|
-
} else {
|
|
292
|
-
n = A;
|
|
293
|
-
d = B;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
n*= z;
|
|
298
|
-
} else if (isNaN(p1) || isNaN(p2)) {
|
|
299
|
-
d = n = NaN;
|
|
300
|
-
}
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
case "string":
|
|
304
|
-
{
|
|
305
|
-
B = p1.match(/\d+|./g);
|
|
306
|
-
|
|
307
|
-
if (B === null)
|
|
308
|
-
throw InvalidParameter();
|
|
309
|
-
|
|
310
|
-
if (B[A] === '-') {// Check for minus sign at the beginning
|
|
311
|
-
s = -1;
|
|
312
|
-
A++;
|
|
313
|
-
} else if (B[A] === '+') {// Check for plus sign at the beginning
|
|
314
|
-
A++;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if (B.length === A + 1) { // Check if it's just a simple number "1234"
|
|
318
|
-
w = assign(B[A++], s);
|
|
319
|
-
} else if (B[A + 1] === '.' || B[A] === '.') { // Check if it's a decimal number
|
|
320
|
-
|
|
321
|
-
if (B[A] !== '.') { // Handle 0.5 and .5
|
|
322
|
-
v = assign(B[A++], s);
|
|
323
|
-
}
|
|
324
|
-
A++;
|
|
325
|
-
|
|
326
|
-
// Check for decimal places
|
|
327
|
-
if (A + 1 === B.length || B[A + 1] === '(' && B[A + 3] === ')' || B[A + 1] === "'" && B[A + 3] === "'") {
|
|
328
|
-
w = assign(B[A], s);
|
|
329
|
-
y = Math.pow(10, B[A].length);
|
|
330
|
-
A++;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// Check for repeating places
|
|
334
|
-
if (B[A] === '(' && B[A + 2] === ')' || B[A] === "'" && B[A + 2] === "'") {
|
|
335
|
-
x = assign(B[A + 1], s);
|
|
336
|
-
z = Math.pow(10, B[A + 1].length) - 1;
|
|
337
|
-
A+= 3;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
} else if (B[A + 1] === '/' || B[A + 1] === ':') { // Check for a simple fraction "123/456" or "123:456"
|
|
341
|
-
w = assign(B[A], s);
|
|
342
|
-
y = assign(B[A + 2], 1);
|
|
343
|
-
A+= 3;
|
|
344
|
-
} else if (B[A + 3] === '/' && B[A + 1] === ' ') { // Check for a complex fraction "123 1/2"
|
|
345
|
-
v = assign(B[A], s);
|
|
346
|
-
w = assign(B[A + 2], s);
|
|
347
|
-
y = assign(B[A + 4], 1);
|
|
348
|
-
A+= 5;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
if (B.length <= A) { // Check for more tokens on the stack
|
|
352
|
-
d = y * z;
|
|
353
|
-
s = /* void */
|
|
354
|
-
n = x + d * v + z * w;
|
|
355
|
-
break;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/* Fall through on error */
|
|
359
|
-
}
|
|
360
|
-
default:
|
|
361
|
-
throw InvalidParameter();
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
if (d === 0) {
|
|
365
|
-
throw DivisionByZero();
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
P["s"] = s < 0 ? -1 : 1;
|
|
369
|
-
P["n"] = Math.abs(n);
|
|
370
|
-
P["d"] = Math.abs(d);
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
function modpow(b, e, m) {
|
|
374
|
-
|
|
375
|
-
var r = 1;
|
|
376
|
-
for (; e > 0; b = (b * b) % m, e >>= 1) {
|
|
377
|
-
|
|
378
|
-
if (e & 1) {
|
|
379
|
-
r = (r * b) % m;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
return r;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
function cycleLen(n, d) {
|
|
387
|
-
|
|
388
|
-
for (; d % 2 === 0;
|
|
389
|
-
d/= 2) {
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
for (; d % 5 === 0;
|
|
393
|
-
d/= 5) {
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if (d === 1) // Catch non-cyclic numbers
|
|
397
|
-
return 0;
|
|
398
|
-
|
|
399
|
-
// If we would like to compute really large numbers quicker, we could make use of Fermat's little theorem:
|
|
400
|
-
// 10^(d-1) % d == 1
|
|
401
|
-
// However, we don't need such large numbers and MAX_CYCLE_LEN should be the capstone,
|
|
402
|
-
// as we want to translate the numbers to strings.
|
|
403
|
-
|
|
404
|
-
var rem = 10 % d;
|
|
405
|
-
var t = 1;
|
|
406
|
-
|
|
407
|
-
for (; rem !== 1; t++) {
|
|
408
|
-
rem = rem * 10 % d;
|
|
409
|
-
|
|
410
|
-
if (t > MAX_CYCLE_LEN)
|
|
411
|
-
return 0; // Returning 0 here means that we don't print it as a cyclic number. It's likely that the answer is `d-1`
|
|
412
|
-
}
|
|
413
|
-
return t;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
function cycleStart(n, d, len) {
|
|
418
|
-
|
|
419
|
-
var rem1 = 1;
|
|
420
|
-
var rem2 = modpow(10, len, d);
|
|
421
|
-
|
|
422
|
-
for (var t = 0; t < 300; t++) { // s < ~log10(Number.MAX_VALUE)
|
|
423
|
-
// Solve 10^s == 10^(s+t) (mod d)
|
|
424
|
-
|
|
425
|
-
if (rem1 === rem2)
|
|
426
|
-
return t;
|
|
427
|
-
|
|
428
|
-
rem1 = rem1 * 10 % d;
|
|
429
|
-
rem2 = rem2 * 10 % d;
|
|
430
|
-
}
|
|
431
|
-
return 0;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
function gcd(a, b) {
|
|
435
|
-
|
|
436
|
-
if (!a)
|
|
437
|
-
return b;
|
|
438
|
-
if (!b)
|
|
439
|
-
return a;
|
|
440
|
-
|
|
441
|
-
while (1) {
|
|
442
|
-
a%= b;
|
|
443
|
-
if (!a)
|
|
444
|
-
return b;
|
|
445
|
-
b%= a;
|
|
446
|
-
if (!b)
|
|
447
|
-
return a;
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Module constructor
|
|
453
|
-
*
|
|
454
|
-
* @constructor
|
|
455
|
-
* @param {number|Fraction=} a
|
|
456
|
-
* @param {number=} b
|
|
457
|
-
*/
|
|
458
|
-
function Fraction(a, b) {
|
|
459
|
-
|
|
460
|
-
parse(a, b);
|
|
461
|
-
|
|
462
|
-
if (this instanceof Fraction) {
|
|
463
|
-
a = gcd(P["d"], P["n"]); // Abuse variable a
|
|
464
|
-
this["s"] = P["s"];
|
|
465
|
-
this["n"] = P["n"] / a;
|
|
466
|
-
this["d"] = P["d"] / a;
|
|
467
|
-
} else {
|
|
468
|
-
return newFraction(P['s'] * P['n'], P['d']);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
var DivisionByZero = function() { return new Error("Division by Zero"); };
|
|
473
|
-
var InvalidParameter = function() { return new Error("Invalid argument"); };
|
|
474
|
-
var NonIntegerParameter = function() { return new Error("Parameters must be integer"); };
|
|
475
|
-
|
|
476
|
-
Fraction.prototype = {
|
|
477
|
-
|
|
478
|
-
"s": 1,
|
|
479
|
-
"n": 0,
|
|
480
|
-
"d": 1,
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Calculates the absolute value
|
|
484
|
-
*
|
|
485
|
-
* Ex: new Fraction(-4).abs() => 4
|
|
486
|
-
**/
|
|
487
|
-
"abs": function() {
|
|
488
|
-
|
|
489
|
-
return newFraction(this["n"], this["d"]);
|
|
490
|
-
},
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* Inverts the sign of the current fraction
|
|
494
|
-
*
|
|
495
|
-
* Ex: new Fraction(-4).neg() => 4
|
|
496
|
-
**/
|
|
497
|
-
"neg": function() {
|
|
498
|
-
|
|
499
|
-
return newFraction(-this["s"] * this["n"], this["d"]);
|
|
500
|
-
},
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Adds two rational numbers
|
|
504
|
-
*
|
|
505
|
-
* Ex: new Fraction({n: 2, d: 3}).add("14.9") => 467 / 30
|
|
506
|
-
**/
|
|
507
|
-
"add": function(a, b) {
|
|
508
|
-
|
|
509
|
-
parse(a, b);
|
|
510
|
-
return newFraction(
|
|
511
|
-
this["s"] * this["n"] * P["d"] + P["s"] * this["d"] * P["n"],
|
|
512
|
-
this["d"] * P["d"]
|
|
513
|
-
);
|
|
514
|
-
},
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Subtracts two rational numbers
|
|
518
|
-
*
|
|
519
|
-
* Ex: new Fraction({n: 2, d: 3}).add("14.9") => -427 / 30
|
|
520
|
-
**/
|
|
521
|
-
"sub": function(a, b) {
|
|
522
|
-
|
|
523
|
-
parse(a, b);
|
|
524
|
-
return newFraction(
|
|
525
|
-
this["s"] * this["n"] * P["d"] - P["s"] * this["d"] * P["n"],
|
|
526
|
-
this["d"] * P["d"]
|
|
527
|
-
);
|
|
528
|
-
},
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* Multiplies two rational numbers
|
|
532
|
-
*
|
|
533
|
-
* Ex: new Fraction("-17.(345)").mul(3) => 5776 / 111
|
|
534
|
-
**/
|
|
535
|
-
"mul": function(a, b) {
|
|
536
|
-
|
|
537
|
-
parse(a, b);
|
|
538
|
-
return newFraction(
|
|
539
|
-
this["s"] * P["s"] * this["n"] * P["n"],
|
|
540
|
-
this["d"] * P["d"]
|
|
541
|
-
);
|
|
542
|
-
},
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Divides two rational numbers
|
|
546
|
-
*
|
|
547
|
-
* Ex: new Fraction("-17.(345)").inverse().div(3)
|
|
548
|
-
**/
|
|
549
|
-
"div": function(a, b) {
|
|
550
|
-
|
|
551
|
-
parse(a, b);
|
|
552
|
-
return newFraction(
|
|
553
|
-
this["s"] * P["s"] * this["n"] * P["d"],
|
|
554
|
-
this["d"] * P["n"]
|
|
555
|
-
);
|
|
556
|
-
},
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* Clones the actual object
|
|
560
|
-
*
|
|
561
|
-
* Ex: new Fraction("-17.(345)").clone()
|
|
562
|
-
**/
|
|
563
|
-
"clone": function() {
|
|
564
|
-
return newFraction(this['s'] * this['n'], this['d']);
|
|
565
|
-
},
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Calculates the modulo of two rational numbers - a more precise fmod
|
|
569
|
-
*
|
|
570
|
-
* Ex: new Fraction('4.(3)').mod([7, 8]) => (13/3) % (7/8) = (5/6)
|
|
571
|
-
**/
|
|
572
|
-
"mod": function(a, b) {
|
|
573
|
-
|
|
574
|
-
if (isNaN(this['n']) || isNaN(this['d'])) {
|
|
575
|
-
return new Fraction(NaN);
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
if (a === undefined) {
|
|
579
|
-
return newFraction(this["s"] * this["n"] % this["d"], 1);
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
parse(a, b);
|
|
583
|
-
if (0 === P["n"] && 0 === this["d"]) {
|
|
584
|
-
throw DivisionByZero();
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/*
|
|
588
|
-
* First silly attempt, kinda slow
|
|
589
|
-
*
|
|
590
|
-
return that["sub"]({
|
|
591
|
-
"n": num["n"] * Math.floor((this.n / this.d) / (num.n / num.d)),
|
|
592
|
-
"d": num["d"],
|
|
593
|
-
"s": this["s"]
|
|
594
|
-
});*/
|
|
595
|
-
|
|
596
|
-
/*
|
|
597
|
-
* New attempt: a1 / b1 = a2 / b2 * q + r
|
|
598
|
-
* => b2 * a1 = a2 * b1 * q + b1 * b2 * r
|
|
599
|
-
* => (b2 * a1 % a2 * b1) / (b1 * b2)
|
|
600
|
-
*/
|
|
601
|
-
return newFraction(
|
|
602
|
-
this["s"] * (P["d"] * this["n"]) % (P["n"] * this["d"]),
|
|
603
|
-
P["d"] * this["d"]
|
|
604
|
-
);
|
|
605
|
-
},
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Calculates the fractional gcd of two rational numbers
|
|
609
|
-
*
|
|
610
|
-
* Ex: new Fraction(5,8).gcd(3,7) => 1/56
|
|
611
|
-
*/
|
|
612
|
-
"gcd": function(a, b) {
|
|
613
|
-
|
|
614
|
-
parse(a, b);
|
|
615
|
-
|
|
616
|
-
// gcd(a / b, c / d) = gcd(a, c) / lcm(b, d)
|
|
617
|
-
|
|
618
|
-
return newFraction(gcd(P["n"], this["n"]) * gcd(P["d"], this["d"]), P["d"] * this["d"]);
|
|
619
|
-
},
|
|
620
|
-
|
|
621
|
-
/**
|
|
622
|
-
* Calculates the fractional lcm of two rational numbers
|
|
623
|
-
*
|
|
624
|
-
* Ex: new Fraction(5,8).lcm(3,7) => 15
|
|
625
|
-
*/
|
|
626
|
-
"lcm": function(a, b) {
|
|
627
|
-
|
|
628
|
-
parse(a, b);
|
|
629
|
-
|
|
630
|
-
// lcm(a / b, c / d) = lcm(a, c) / gcd(b, d)
|
|
631
|
-
|
|
632
|
-
if (P["n"] === 0 && this["n"] === 0) {
|
|
633
|
-
return newFraction(0, 1);
|
|
634
|
-
}
|
|
635
|
-
return newFraction(P["n"] * this["n"], gcd(P["n"], this["n"]) * gcd(P["d"], this["d"]));
|
|
636
|
-
},
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* Calculates the ceil of a rational number
|
|
640
|
-
*
|
|
641
|
-
* Ex: new Fraction('4.(3)').ceil() => (5 / 1)
|
|
642
|
-
**/
|
|
643
|
-
"ceil": function(places) {
|
|
644
|
-
|
|
645
|
-
places = Math.pow(10, places || 0);
|
|
646
|
-
|
|
647
|
-
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
|
648
|
-
return new Fraction(NaN);
|
|
649
|
-
}
|
|
650
|
-
return newFraction(Math.ceil(places * this["s"] * this["n"] / this["d"]), places);
|
|
651
|
-
},
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* Calculates the floor of a rational number
|
|
655
|
-
*
|
|
656
|
-
* Ex: new Fraction('4.(3)').floor() => (4 / 1)
|
|
657
|
-
**/
|
|
658
|
-
"floor": function(places) {
|
|
659
|
-
|
|
660
|
-
places = Math.pow(10, places || 0);
|
|
661
|
-
|
|
662
|
-
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
|
663
|
-
return new Fraction(NaN);
|
|
664
|
-
}
|
|
665
|
-
return newFraction(Math.floor(places * this["s"] * this["n"] / this["d"]), places);
|
|
666
|
-
},
|
|
667
|
-
|
|
668
|
-
/**
|
|
669
|
-
* Rounds a rational numbers
|
|
670
|
-
*
|
|
671
|
-
* Ex: new Fraction('4.(3)').round() => (4 / 1)
|
|
672
|
-
**/
|
|
673
|
-
"round": function(places) {
|
|
674
|
-
|
|
675
|
-
places = Math.pow(10, places || 0);
|
|
676
|
-
|
|
677
|
-
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
|
678
|
-
return new Fraction(NaN);
|
|
679
|
-
}
|
|
680
|
-
return newFraction(Math.round(places * this["s"] * this["n"] / this["d"]), places);
|
|
681
|
-
},
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* Gets the inverse of the fraction, means numerator and denominator are exchanged
|
|
685
|
-
*
|
|
686
|
-
* Ex: new Fraction([-3, 4]).inverse() => -4 / 3
|
|
687
|
-
**/
|
|
688
|
-
"inverse": function() {
|
|
689
|
-
|
|
690
|
-
return newFraction(this["s"] * this["d"], this["n"]);
|
|
691
|
-
},
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* Calculates the fraction to some rational exponent, if possible
|
|
695
|
-
*
|
|
696
|
-
* Ex: new Fraction(-1,2).pow(-3) => -8
|
|
697
|
-
*/
|
|
698
|
-
"pow": function(a, b) {
|
|
699
|
-
|
|
700
|
-
parse(a, b);
|
|
701
|
-
|
|
702
|
-
// Trivial case when exp is an integer
|
|
703
|
-
|
|
704
|
-
if (P['d'] === 1) {
|
|
705
|
-
|
|
706
|
-
if (P['s'] < 0) {
|
|
707
|
-
return newFraction(Math.pow(this['s'] * this["d"], P['n']), Math.pow(this["n"], P['n']));
|
|
708
|
-
} else {
|
|
709
|
-
return newFraction(Math.pow(this['s'] * this["n"], P['n']), Math.pow(this["d"], P['n']));
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// Negative roots become complex
|
|
714
|
-
// (-a/b)^(c/d) = x
|
|
715
|
-
// <=> (-1)^(c/d) * (a/b)^(c/d) = x
|
|
716
|
-
// <=> (cos(pi) + i*sin(pi))^(c/d) * (a/b)^(c/d) = x # rotate 1 by 180°
|
|
717
|
-
// <=> (cos(c*pi/d) + i*sin(c*pi/d)) * (a/b)^(c/d) = x # DeMoivre's formula in Q ( https://proofwiki.org/wiki/De_Moivre%27s_Formula/Rational_Index )
|
|
718
|
-
// From which follows that only for c=0 the root is non-complex. c/d is a reduced fraction, so that sin(c/dpi)=0 occurs for d=1, which is handled by our trivial case.
|
|
719
|
-
if (this['s'] < 0) return null;
|
|
720
|
-
|
|
721
|
-
// Now prime factor n and d
|
|
722
|
-
var N = factorize(this['n']);
|
|
723
|
-
var D = factorize(this['d']);
|
|
724
|
-
|
|
725
|
-
// Exponentiate and take root for n and d individually
|
|
726
|
-
var n = 1;
|
|
727
|
-
var d = 1;
|
|
728
|
-
for (var k in N) {
|
|
729
|
-
if (k === '1') continue;
|
|
730
|
-
if (k === '0') {
|
|
731
|
-
n = 0;
|
|
732
|
-
break;
|
|
733
|
-
}
|
|
734
|
-
N[k]*= P['n'];
|
|
735
|
-
|
|
736
|
-
if (N[k] % P['d'] === 0) {
|
|
737
|
-
N[k]/= P['d'];
|
|
738
|
-
} else return null;
|
|
739
|
-
n*= Math.pow(k, N[k]);
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
for (var k in D) {
|
|
743
|
-
if (k === '1') continue;
|
|
744
|
-
D[k]*= P['n'];
|
|
745
|
-
|
|
746
|
-
if (D[k] % P['d'] === 0) {
|
|
747
|
-
D[k]/= P['d'];
|
|
748
|
-
} else return null;
|
|
749
|
-
d*= Math.pow(k, D[k]);
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
if (P['s'] < 0) {
|
|
753
|
-
return newFraction(d, n);
|
|
754
|
-
}
|
|
755
|
-
return newFraction(n, d);
|
|
756
|
-
},
|
|
757
|
-
|
|
758
|
-
/**
|
|
759
|
-
* Check if two rational numbers are the same
|
|
760
|
-
*
|
|
761
|
-
* Ex: new Fraction(19.6).equals([98, 5]);
|
|
762
|
-
**/
|
|
763
|
-
"equals": function(a, b) {
|
|
764
|
-
|
|
765
|
-
parse(a, b);
|
|
766
|
-
return this["s"] * this["n"] * P["d"] === P["s"] * P["n"] * this["d"]; // Same as compare() === 0
|
|
767
|
-
},
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
* Check if two rational numbers are the same
|
|
771
|
-
*
|
|
772
|
-
* Ex: new Fraction(19.6).equals([98, 5]);
|
|
773
|
-
**/
|
|
774
|
-
"compare": function(a, b) {
|
|
775
|
-
|
|
776
|
-
parse(a, b);
|
|
777
|
-
var t = (this["s"] * this["n"] * P["d"] - P["s"] * P["n"] * this["d"]);
|
|
778
|
-
return (0 < t) - (t < 0);
|
|
779
|
-
},
|
|
780
|
-
|
|
781
|
-
"simplify": function(eps) {
|
|
782
|
-
|
|
783
|
-
if (isNaN(this['n']) || isNaN(this['d'])) {
|
|
784
|
-
return this;
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
eps = eps || 0.001;
|
|
788
|
-
|
|
789
|
-
var thisABS = this['abs']();
|
|
790
|
-
var cont = thisABS['toContinued']();
|
|
791
|
-
|
|
792
|
-
for (var i = 1; i < cont.length; i++) {
|
|
793
|
-
|
|
794
|
-
var s = newFraction(cont[i - 1], 1);
|
|
795
|
-
for (var k = i - 2; k >= 0; k--) {
|
|
796
|
-
s = s['inverse']()['add'](cont[k]);
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
if (Math.abs(s['sub'](thisABS).valueOf()) < eps) {
|
|
800
|
-
return s['mul'](this['s']);
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
return this;
|
|
804
|
-
},
|
|
805
|
-
|
|
806
|
-
/**
|
|
807
|
-
* Check if two rational numbers are divisible
|
|
808
|
-
*
|
|
809
|
-
* Ex: new Fraction(19.6).divisible(1.5);
|
|
810
|
-
*/
|
|
811
|
-
"divisible": function(a, b) {
|
|
812
|
-
|
|
813
|
-
parse(a, b);
|
|
814
|
-
return !(!(P["n"] * this["d"]) || ((this["n"] * P["d"]) % (P["n"] * this["d"])));
|
|
815
|
-
},
|
|
816
|
-
|
|
817
|
-
/**
|
|
818
|
-
* Returns a decimal representation of the fraction
|
|
819
|
-
*
|
|
820
|
-
* Ex: new Fraction("100.'91823'").valueOf() => 100.91823918239183
|
|
821
|
-
**/
|
|
822
|
-
'valueOf': function() {
|
|
823
|
-
|
|
824
|
-
return this["s"] * this["n"] / this["d"];
|
|
825
|
-
},
|
|
826
|
-
|
|
827
|
-
/**
|
|
828
|
-
* Returns a string-fraction representation of a Fraction object
|
|
829
|
-
*
|
|
830
|
-
* Ex: new Fraction("1.'3'").toFraction(true) => "4 1/3"
|
|
831
|
-
**/
|
|
832
|
-
'toFraction': function(excludeWhole) {
|
|
833
|
-
|
|
834
|
-
var whole, str = "";
|
|
835
|
-
var n = this["n"];
|
|
836
|
-
var d = this["d"];
|
|
837
|
-
if (this["s"] < 0) {
|
|
838
|
-
str+= '-';
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
if (d === 1) {
|
|
842
|
-
str+= n;
|
|
843
|
-
} else {
|
|
844
|
-
|
|
845
|
-
if (excludeWhole && (whole = Math.floor(n / d)) > 0) {
|
|
846
|
-
str+= whole;
|
|
847
|
-
str+= " ";
|
|
848
|
-
n%= d;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
str+= n;
|
|
852
|
-
str+= '/';
|
|
853
|
-
str+= d;
|
|
854
|
-
}
|
|
855
|
-
return str;
|
|
856
|
-
},
|
|
857
|
-
|
|
858
|
-
/**
|
|
859
|
-
* Returns a latex representation of a Fraction object
|
|
860
|
-
*
|
|
861
|
-
* Ex: new Fraction("1.'3'").toLatex() => "\frac{4}{3}"
|
|
862
|
-
**/
|
|
863
|
-
'toLatex': function(excludeWhole) {
|
|
864
|
-
|
|
865
|
-
var whole, str = "";
|
|
866
|
-
var n = this["n"];
|
|
867
|
-
var d = this["d"];
|
|
868
|
-
if (this["s"] < 0) {
|
|
869
|
-
str+= '-';
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
if (d === 1) {
|
|
873
|
-
str+= n;
|
|
874
|
-
} else {
|
|
875
|
-
|
|
876
|
-
if (excludeWhole && (whole = Math.floor(n / d)) > 0) {
|
|
877
|
-
str+= whole;
|
|
878
|
-
n%= d;
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
str+= "\\frac{";
|
|
882
|
-
str+= n;
|
|
883
|
-
str+= '}{';
|
|
884
|
-
str+= d;
|
|
885
|
-
str+= '}';
|
|
886
|
-
}
|
|
887
|
-
return str;
|
|
888
|
-
},
|
|
889
|
-
|
|
890
|
-
/**
|
|
891
|
-
* Returns an array of continued fraction elements
|
|
892
|
-
*
|
|
893
|
-
* Ex: new Fraction("7/8").toContinued() => [0,1,7]
|
|
894
|
-
*/
|
|
895
|
-
'toContinued': function() {
|
|
896
|
-
|
|
897
|
-
var t;
|
|
898
|
-
var a = this['n'];
|
|
899
|
-
var b = this['d'];
|
|
900
|
-
var res = [];
|
|
901
|
-
|
|
902
|
-
if (isNaN(a) || isNaN(b)) {
|
|
903
|
-
return res;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
do {
|
|
907
|
-
res.push(Math.floor(a / b));
|
|
908
|
-
t = a % b;
|
|
909
|
-
a = b;
|
|
910
|
-
b = t;
|
|
911
|
-
} while (a !== 1);
|
|
912
|
-
|
|
913
|
-
return res;
|
|
914
|
-
},
|
|
915
|
-
|
|
916
|
-
/**
|
|
917
|
-
* Creates a string representation of a fraction with all digits
|
|
918
|
-
*
|
|
919
|
-
* Ex: new Fraction("100.'91823'").toString() => "100.(91823)"
|
|
920
|
-
**/
|
|
921
|
-
'toString': function(dec) {
|
|
922
|
-
|
|
923
|
-
var N = this["n"];
|
|
924
|
-
var D = this["d"];
|
|
925
|
-
|
|
926
|
-
if (isNaN(N) || isNaN(D)) {
|
|
927
|
-
return "NaN";
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
dec = dec || 15; // 15 = decimal places when no repetation
|
|
931
|
-
|
|
932
|
-
var cycLen = cycleLen(N, D); // Cycle length
|
|
933
|
-
var cycOff = cycleStart(N, D, cycLen); // Cycle start
|
|
934
|
-
|
|
935
|
-
var str = this['s'] < 0 ? "-" : "";
|
|
936
|
-
|
|
937
|
-
str+= N / D | 0;
|
|
938
|
-
|
|
939
|
-
N%= D;
|
|
940
|
-
N*= 10;
|
|
941
|
-
|
|
942
|
-
if (N)
|
|
943
|
-
str+= ".";
|
|
944
|
-
|
|
945
|
-
if (cycLen) {
|
|
946
|
-
|
|
947
|
-
for (var i = cycOff; i--;) {
|
|
948
|
-
str+= N / D | 0;
|
|
949
|
-
N%= D;
|
|
950
|
-
N*= 10;
|
|
951
|
-
}
|
|
952
|
-
str+= "(";
|
|
953
|
-
for (var i = cycLen; i--;) {
|
|
954
|
-
str+= N / D | 0;
|
|
955
|
-
N%= D;
|
|
956
|
-
N*= 10;
|
|
957
|
-
}
|
|
958
|
-
str+= ")";
|
|
959
|
-
} else {
|
|
960
|
-
for (var i = dec; N && i--;) {
|
|
961
|
-
str+= N / D | 0;
|
|
962
|
-
N%= D;
|
|
963
|
-
N*= 10;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
return str;
|
|
967
|
-
}
|
|
968
|
-
};
|
|
969
|
-
|
|
970
|
-
if (true) {
|
|
971
|
-
Object.defineProperty(Fraction, "__esModule", { 'value': true });
|
|
972
|
-
Fraction['default'] = Fraction;
|
|
973
|
-
Fraction['Fraction'] = Fraction;
|
|
974
|
-
module['exports'] = Fraction;
|
|
975
|
-
} else {}
|
|
976
|
-
|
|
977
|
-
})(this);
|
|
978
|
-
|
|
979
|
-
|
|
980
88
|
/***/ }),
|
|
981
89
|
|
|
982
90
|
/***/ 52794:
|
|
@@ -1105,7 +213,7 @@ module.exports.TinyEmitter = E;
|
|
|
1105
213
|
|
|
1106
214
|
/***/ }),
|
|
1107
215
|
|
|
1108
|
-
/***/
|
|
216
|
+
/***/ 43348:
|
|
1109
217
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
1110
218
|
|
|
1111
219
|
"use strict";
|
|
@@ -10367,17 +9475,17 @@ var createBigNumberClass = /* #__PURE__ */factory_factory(BigNumber_name, BigNum
|
|
|
10367
9475
|
*
|
|
10368
9476
|
* Example:
|
|
10369
9477
|
*
|
|
10370
|
-
*
|
|
9478
|
+
* const c = new Complex('99.3+8i');
|
|
10371
9479
|
* c.mul({r: 3, i: 9}).div(4.9).sub(3, 2);
|
|
10372
9480
|
*
|
|
10373
9481
|
*/
|
|
10374
9482
|
|
|
10375
9483
|
|
|
10376
|
-
|
|
9484
|
+
const complex_cosh = Math.cosh || function (x) {
|
|
10377
9485
|
return Math.abs(x) < 1e-9 ? 1 - x : (Math.exp(x) + Math.exp(-x)) * 0.5;
|
|
10378
9486
|
};
|
|
10379
9487
|
|
|
10380
|
-
|
|
9488
|
+
const complex_sinh = Math.sinh || function (x) {
|
|
10381
9489
|
return Math.abs(x) < 1e-9 ? x : (Math.exp(x) - Math.exp(-x)) * 0.5;
|
|
10382
9490
|
};
|
|
10383
9491
|
|
|
@@ -10387,16 +9495,16 @@ var complex_sinh = Math.sinh || function (x) {
|
|
|
10387
9495
|
* @param {number} x
|
|
10388
9496
|
* @returns {number} cos(x) - 1
|
|
10389
9497
|
*/
|
|
10390
|
-
|
|
9498
|
+
const cosm1 = function (x) {
|
|
10391
9499
|
|
|
10392
|
-
|
|
9500
|
+
const b = Math.PI / 4;
|
|
10393
9501
|
if (-b > x || x > b) {
|
|
10394
9502
|
return Math.cos(x) - 1.0;
|
|
10395
9503
|
}
|
|
10396
9504
|
|
|
10397
9505
|
/* Calculate horner form of polynomial of taylor series in Q
|
|
10398
|
-
|
|
10399
|
-
for (
|
|
9506
|
+
let fac = 1, alt = 1, pol = {};
|
|
9507
|
+
for (let i = 0; i <= 16; i++) {
|
|
10400
9508
|
fac*= i || 1;
|
|
10401
9509
|
if (i % 2 == 0) {
|
|
10402
9510
|
pol[i] = new Fraction(1, alt * fac);
|
|
@@ -10406,7 +9514,7 @@ var cosm1 = function (x) {
|
|
|
10406
9514
|
console.log(new Polynomial(pol).toHorner()); // (((((((1/20922789888000x^2-1/87178291200)x^2+1/479001600)x^2-1/3628800)x^2+1/40320)x^2-1/720)x^2+1/24)x^2-1/2)x^2+1
|
|
10407
9515
|
*/
|
|
10408
9516
|
|
|
10409
|
-
|
|
9517
|
+
const xx = x * x;
|
|
10410
9518
|
return xx * (
|
|
10411
9519
|
xx * (
|
|
10412
9520
|
xx * (
|
|
@@ -10424,25 +9532,23 @@ var cosm1 = function (x) {
|
|
|
10424
9532
|
- 1 / 2);
|
|
10425
9533
|
};
|
|
10426
9534
|
|
|
10427
|
-
|
|
9535
|
+
const complex_hypot = function (x, y) {
|
|
10428
9536
|
|
|
10429
|
-
|
|
10430
|
-
|
|
9537
|
+
x = Math.abs(x);
|
|
9538
|
+
y = Math.abs(y);
|
|
10431
9539
|
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
}
|
|
9540
|
+
// Ensure `x` is the larger value
|
|
9541
|
+
if (x < y) [x, y] = [y, x];
|
|
10435
9542
|
|
|
10436
|
-
|
|
10437
|
-
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
return a * Math.sqrt(1 + b * b);
|
|
9543
|
+
// If both are below the threshold, use straightforward Pythagoras
|
|
9544
|
+
if (x < 1e8) return Math.sqrt(x * x + y * y);
|
|
9545
|
+
|
|
9546
|
+
// For larger values, scale to avoid overflow
|
|
9547
|
+
y /= x;
|
|
9548
|
+
return x * Math.sqrt(1 + y * y);
|
|
10443
9549
|
};
|
|
10444
9550
|
|
|
10445
|
-
|
|
9551
|
+
const parser_exit = function () {
|
|
10446
9552
|
throw SyntaxError('Invalid Param');
|
|
10447
9553
|
};
|
|
10448
9554
|
|
|
@@ -10455,8 +9561,8 @@ var parser_exit = function () {
|
|
|
10455
9561
|
*/
|
|
10456
9562
|
function logHypot(a, b) {
|
|
10457
9563
|
|
|
10458
|
-
|
|
10459
|
-
|
|
9564
|
+
const _a = Math.abs(a);
|
|
9565
|
+
const _b = Math.abs(b);
|
|
10460
9566
|
|
|
10461
9567
|
if (a === 0) {
|
|
10462
9568
|
return Math.log(_b);
|
|
@@ -10482,10 +9588,10 @@ function logHypot(a, b) {
|
|
|
10482
9588
|
*
|
|
10483
9589
|
* 2. Try to use the non-overflowing pythagoras: (OVERALL ERROR: 8.889760039210159e-10)
|
|
10484
9590
|
|
|
10485
|
-
|
|
9591
|
+
const fn = function(a, b) {
|
|
10486
9592
|
a = Math.abs(a);
|
|
10487
9593
|
b = Math.abs(b);
|
|
10488
|
-
|
|
9594
|
+
let t = Math.min(a, b);
|
|
10489
9595
|
a = Math.max(a, b);
|
|
10490
9596
|
t = t / a;
|
|
10491
9597
|
|
|
@@ -10502,15 +9608,16 @@ function logHypot(a, b) {
|
|
|
10502
9608
|
|
|
10503
9609
|
*/
|
|
10504
9610
|
|
|
10505
|
-
a = a
|
|
10506
|
-
b = b
|
|
9611
|
+
a = a * 0.5;
|
|
9612
|
+
b = b * 0.5;
|
|
10507
9613
|
|
|
10508
9614
|
return 0.5 * Math.log(a * a + b * b) + Math.LN2;
|
|
10509
9615
|
}
|
|
10510
9616
|
|
|
10511
|
-
|
|
9617
|
+
const complex_P = { 're': 0, 'im': 0 };
|
|
9618
|
+
const parse = function (a, b) {
|
|
10512
9619
|
|
|
10513
|
-
|
|
9620
|
+
const z = complex_P;
|
|
10514
9621
|
|
|
10515
9622
|
if (a === undefined || a === null) {
|
|
10516
9623
|
z['re'] =
|
|
@@ -10527,13 +9634,13 @@ var parse = function (a, b) {
|
|
|
10527
9634
|
z['re'] = a['re'];
|
|
10528
9635
|
z['im'] = a['im'];
|
|
10529
9636
|
} else if ('abs' in a && 'arg' in a) {
|
|
10530
|
-
if (!
|
|
9637
|
+
if (!isFinite(a['abs']) && isFinite(a['arg'])) {
|
|
10531
9638
|
return Complex['INFINITY'];
|
|
10532
9639
|
}
|
|
10533
9640
|
z['re'] = a['abs'] * Math.cos(a['arg']);
|
|
10534
9641
|
z['im'] = a['abs'] * Math.sin(a['arg']);
|
|
10535
9642
|
} else if ('r' in a && 'phi' in a) {
|
|
10536
|
-
if (!
|
|
9643
|
+
if (!isFinite(a['r']) && isFinite(a['phi'])) {
|
|
10537
9644
|
return Complex['INFINITY'];
|
|
10538
9645
|
}
|
|
10539
9646
|
z['re'] = a['r'] * Math.cos(a['phi']);
|
|
@@ -10549,19 +9656,20 @@ var parse = function (a, b) {
|
|
|
10549
9656
|
case 'string':
|
|
10550
9657
|
|
|
10551
9658
|
z['im'] = /* void */
|
|
10552
|
-
|
|
9659
|
+
z['re'] = 0;
|
|
10553
9660
|
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
9661
|
+
const tokens = a.replace(/_/g, '')
|
|
9662
|
+
.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g);
|
|
9663
|
+
let plus = 1;
|
|
9664
|
+
let minus = 0;
|
|
10557
9665
|
|
|
10558
9666
|
if (tokens === null) {
|
|
10559
9667
|
parser_exit();
|
|
10560
9668
|
}
|
|
10561
9669
|
|
|
10562
|
-
for (
|
|
9670
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
10563
9671
|
|
|
10564
|
-
|
|
9672
|
+
const c = tokens[i];
|
|
10565
9673
|
|
|
10566
9674
|
if (c === ' ' || c === '\t' || c === '\n') {
|
|
10567
9675
|
/* void */
|
|
@@ -10632,7 +9740,7 @@ function Complex(a, b) {
|
|
|
10632
9740
|
return new Complex(a, b);
|
|
10633
9741
|
}
|
|
10634
9742
|
|
|
10635
|
-
|
|
9743
|
+
const z = parse(a, b);
|
|
10636
9744
|
|
|
10637
9745
|
this['re'] = z['re'];
|
|
10638
9746
|
this['im'] = z['im'];
|
|
@@ -10650,7 +9758,7 @@ Complex.prototype = {
|
|
|
10650
9758
|
*/
|
|
10651
9759
|
'sign': function () {
|
|
10652
9760
|
|
|
10653
|
-
|
|
9761
|
+
const abs = complex_hypot(this['re'], this['im']);
|
|
10654
9762
|
|
|
10655
9763
|
return new Complex(
|
|
10656
9764
|
this['re'] / abs,
|
|
@@ -10664,15 +9772,18 @@ Complex.prototype = {
|
|
|
10664
9772
|
*/
|
|
10665
9773
|
'add': function (a, b) {
|
|
10666
9774
|
|
|
10667
|
-
|
|
9775
|
+
const z = parse(a, b);
|
|
10668
9776
|
|
|
10669
|
-
|
|
10670
|
-
|
|
10671
|
-
|
|
10672
|
-
|
|
9777
|
+
const tInfin = this['isInfinite']();
|
|
9778
|
+
const zInfin = !(isFinite(z['re']) && isFinite(z['im']));
|
|
9779
|
+
|
|
9780
|
+
if (tInfin || zInfin) {
|
|
10673
9781
|
|
|
10674
|
-
|
|
10675
|
-
|
|
9782
|
+
if (tInfin && zInfin) {
|
|
9783
|
+
// Infinity + Infinity = NaN
|
|
9784
|
+
return Complex['NAN'];
|
|
9785
|
+
}
|
|
9786
|
+
// Infinity + z = Infinity { where z != Infinity }
|
|
10676
9787
|
return Complex['INFINITY'];
|
|
10677
9788
|
}
|
|
10678
9789
|
|
|
@@ -10688,15 +9799,18 @@ Complex.prototype = {
|
|
|
10688
9799
|
*/
|
|
10689
9800
|
'sub': function (a, b) {
|
|
10690
9801
|
|
|
10691
|
-
|
|
9802
|
+
const z = parse(a, b);
|
|
10692
9803
|
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
9804
|
+
const tInfin = this['isInfinite']();
|
|
9805
|
+
const zInfin = !(isFinite(z['re']) && isFinite(z['im']));
|
|
9806
|
+
|
|
9807
|
+
if (tInfin || zInfin) {
|
|
10697
9808
|
|
|
10698
|
-
|
|
10699
|
-
|
|
9809
|
+
if (tInfin && zInfin) {
|
|
9810
|
+
// Infinity - Infinity = NaN
|
|
9811
|
+
return Complex['NAN'];
|
|
9812
|
+
}
|
|
9813
|
+
// Infinity - z = Infinity { where z != Infinity }
|
|
10700
9814
|
return Complex['INFINITY'];
|
|
10701
9815
|
}
|
|
10702
9816
|
|
|
@@ -10712,19 +9826,24 @@ Complex.prototype = {
|
|
|
10712
9826
|
*/
|
|
10713
9827
|
'mul': function (a, b) {
|
|
10714
9828
|
|
|
10715
|
-
|
|
9829
|
+
const z = parse(a, b);
|
|
9830
|
+
|
|
9831
|
+
const tInfin = this['isInfinite']();
|
|
9832
|
+
const zInfin = !(isFinite(z['re']) && isFinite(z['im']));
|
|
9833
|
+
const tIsZero = this['re'] === 0 && this['im'] === 0;
|
|
9834
|
+
const zIsZero = z['re'] === 0 && z['im'] === 0;
|
|
10716
9835
|
|
|
10717
9836
|
// Infinity * 0 = NaN
|
|
10718
|
-
if (
|
|
9837
|
+
if (tInfin && zIsZero || zInfin && tIsZero) {
|
|
10719
9838
|
return Complex['NAN'];
|
|
10720
9839
|
}
|
|
10721
9840
|
|
|
10722
9841
|
// Infinity * z = Infinity { where z != 0 }
|
|
10723
|
-
if (
|
|
9842
|
+
if (tInfin || zInfin) {
|
|
10724
9843
|
return Complex['INFINITY'];
|
|
10725
9844
|
}
|
|
10726
9845
|
|
|
10727
|
-
//
|
|
9846
|
+
// Shortcut for real values
|
|
10728
9847
|
if (z['im'] === 0 && this['im'] === 0) {
|
|
10729
9848
|
return new Complex(this['re'] * z['re'], 0);
|
|
10730
9849
|
}
|
|
@@ -10741,52 +9860,50 @@ Complex.prototype = {
|
|
|
10741
9860
|
*/
|
|
10742
9861
|
'div': function (a, b) {
|
|
10743
9862
|
|
|
10744
|
-
|
|
9863
|
+
const z = parse(a, b);
|
|
9864
|
+
|
|
9865
|
+
const tInfin = this['isInfinite']();
|
|
9866
|
+
const zInfin = !(isFinite(z['re']) && isFinite(z['im']));
|
|
9867
|
+
const tIsZero = this['re'] === 0 && this['im'] === 0;
|
|
9868
|
+
const zIsZero = z['re'] === 0 && z['im'] === 0;
|
|
10745
9869
|
|
|
10746
9870
|
// 0 / 0 = NaN and Infinity / Infinity = NaN
|
|
10747
|
-
if (
|
|
9871
|
+
if (tIsZero && zIsZero || tInfin && zInfin) {
|
|
10748
9872
|
return Complex['NAN'];
|
|
10749
9873
|
}
|
|
10750
9874
|
|
|
10751
9875
|
// Infinity / 0 = Infinity
|
|
10752
|
-
if (
|
|
9876
|
+
if (zIsZero || tInfin) {
|
|
10753
9877
|
return Complex['INFINITY'];
|
|
10754
9878
|
}
|
|
10755
9879
|
|
|
10756
9880
|
// 0 / Infinity = 0
|
|
10757
|
-
if (
|
|
9881
|
+
if (tIsZero || zInfin) {
|
|
10758
9882
|
return Complex['ZERO'];
|
|
10759
9883
|
}
|
|
10760
9884
|
|
|
10761
|
-
|
|
10762
|
-
b = this['im'];
|
|
10763
|
-
|
|
10764
|
-
var c = z['re'];
|
|
10765
|
-
var d = z['im'];
|
|
10766
|
-
var t, x;
|
|
10767
|
-
|
|
10768
|
-
if (0 === d) {
|
|
9885
|
+
if (0 === z['im']) {
|
|
10769
9886
|
// Divisor is real
|
|
10770
|
-
return new Complex(
|
|
9887
|
+
return new Complex(this['re'] / z['re'], this['im'] / z['re']);
|
|
10771
9888
|
}
|
|
10772
9889
|
|
|
10773
|
-
if (Math.abs(
|
|
9890
|
+
if (Math.abs(z['re']) < Math.abs(z['im'])) {
|
|
10774
9891
|
|
|
10775
|
-
x =
|
|
10776
|
-
t =
|
|
9892
|
+
const x = z['re'] / z['im'];
|
|
9893
|
+
const t = z['re'] * x + z['im'];
|
|
10777
9894
|
|
|
10778
9895
|
return new Complex(
|
|
10779
|
-
(
|
|
10780
|
-
(
|
|
9896
|
+
(this['re'] * x + this['im']) / t,
|
|
9897
|
+
(this['im'] * x - this['re']) / t);
|
|
10781
9898
|
|
|
10782
9899
|
} else {
|
|
10783
9900
|
|
|
10784
|
-
x =
|
|
10785
|
-
t =
|
|
9901
|
+
const x = z['im'] / z['re'];
|
|
9902
|
+
const t = z['im'] * x + z['re'];
|
|
10786
9903
|
|
|
10787
9904
|
return new Complex(
|
|
10788
|
-
(
|
|
10789
|
-
(
|
|
9905
|
+
(this['re'] + this['im'] * x) / t,
|
|
9906
|
+
(this['im'] - this['re'] * x) / t);
|
|
10790
9907
|
}
|
|
10791
9908
|
},
|
|
10792
9909
|
|
|
@@ -10797,33 +9914,33 @@ Complex.prototype = {
|
|
|
10797
9914
|
*/
|
|
10798
9915
|
'pow': function (a, b) {
|
|
10799
9916
|
|
|
10800
|
-
|
|
9917
|
+
const z = parse(a, b);
|
|
10801
9918
|
|
|
10802
|
-
|
|
10803
|
-
|
|
9919
|
+
const tIsZero = this['re'] === 0 && this['im'] === 0;
|
|
9920
|
+
const zIsZero = z['re'] === 0 && z['im'] === 0;
|
|
10804
9921
|
|
|
10805
|
-
if (
|
|
9922
|
+
if (zIsZero) {
|
|
10806
9923
|
return Complex['ONE'];
|
|
10807
9924
|
}
|
|
10808
9925
|
|
|
10809
9926
|
// If the exponent is real
|
|
10810
9927
|
if (z['im'] === 0) {
|
|
10811
9928
|
|
|
10812
|
-
if (
|
|
9929
|
+
if (this['im'] === 0 && this['re'] > 0) {
|
|
10813
9930
|
|
|
10814
|
-
return new Complex(Math.pow(
|
|
9931
|
+
return new Complex(Math.pow(this['re'], z['re']), 0);
|
|
10815
9932
|
|
|
10816
|
-
} else if (
|
|
9933
|
+
} else if (this['re'] === 0) { // If base is fully imaginary
|
|
10817
9934
|
|
|
10818
9935
|
switch ((z['re'] % 4 + 4) % 4) {
|
|
10819
9936
|
case 0:
|
|
10820
|
-
return new Complex(Math.pow(
|
|
9937
|
+
return new Complex(Math.pow(this['im'], z['re']), 0);
|
|
10821
9938
|
case 1:
|
|
10822
|
-
return new Complex(0, Math.pow(
|
|
9939
|
+
return new Complex(0, Math.pow(this['im'], z['re']));
|
|
10823
9940
|
case 2:
|
|
10824
|
-
return new Complex(-Math.pow(
|
|
9941
|
+
return new Complex(-Math.pow(this['im'], z['re']), 0);
|
|
10825
9942
|
case 3:
|
|
10826
|
-
return new Complex(0, -Math.pow(
|
|
9943
|
+
return new Complex(0, -Math.pow(this['im'], z['re']));
|
|
10827
9944
|
}
|
|
10828
9945
|
}
|
|
10829
9946
|
}
|
|
@@ -10847,18 +9964,18 @@ Complex.prototype = {
|
|
|
10847
9964
|
*
|
|
10848
9965
|
*/
|
|
10849
9966
|
|
|
10850
|
-
if (
|
|
9967
|
+
if (tIsZero && z['re'] > 0) { // Same behavior as Wolframalpha, Zero if real part is zero
|
|
10851
9968
|
return Complex['ZERO'];
|
|
10852
9969
|
}
|
|
10853
9970
|
|
|
10854
|
-
|
|
10855
|
-
|
|
9971
|
+
const arg = Math.atan2(this['im'], this['re']);
|
|
9972
|
+
const loh = logHypot(this['re'], this['im']);
|
|
10856
9973
|
|
|
10857
|
-
|
|
10858
|
-
|
|
9974
|
+
let re = Math.exp(z['re'] * loh - z['im'] * arg);
|
|
9975
|
+
let im = z['im'] * loh + z['re'] * arg;
|
|
10859
9976
|
return new Complex(
|
|
10860
|
-
|
|
10861
|
-
|
|
9977
|
+
re * Math.cos(im),
|
|
9978
|
+
re * Math.sin(im));
|
|
10862
9979
|
},
|
|
10863
9980
|
|
|
10864
9981
|
/**
|
|
@@ -10868,30 +9985,28 @@ Complex.prototype = {
|
|
|
10868
9985
|
*/
|
|
10869
9986
|
'sqrt': function () {
|
|
10870
9987
|
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
var r = this['abs']();
|
|
9988
|
+
const a = this['re'];
|
|
9989
|
+
const b = this['im'];
|
|
10874
9990
|
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
if (b === 0) {
|
|
9991
|
+
if (b === 0) {
|
|
9992
|
+
// Real number case
|
|
9993
|
+
if (a >= 0) {
|
|
10880
9994
|
return new Complex(Math.sqrt(a), 0);
|
|
9995
|
+
} else {
|
|
9996
|
+
return new Complex(0, Math.sqrt(-a));
|
|
10881
9997
|
}
|
|
10882
|
-
|
|
10883
|
-
re = 0.5 * Math.sqrt(2.0 * (r + a));
|
|
10884
|
-
} else {
|
|
10885
|
-
re = Math.abs(b) / Math.sqrt(2 * (r - a));
|
|
10886
9998
|
}
|
|
10887
9999
|
|
|
10888
|
-
|
|
10889
|
-
|
|
10000
|
+
const r = complex_hypot(a, b);
|
|
10001
|
+
|
|
10002
|
+
let re = Math.sqrt(0.5 * (r + Math.abs(a))); // sqrt(2x) / 2 = sqrt(x / 2)
|
|
10003
|
+
let im = Math.abs(b) / (2 * re);
|
|
10004
|
+
|
|
10005
|
+
if (a >= 0) {
|
|
10006
|
+
return new Complex(re, b < 0 ? -im : im);
|
|
10890
10007
|
} else {
|
|
10891
|
-
|
|
10008
|
+
return new Complex(im, b < 0 ? -re : re);
|
|
10892
10009
|
}
|
|
10893
|
-
|
|
10894
|
-
return new Complex(re, b < 0 ? -im : im);
|
|
10895
10010
|
},
|
|
10896
10011
|
|
|
10897
10012
|
/**
|
|
@@ -10901,14 +10016,14 @@ Complex.prototype = {
|
|
|
10901
10016
|
*/
|
|
10902
10017
|
'exp': function () {
|
|
10903
10018
|
|
|
10904
|
-
|
|
10019
|
+
const er = Math.exp(this['re']);
|
|
10905
10020
|
|
|
10906
10021
|
if (this['im'] === 0) {
|
|
10907
|
-
|
|
10022
|
+
return new Complex(er, 0);
|
|
10908
10023
|
}
|
|
10909
10024
|
return new Complex(
|
|
10910
|
-
|
|
10911
|
-
|
|
10025
|
+
er * Math.cos(this['im']),
|
|
10026
|
+
er * Math.sin(this['im']));
|
|
10912
10027
|
},
|
|
10913
10028
|
|
|
10914
10029
|
/**
|
|
@@ -10927,8 +10042,8 @@ Complex.prototype = {
|
|
|
10927
10042
|
= expm1(a)*cos(b) + cosm1(b) + j*exp(a)*sin(b)
|
|
10928
10043
|
*/
|
|
10929
10044
|
|
|
10930
|
-
|
|
10931
|
-
|
|
10045
|
+
const a = this['re'];
|
|
10046
|
+
const b = this['im'];
|
|
10932
10047
|
|
|
10933
10048
|
return new Complex(
|
|
10934
10049
|
Math.expm1(a) * Math.cos(b) + cosm1(b),
|
|
@@ -10942,11 +10057,11 @@ Complex.prototype = {
|
|
|
10942
10057
|
*/
|
|
10943
10058
|
'log': function () {
|
|
10944
10059
|
|
|
10945
|
-
|
|
10946
|
-
|
|
10060
|
+
const a = this['re'];
|
|
10061
|
+
const b = this['im'];
|
|
10947
10062
|
|
|
10948
10063
|
if (b === 0 && a > 0) {
|
|
10949
|
-
|
|
10064
|
+
return new Complex(Math.log(a), 0);
|
|
10950
10065
|
}
|
|
10951
10066
|
|
|
10952
10067
|
return new Complex(
|
|
@@ -10984,8 +10099,8 @@ Complex.prototype = {
|
|
|
10984
10099
|
// sin(z) = ( e^iz - e^-iz ) / 2i
|
|
10985
10100
|
// = sin(a)cosh(b) + i cos(a)sinh(b)
|
|
10986
10101
|
|
|
10987
|
-
|
|
10988
|
-
|
|
10102
|
+
const a = this['re'];
|
|
10103
|
+
const b = this['im'];
|
|
10989
10104
|
|
|
10990
10105
|
return new Complex(
|
|
10991
10106
|
Math.sin(a) * complex_cosh(b),
|
|
@@ -11002,8 +10117,8 @@ Complex.prototype = {
|
|
|
11002
10117
|
// cos(z) = ( e^iz + e^-iz ) / 2
|
|
11003
10118
|
// = cos(a)cosh(b) - i sin(a)sinh(b)
|
|
11004
10119
|
|
|
11005
|
-
|
|
11006
|
-
|
|
10120
|
+
const a = this['re'];
|
|
10121
|
+
const b = this['im'];
|
|
11007
10122
|
|
|
11008
10123
|
return new Complex(
|
|
11009
10124
|
Math.cos(a) * complex_cosh(b),
|
|
@@ -11022,9 +10137,9 @@ Complex.prototype = {
|
|
|
11022
10137
|
// = ( e^2iz - 1 ) / i( e^2iz + 1 )
|
|
11023
10138
|
// = ( sin(2a) + i sinh(2b) ) / ( cos(2a) + cosh(2b) )
|
|
11024
10139
|
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
10140
|
+
const a = 2 * this['re'];
|
|
10141
|
+
const b = 2 * this['im'];
|
|
10142
|
+
const d = Math.cos(a) + complex_cosh(b);
|
|
11028
10143
|
|
|
11029
10144
|
return new Complex(
|
|
11030
10145
|
Math.sin(a) / d,
|
|
@@ -11040,9 +10155,9 @@ Complex.prototype = {
|
|
|
11040
10155
|
|
|
11041
10156
|
// cot(c) = i(e^(ci) + e^(-ci)) / (e^(ci) - e^(-ci))
|
|
11042
10157
|
|
|
11043
|
-
|
|
11044
|
-
|
|
11045
|
-
|
|
10158
|
+
const a = 2 * this['re'];
|
|
10159
|
+
const b = 2 * this['im'];
|
|
10160
|
+
const d = Math.cos(a) - complex_cosh(b);
|
|
11046
10161
|
|
|
11047
10162
|
return new Complex(
|
|
11048
10163
|
-Math.sin(a) / d,
|
|
@@ -11058,9 +10173,9 @@ Complex.prototype = {
|
|
|
11058
10173
|
|
|
11059
10174
|
// sec(c) = 2 / (e^(ci) + e^(-ci))
|
|
11060
10175
|
|
|
11061
|
-
|
|
11062
|
-
|
|
11063
|
-
|
|
10176
|
+
const a = this['re'];
|
|
10177
|
+
const b = this['im'];
|
|
10178
|
+
const d = 0.5 * complex_cosh(2 * b) + 0.5 * Math.cos(2 * a);
|
|
11064
10179
|
|
|
11065
10180
|
return new Complex(
|
|
11066
10181
|
Math.cos(a) * complex_cosh(b) / d,
|
|
@@ -11076,9 +10191,9 @@ Complex.prototype = {
|
|
|
11076
10191
|
|
|
11077
10192
|
// csc(c) = 2i / (e^(ci) - e^(-ci))
|
|
11078
10193
|
|
|
11079
|
-
|
|
11080
|
-
|
|
11081
|
-
|
|
10194
|
+
const a = this['re'];
|
|
10195
|
+
const b = this['im'];
|
|
10196
|
+
const d = 0.5 * complex_cosh(2 * b) - 0.5 * Math.cos(2 * a);
|
|
11082
10197
|
|
|
11083
10198
|
return new Complex(
|
|
11084
10199
|
Math.sin(a) * complex_cosh(b) / d,
|
|
@@ -11094,14 +10209,14 @@ Complex.prototype = {
|
|
|
11094
10209
|
|
|
11095
10210
|
// asin(c) = -i * log(ci + sqrt(1 - c^2))
|
|
11096
10211
|
|
|
11097
|
-
|
|
11098
|
-
|
|
10212
|
+
const a = this['re'];
|
|
10213
|
+
const b = this['im'];
|
|
11099
10214
|
|
|
11100
|
-
|
|
10215
|
+
const t1 = new Complex(
|
|
11101
10216
|
b * b - a * a + 1,
|
|
11102
10217
|
-2 * a * b)['sqrt']();
|
|
11103
10218
|
|
|
11104
|
-
|
|
10219
|
+
const t2 = new Complex(
|
|
11105
10220
|
t1['re'] - b,
|
|
11106
10221
|
t1['im'] + a)['log']();
|
|
11107
10222
|
|
|
@@ -11117,14 +10232,14 @@ Complex.prototype = {
|
|
|
11117
10232
|
|
|
11118
10233
|
// acos(c) = i * log(c - i * sqrt(1 - c^2))
|
|
11119
10234
|
|
|
11120
|
-
|
|
11121
|
-
|
|
10235
|
+
const a = this['re'];
|
|
10236
|
+
const b = this['im'];
|
|
11122
10237
|
|
|
11123
|
-
|
|
10238
|
+
const t1 = new Complex(
|
|
11124
10239
|
b * b - a * a + 1,
|
|
11125
10240
|
-2 * a * b)['sqrt']();
|
|
11126
10241
|
|
|
11127
|
-
|
|
10242
|
+
const t2 = new Complex(
|
|
11128
10243
|
t1['re'] - b,
|
|
11129
10244
|
t1['im'] + a)['log']();
|
|
11130
10245
|
|
|
@@ -11140,8 +10255,8 @@ Complex.prototype = {
|
|
|
11140
10255
|
|
|
11141
10256
|
// atan(c) = i / 2 log((i + x) / (i - x))
|
|
11142
10257
|
|
|
11143
|
-
|
|
11144
|
-
|
|
10258
|
+
const a = this['re'];
|
|
10259
|
+
const b = this['im'];
|
|
11145
10260
|
|
|
11146
10261
|
if (a === 0) {
|
|
11147
10262
|
|
|
@@ -11154,9 +10269,9 @@ Complex.prototype = {
|
|
|
11154
10269
|
}
|
|
11155
10270
|
}
|
|
11156
10271
|
|
|
11157
|
-
|
|
10272
|
+
const d = a * a + (1.0 - b) * (1.0 - b);
|
|
11158
10273
|
|
|
11159
|
-
|
|
10274
|
+
const t1 = new Complex(
|
|
11160
10275
|
(1 - b * b - a * a) / d,
|
|
11161
10276
|
-2 * a / d).log();
|
|
11162
10277
|
|
|
@@ -11172,14 +10287,14 @@ Complex.prototype = {
|
|
|
11172
10287
|
|
|
11173
10288
|
// acot(c) = i / 2 log((c - i) / (c + i))
|
|
11174
10289
|
|
|
11175
|
-
|
|
11176
|
-
|
|
10290
|
+
const a = this['re'];
|
|
10291
|
+
const b = this['im'];
|
|
11177
10292
|
|
|
11178
10293
|
if (b === 0) {
|
|
11179
10294
|
return new Complex(Math.atan2(1, a), 0);
|
|
11180
10295
|
}
|
|
11181
10296
|
|
|
11182
|
-
|
|
10297
|
+
const d = a * a + b * b;
|
|
11183
10298
|
return (d !== 0)
|
|
11184
10299
|
? new Complex(
|
|
11185
10300
|
a / d,
|
|
@@ -11198,14 +10313,14 @@ Complex.prototype = {
|
|
|
11198
10313
|
|
|
11199
10314
|
// asec(c) = -i * log(1 / c + sqrt(1 - i / c^2))
|
|
11200
10315
|
|
|
11201
|
-
|
|
11202
|
-
|
|
10316
|
+
const a = this['re'];
|
|
10317
|
+
const b = this['im'];
|
|
11203
10318
|
|
|
11204
10319
|
if (a === 0 && b === 0) {
|
|
11205
10320
|
return new Complex(0, Infinity);
|
|
11206
10321
|
}
|
|
11207
10322
|
|
|
11208
|
-
|
|
10323
|
+
const d = a * a + b * b;
|
|
11209
10324
|
return (d !== 0)
|
|
11210
10325
|
? new Complex(
|
|
11211
10326
|
a / d,
|
|
@@ -11224,14 +10339,14 @@ Complex.prototype = {
|
|
|
11224
10339
|
|
|
11225
10340
|
// acsc(c) = -i * log(i / c + sqrt(1 - 1 / c^2))
|
|
11226
10341
|
|
|
11227
|
-
|
|
11228
|
-
|
|
10342
|
+
const a = this['re'];
|
|
10343
|
+
const b = this['im'];
|
|
11229
10344
|
|
|
11230
10345
|
if (a === 0 && b === 0) {
|
|
11231
10346
|
return new Complex(Math.PI / 2, Infinity);
|
|
11232
10347
|
}
|
|
11233
10348
|
|
|
11234
|
-
|
|
10349
|
+
const d = a * a + b * b;
|
|
11235
10350
|
return (d !== 0)
|
|
11236
10351
|
? new Complex(
|
|
11237
10352
|
a / d,
|
|
@@ -11250,8 +10365,8 @@ Complex.prototype = {
|
|
|
11250
10365
|
|
|
11251
10366
|
// sinh(c) = (e^c - e^-c) / 2
|
|
11252
10367
|
|
|
11253
|
-
|
|
11254
|
-
|
|
10368
|
+
const a = this['re'];
|
|
10369
|
+
const b = this['im'];
|
|
11255
10370
|
|
|
11256
10371
|
return new Complex(
|
|
11257
10372
|
complex_sinh(a) * Math.cos(b),
|
|
@@ -11267,8 +10382,8 @@ Complex.prototype = {
|
|
|
11267
10382
|
|
|
11268
10383
|
// cosh(c) = (e^c + e^-c) / 2
|
|
11269
10384
|
|
|
11270
|
-
|
|
11271
|
-
|
|
10385
|
+
const a = this['re'];
|
|
10386
|
+
const b = this['im'];
|
|
11272
10387
|
|
|
11273
10388
|
return new Complex(
|
|
11274
10389
|
complex_cosh(a) * Math.cos(b),
|
|
@@ -11284,9 +10399,9 @@ Complex.prototype = {
|
|
|
11284
10399
|
|
|
11285
10400
|
// tanh(c) = (e^c - e^-c) / (e^c + e^-c)
|
|
11286
10401
|
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
10402
|
+
const a = 2 * this['re'];
|
|
10403
|
+
const b = 2 * this['im'];
|
|
10404
|
+
const d = complex_cosh(a) + Math.cos(b);
|
|
11290
10405
|
|
|
11291
10406
|
return new Complex(
|
|
11292
10407
|
complex_sinh(a) / d,
|
|
@@ -11302,9 +10417,9 @@ Complex.prototype = {
|
|
|
11302
10417
|
|
|
11303
10418
|
// coth(c) = (e^c + e^-c) / (e^c - e^-c)
|
|
11304
10419
|
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
10420
|
+
const a = 2 * this['re'];
|
|
10421
|
+
const b = 2 * this['im'];
|
|
10422
|
+
const d = complex_cosh(a) - Math.cos(b);
|
|
11308
10423
|
|
|
11309
10424
|
return new Complex(
|
|
11310
10425
|
complex_sinh(a) / d,
|
|
@@ -11320,9 +10435,9 @@ Complex.prototype = {
|
|
|
11320
10435
|
|
|
11321
10436
|
// csch(c) = 2 / (e^c - e^-c)
|
|
11322
10437
|
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
|
|
10438
|
+
const a = this['re'];
|
|
10439
|
+
const b = this['im'];
|
|
10440
|
+
const d = Math.cos(2 * b) - complex_cosh(2 * a);
|
|
11326
10441
|
|
|
11327
10442
|
return new Complex(
|
|
11328
10443
|
-2 * complex_sinh(a) * Math.cos(b) / d,
|
|
@@ -11338,9 +10453,9 @@ Complex.prototype = {
|
|
|
11338
10453
|
|
|
11339
10454
|
// sech(c) = 2 / (e^c + e^-c)
|
|
11340
10455
|
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
10456
|
+
const a = this['re'];
|
|
10457
|
+
const b = this['im'];
|
|
10458
|
+
const d = Math.cos(2 * b) + complex_cosh(2 * a);
|
|
11344
10459
|
|
|
11345
10460
|
return new Complex(
|
|
11346
10461
|
2 * complex_cosh(a) * Math.cos(b) / d,
|
|
@@ -11356,10 +10471,10 @@ Complex.prototype = {
|
|
|
11356
10471
|
|
|
11357
10472
|
// asinh(c) = log(c + sqrt(c^2 + 1))
|
|
11358
10473
|
|
|
11359
|
-
|
|
10474
|
+
let tmp = this['im'];
|
|
11360
10475
|
this['im'] = -this['re'];
|
|
11361
10476
|
this['re'] = tmp;
|
|
11362
|
-
|
|
10477
|
+
const res = this['asin']();
|
|
11363
10478
|
|
|
11364
10479
|
this['re'] = -this['im'];
|
|
11365
10480
|
this['im'] = tmp;
|
|
@@ -11379,13 +10494,13 @@ Complex.prototype = {
|
|
|
11379
10494
|
|
|
11380
10495
|
// acosh(c) = log(c + sqrt(c^2 - 1))
|
|
11381
10496
|
|
|
11382
|
-
|
|
10497
|
+
const res = this['acos']();
|
|
11383
10498
|
if (res['im'] <= 0) {
|
|
11384
|
-
|
|
10499
|
+
const tmp = res['re'];
|
|
11385
10500
|
res['re'] = -res['im'];
|
|
11386
10501
|
res['im'] = tmp;
|
|
11387
10502
|
} else {
|
|
11388
|
-
|
|
10503
|
+
const tmp = res['im'];
|
|
11389
10504
|
res['im'] = -res['re'];
|
|
11390
10505
|
res['re'] = tmp;
|
|
11391
10506
|
}
|
|
@@ -11401,15 +10516,15 @@ Complex.prototype = {
|
|
|
11401
10516
|
|
|
11402
10517
|
// atanh(c) = log((1+c) / (1-c)) / 2
|
|
11403
10518
|
|
|
11404
|
-
|
|
11405
|
-
|
|
10519
|
+
const a = this['re'];
|
|
10520
|
+
const b = this['im'];
|
|
11406
10521
|
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
|
|
10522
|
+
const noIM = a > 1 && b === 0;
|
|
10523
|
+
const oneMinus = 1 - a;
|
|
10524
|
+
const onePlus = 1 + a;
|
|
10525
|
+
const d = oneMinus * oneMinus + b * b;
|
|
11411
10526
|
|
|
11412
|
-
|
|
10527
|
+
const x = (d !== 0)
|
|
11413
10528
|
? new Complex(
|
|
11414
10529
|
(onePlus * oneMinus - b * b) / d,
|
|
11415
10530
|
(b * oneMinus + onePlus * b) / d)
|
|
@@ -11417,7 +10532,7 @@ Complex.prototype = {
|
|
|
11417
10532
|
(a !== -1) ? (a / 0) : 0,
|
|
11418
10533
|
(b !== 0) ? (b / 0) : 0);
|
|
11419
10534
|
|
|
11420
|
-
|
|
10535
|
+
const temp = x['re'];
|
|
11421
10536
|
x['re'] = logHypot(x['re'], x['im']) / 2;
|
|
11422
10537
|
x['im'] = Math.atan2(x['im'], temp) / 2;
|
|
11423
10538
|
if (noIM) {
|
|
@@ -11435,14 +10550,14 @@ Complex.prototype = {
|
|
|
11435
10550
|
|
|
11436
10551
|
// acoth(c) = log((c+1) / (c-1)) / 2
|
|
11437
10552
|
|
|
11438
|
-
|
|
11439
|
-
|
|
10553
|
+
const a = this['re'];
|
|
10554
|
+
const b = this['im'];
|
|
11440
10555
|
|
|
11441
10556
|
if (a === 0 && b === 0) {
|
|
11442
10557
|
return new Complex(0, Math.PI / 2);
|
|
11443
10558
|
}
|
|
11444
10559
|
|
|
11445
|
-
|
|
10560
|
+
const d = a * a + b * b;
|
|
11446
10561
|
return (d !== 0)
|
|
11447
10562
|
? new Complex(
|
|
11448
10563
|
a / d,
|
|
@@ -11461,8 +10576,8 @@ Complex.prototype = {
|
|
|
11461
10576
|
|
|
11462
10577
|
// acsch(c) = log((1+sqrt(1+c^2))/c)
|
|
11463
10578
|
|
|
11464
|
-
|
|
11465
|
-
|
|
10579
|
+
const a = this['re'];
|
|
10580
|
+
const b = this['im'];
|
|
11466
10581
|
|
|
11467
10582
|
if (b === 0) {
|
|
11468
10583
|
|
|
@@ -11472,7 +10587,7 @@ Complex.prototype = {
|
|
|
11472
10587
|
: Infinity, 0);
|
|
11473
10588
|
}
|
|
11474
10589
|
|
|
11475
|
-
|
|
10590
|
+
const d = a * a + b * b;
|
|
11476
10591
|
return (d !== 0)
|
|
11477
10592
|
? new Complex(
|
|
11478
10593
|
a / d,
|
|
@@ -11491,14 +10606,14 @@ Complex.prototype = {
|
|
|
11491
10606
|
|
|
11492
10607
|
// asech(c) = log((1+sqrt(1-c^2))/c)
|
|
11493
10608
|
|
|
11494
|
-
|
|
11495
|
-
|
|
10609
|
+
const a = this['re'];
|
|
10610
|
+
const b = this['im'];
|
|
11496
10611
|
|
|
11497
10612
|
if (this['isZero']()) {
|
|
11498
10613
|
return Complex['INFINITY'];
|
|
11499
10614
|
}
|
|
11500
10615
|
|
|
11501
|
-
|
|
10616
|
+
const d = a * a + b * b;
|
|
11502
10617
|
return (d !== 0)
|
|
11503
10618
|
? new Complex(
|
|
11504
10619
|
a / d,
|
|
@@ -11524,10 +10639,10 @@ Complex.prototype = {
|
|
|
11524
10639
|
return Complex['ZERO'];
|
|
11525
10640
|
}
|
|
11526
10641
|
|
|
11527
|
-
|
|
11528
|
-
|
|
10642
|
+
const a = this['re'];
|
|
10643
|
+
const b = this['im'];
|
|
11529
10644
|
|
|
11530
|
-
|
|
10645
|
+
const d = a * a + b * b;
|
|
11531
10646
|
|
|
11532
10647
|
return new Complex(a / d, -b / d);
|
|
11533
10648
|
},
|
|
@@ -11603,7 +10718,7 @@ Complex.prototype = {
|
|
|
11603
10718
|
*/
|
|
11604
10719
|
'equals': function (a, b) {
|
|
11605
10720
|
|
|
11606
|
-
|
|
10721
|
+
const z = parse(a, b);
|
|
11607
10722
|
|
|
11608
10723
|
return Math.abs(z['re'] - this['re']) <= Complex['EPSILON'] &&
|
|
11609
10724
|
Math.abs(z['im'] - this['im']) <= Complex['EPSILON'];
|
|
@@ -11626,9 +10741,9 @@ Complex.prototype = {
|
|
|
11626
10741
|
*/
|
|
11627
10742
|
'toString': function () {
|
|
11628
10743
|
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
10744
|
+
let a = this['re'];
|
|
10745
|
+
let b = this['im'];
|
|
10746
|
+
let ret = "";
|
|
11632
10747
|
|
|
11633
10748
|
if (this['isNaN']()) {
|
|
11634
10749
|
return 'NaN';
|
|
@@ -11731,7 +10846,7 @@ Complex.prototype = {
|
|
|
11731
10846
|
* @returns {boolean}
|
|
11732
10847
|
*/
|
|
11733
10848
|
'isInfinite': function () {
|
|
11734
|
-
return !
|
|
10849
|
+
return !this['isFinite']();
|
|
11735
10850
|
}
|
|
11736
10851
|
};
|
|
11737
10852
|
|
|
@@ -11940,8 +11055,899 @@ var createComplexClass = /* #__PURE__ */factory_factory(Complex_name, Complex_de
|
|
|
11940
11055
|
}, {
|
|
11941
11056
|
isClass: true
|
|
11942
11057
|
});
|
|
11943
|
-
|
|
11944
|
-
|
|
11058
|
+
;// CONCATENATED MODULE: ../../../node_modules/fraction.js/fraction.js
|
|
11059
|
+
/**
|
|
11060
|
+
* @license Fraction.js v4.3.7 31/08/2023
|
|
11061
|
+
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
|
|
11062
|
+
*
|
|
11063
|
+
* Copyright (c) 2023, Robert Eisele (robert@raw.org)
|
|
11064
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
11065
|
+
**/
|
|
11066
|
+
|
|
11067
|
+
|
|
11068
|
+
/**
|
|
11069
|
+
*
|
|
11070
|
+
* This class offers the possibility to calculate fractions.
|
|
11071
|
+
* You can pass a fraction in different formats. Either as array, as double, as string or as an integer.
|
|
11072
|
+
*
|
|
11073
|
+
* Array/Object form
|
|
11074
|
+
* [ 0 => <numerator>, 1 => <denominator> ]
|
|
11075
|
+
* [ n => <numerator>, d => <denominator> ]
|
|
11076
|
+
*
|
|
11077
|
+
* Integer form
|
|
11078
|
+
* - Single integer value
|
|
11079
|
+
*
|
|
11080
|
+
* Double form
|
|
11081
|
+
* - Single double value
|
|
11082
|
+
*
|
|
11083
|
+
* String form
|
|
11084
|
+
* 123.456 - a simple double
|
|
11085
|
+
* 123/456 - a string fraction
|
|
11086
|
+
* 123.'456' - a double with repeating decimal places
|
|
11087
|
+
* 123.(456) - synonym
|
|
11088
|
+
* 123.45'6' - a double with repeating last place
|
|
11089
|
+
* 123.45(6) - synonym
|
|
11090
|
+
*
|
|
11091
|
+
* Example:
|
|
11092
|
+
*
|
|
11093
|
+
* var f = new Fraction("9.4'31'");
|
|
11094
|
+
* f.mul([-4, 3]).div(4.9);
|
|
11095
|
+
*
|
|
11096
|
+
*/
|
|
11097
|
+
|
|
11098
|
+
|
|
11099
|
+
// Maximum search depth for cyclic rational numbers. 2000 should be more than enough.
|
|
11100
|
+
// Example: 1/7 = 0.(142857) has 6 repeating decimal places.
|
|
11101
|
+
// If MAX_CYCLE_LEN gets reduced, long cycles will not be detected and toString() only gets the first 10 digits
|
|
11102
|
+
var MAX_CYCLE_LEN = 2000;
|
|
11103
|
+
|
|
11104
|
+
// Parsed data to avoid calling "new" all the time
|
|
11105
|
+
var fraction_P = {
|
|
11106
|
+
"s": 1,
|
|
11107
|
+
"n": 0,
|
|
11108
|
+
"d": 1
|
|
11109
|
+
};
|
|
11110
|
+
|
|
11111
|
+
function fraction_assign(n, s) {
|
|
11112
|
+
|
|
11113
|
+
if (isNaN(n = parseInt(n, 10))) {
|
|
11114
|
+
throw InvalidParameter();
|
|
11115
|
+
}
|
|
11116
|
+
return n * s;
|
|
11117
|
+
}
|
|
11118
|
+
|
|
11119
|
+
// Creates a new Fraction internally without the need of the bulky constructor
|
|
11120
|
+
function newFraction(n, d) {
|
|
11121
|
+
|
|
11122
|
+
if (d === 0) {
|
|
11123
|
+
throw DivisionByZero();
|
|
11124
|
+
}
|
|
11125
|
+
|
|
11126
|
+
var f = Object.create(Fraction.prototype);
|
|
11127
|
+
f["s"] = n < 0 ? -1 : 1;
|
|
11128
|
+
|
|
11129
|
+
n = n < 0 ? -n : n;
|
|
11130
|
+
|
|
11131
|
+
var a = gcd(n, d);
|
|
11132
|
+
|
|
11133
|
+
f["n"] = n / a;
|
|
11134
|
+
f["d"] = d / a;
|
|
11135
|
+
return f;
|
|
11136
|
+
}
|
|
11137
|
+
|
|
11138
|
+
function factorize(num) {
|
|
11139
|
+
|
|
11140
|
+
var factors = {};
|
|
11141
|
+
|
|
11142
|
+
var n = num;
|
|
11143
|
+
var i = 2;
|
|
11144
|
+
var s = 4;
|
|
11145
|
+
|
|
11146
|
+
while (s <= n) {
|
|
11147
|
+
|
|
11148
|
+
while (n % i === 0) {
|
|
11149
|
+
n/= i;
|
|
11150
|
+
factors[i] = (factors[i] || 0) + 1;
|
|
11151
|
+
}
|
|
11152
|
+
s+= 1 + 2 * i++;
|
|
11153
|
+
}
|
|
11154
|
+
|
|
11155
|
+
if (n !== num) {
|
|
11156
|
+
if (n > 1)
|
|
11157
|
+
factors[n] = (factors[n] || 0) + 1;
|
|
11158
|
+
} else {
|
|
11159
|
+
factors[num] = (factors[num] || 0) + 1;
|
|
11160
|
+
}
|
|
11161
|
+
return factors;
|
|
11162
|
+
}
|
|
11163
|
+
|
|
11164
|
+
var fraction_parse = function(p1, p2) {
|
|
11165
|
+
|
|
11166
|
+
var n = 0, d = 1, s = 1;
|
|
11167
|
+
var v = 0, w = 0, x = 0, y = 1, z = 1;
|
|
11168
|
+
|
|
11169
|
+
var A = 0, B = 1;
|
|
11170
|
+
var C = 1, D = 1;
|
|
11171
|
+
|
|
11172
|
+
var N = 10000000;
|
|
11173
|
+
var M;
|
|
11174
|
+
|
|
11175
|
+
if (p1 === undefined || p1 === null) {
|
|
11176
|
+
/* void */
|
|
11177
|
+
} else if (p2 !== undefined) {
|
|
11178
|
+
n = p1;
|
|
11179
|
+
d = p2;
|
|
11180
|
+
s = n * d;
|
|
11181
|
+
|
|
11182
|
+
if (n % 1 !== 0 || d % 1 !== 0) {
|
|
11183
|
+
throw NonIntegerParameter();
|
|
11184
|
+
}
|
|
11185
|
+
|
|
11186
|
+
} else
|
|
11187
|
+
switch (typeof p1) {
|
|
11188
|
+
|
|
11189
|
+
case "object":
|
|
11190
|
+
{
|
|
11191
|
+
if ("d" in p1 && "n" in p1) {
|
|
11192
|
+
n = p1["n"];
|
|
11193
|
+
d = p1["d"];
|
|
11194
|
+
if ("s" in p1)
|
|
11195
|
+
n*= p1["s"];
|
|
11196
|
+
} else if (0 in p1) {
|
|
11197
|
+
n = p1[0];
|
|
11198
|
+
if (1 in p1)
|
|
11199
|
+
d = p1[1];
|
|
11200
|
+
} else {
|
|
11201
|
+
throw InvalidParameter();
|
|
11202
|
+
}
|
|
11203
|
+
s = n * d;
|
|
11204
|
+
break;
|
|
11205
|
+
}
|
|
11206
|
+
case "number":
|
|
11207
|
+
{
|
|
11208
|
+
if (p1 < 0) {
|
|
11209
|
+
s = p1;
|
|
11210
|
+
p1 = -p1;
|
|
11211
|
+
}
|
|
11212
|
+
|
|
11213
|
+
if (p1 % 1 === 0) {
|
|
11214
|
+
n = p1;
|
|
11215
|
+
} else if (p1 > 0) { // check for != 0, scale would become NaN (log(0)), which converges really slow
|
|
11216
|
+
|
|
11217
|
+
if (p1 >= 1) {
|
|
11218
|
+
z = Math.pow(10, Math.floor(1 + Math.log(p1) / Math.LN10));
|
|
11219
|
+
p1/= z;
|
|
11220
|
+
}
|
|
11221
|
+
|
|
11222
|
+
// Using Farey Sequences
|
|
11223
|
+
// http://www.johndcook.com/blog/2010/10/20/best-rational-approximation/
|
|
11224
|
+
|
|
11225
|
+
while (B <= N && D <= N) {
|
|
11226
|
+
M = (A + C) / (B + D);
|
|
11227
|
+
|
|
11228
|
+
if (p1 === M) {
|
|
11229
|
+
if (B + D <= N) {
|
|
11230
|
+
n = A + C;
|
|
11231
|
+
d = B + D;
|
|
11232
|
+
} else if (D > B) {
|
|
11233
|
+
n = C;
|
|
11234
|
+
d = D;
|
|
11235
|
+
} else {
|
|
11236
|
+
n = A;
|
|
11237
|
+
d = B;
|
|
11238
|
+
}
|
|
11239
|
+
break;
|
|
11240
|
+
|
|
11241
|
+
} else {
|
|
11242
|
+
|
|
11243
|
+
if (p1 > M) {
|
|
11244
|
+
A+= C;
|
|
11245
|
+
B+= D;
|
|
11246
|
+
} else {
|
|
11247
|
+
C+= A;
|
|
11248
|
+
D+= B;
|
|
11249
|
+
}
|
|
11250
|
+
|
|
11251
|
+
if (B > N) {
|
|
11252
|
+
n = C;
|
|
11253
|
+
d = D;
|
|
11254
|
+
} else {
|
|
11255
|
+
n = A;
|
|
11256
|
+
d = B;
|
|
11257
|
+
}
|
|
11258
|
+
}
|
|
11259
|
+
}
|
|
11260
|
+
n*= z;
|
|
11261
|
+
} else if (isNaN(p1) || isNaN(p2)) {
|
|
11262
|
+
d = n = NaN;
|
|
11263
|
+
}
|
|
11264
|
+
break;
|
|
11265
|
+
}
|
|
11266
|
+
case "string":
|
|
11267
|
+
{
|
|
11268
|
+
B = p1.match(/\d+|./g);
|
|
11269
|
+
|
|
11270
|
+
if (B === null)
|
|
11271
|
+
throw InvalidParameter();
|
|
11272
|
+
|
|
11273
|
+
if (B[A] === '-') {// Check for minus sign at the beginning
|
|
11274
|
+
s = -1;
|
|
11275
|
+
A++;
|
|
11276
|
+
} else if (B[A] === '+') {// Check for plus sign at the beginning
|
|
11277
|
+
A++;
|
|
11278
|
+
}
|
|
11279
|
+
|
|
11280
|
+
if (B.length === A + 1) { // Check if it's just a simple number "1234"
|
|
11281
|
+
w = fraction_assign(B[A++], s);
|
|
11282
|
+
} else if (B[A + 1] === '.' || B[A] === '.') { // Check if it's a decimal number
|
|
11283
|
+
|
|
11284
|
+
if (B[A] !== '.') { // Handle 0.5 and .5
|
|
11285
|
+
v = fraction_assign(B[A++], s);
|
|
11286
|
+
}
|
|
11287
|
+
A++;
|
|
11288
|
+
|
|
11289
|
+
// Check for decimal places
|
|
11290
|
+
if (A + 1 === B.length || B[A + 1] === '(' && B[A + 3] === ')' || B[A + 1] === "'" && B[A + 3] === "'") {
|
|
11291
|
+
w = fraction_assign(B[A], s);
|
|
11292
|
+
y = Math.pow(10, B[A].length);
|
|
11293
|
+
A++;
|
|
11294
|
+
}
|
|
11295
|
+
|
|
11296
|
+
// Check for repeating places
|
|
11297
|
+
if (B[A] === '(' && B[A + 2] === ')' || B[A] === "'" && B[A + 2] === "'") {
|
|
11298
|
+
x = fraction_assign(B[A + 1], s);
|
|
11299
|
+
z = Math.pow(10, B[A + 1].length) - 1;
|
|
11300
|
+
A+= 3;
|
|
11301
|
+
}
|
|
11302
|
+
|
|
11303
|
+
} else if (B[A + 1] === '/' || B[A + 1] === ':') { // Check for a simple fraction "123/456" or "123:456"
|
|
11304
|
+
w = fraction_assign(B[A], s);
|
|
11305
|
+
y = fraction_assign(B[A + 2], 1);
|
|
11306
|
+
A+= 3;
|
|
11307
|
+
} else if (B[A + 3] === '/' && B[A + 1] === ' ') { // Check for a complex fraction "123 1/2"
|
|
11308
|
+
v = fraction_assign(B[A], s);
|
|
11309
|
+
w = fraction_assign(B[A + 2], s);
|
|
11310
|
+
y = fraction_assign(B[A + 4], 1);
|
|
11311
|
+
A+= 5;
|
|
11312
|
+
}
|
|
11313
|
+
|
|
11314
|
+
if (B.length <= A) { // Check for more tokens on the stack
|
|
11315
|
+
d = y * z;
|
|
11316
|
+
s = /* void */
|
|
11317
|
+
n = x + d * v + z * w;
|
|
11318
|
+
break;
|
|
11319
|
+
}
|
|
11320
|
+
|
|
11321
|
+
/* Fall through on error */
|
|
11322
|
+
}
|
|
11323
|
+
default:
|
|
11324
|
+
throw InvalidParameter();
|
|
11325
|
+
}
|
|
11326
|
+
|
|
11327
|
+
if (d === 0) {
|
|
11328
|
+
throw DivisionByZero();
|
|
11329
|
+
}
|
|
11330
|
+
|
|
11331
|
+
fraction_P["s"] = s < 0 ? -1 : 1;
|
|
11332
|
+
fraction_P["n"] = Math.abs(n);
|
|
11333
|
+
fraction_P["d"] = Math.abs(d);
|
|
11334
|
+
};
|
|
11335
|
+
|
|
11336
|
+
function modpow(b, e, m) {
|
|
11337
|
+
|
|
11338
|
+
var r = 1;
|
|
11339
|
+
for (; e > 0; b = (b * b) % m, e >>= 1) {
|
|
11340
|
+
|
|
11341
|
+
if (e & 1) {
|
|
11342
|
+
r = (r * b) % m;
|
|
11343
|
+
}
|
|
11344
|
+
}
|
|
11345
|
+
return r;
|
|
11346
|
+
}
|
|
11347
|
+
|
|
11348
|
+
|
|
11349
|
+
function cycleLen(n, d) {
|
|
11350
|
+
|
|
11351
|
+
for (; d % 2 === 0;
|
|
11352
|
+
d/= 2) {
|
|
11353
|
+
}
|
|
11354
|
+
|
|
11355
|
+
for (; d % 5 === 0;
|
|
11356
|
+
d/= 5) {
|
|
11357
|
+
}
|
|
11358
|
+
|
|
11359
|
+
if (d === 1) // Catch non-cyclic numbers
|
|
11360
|
+
return 0;
|
|
11361
|
+
|
|
11362
|
+
// If we would like to compute really large numbers quicker, we could make use of Fermat's little theorem:
|
|
11363
|
+
// 10^(d-1) % d == 1
|
|
11364
|
+
// However, we don't need such large numbers and MAX_CYCLE_LEN should be the capstone,
|
|
11365
|
+
// as we want to translate the numbers to strings.
|
|
11366
|
+
|
|
11367
|
+
var rem = 10 % d;
|
|
11368
|
+
var t = 1;
|
|
11369
|
+
|
|
11370
|
+
for (; rem !== 1; t++) {
|
|
11371
|
+
rem = rem * 10 % d;
|
|
11372
|
+
|
|
11373
|
+
if (t > MAX_CYCLE_LEN)
|
|
11374
|
+
return 0; // Returning 0 here means that we don't print it as a cyclic number. It's likely that the answer is `d-1`
|
|
11375
|
+
}
|
|
11376
|
+
return t;
|
|
11377
|
+
}
|
|
11378
|
+
|
|
11379
|
+
|
|
11380
|
+
function cycleStart(n, d, len) {
|
|
11381
|
+
|
|
11382
|
+
var rem1 = 1;
|
|
11383
|
+
var rem2 = modpow(10, len, d);
|
|
11384
|
+
|
|
11385
|
+
for (var t = 0; t < 300; t++) { // s < ~log10(Number.MAX_VALUE)
|
|
11386
|
+
// Solve 10^s == 10^(s+t) (mod d)
|
|
11387
|
+
|
|
11388
|
+
if (rem1 === rem2)
|
|
11389
|
+
return t;
|
|
11390
|
+
|
|
11391
|
+
rem1 = rem1 * 10 % d;
|
|
11392
|
+
rem2 = rem2 * 10 % d;
|
|
11393
|
+
}
|
|
11394
|
+
return 0;
|
|
11395
|
+
}
|
|
11396
|
+
|
|
11397
|
+
function gcd(a, b) {
|
|
11398
|
+
|
|
11399
|
+
if (!a)
|
|
11400
|
+
return b;
|
|
11401
|
+
if (!b)
|
|
11402
|
+
return a;
|
|
11403
|
+
|
|
11404
|
+
while (1) {
|
|
11405
|
+
a%= b;
|
|
11406
|
+
if (!a)
|
|
11407
|
+
return b;
|
|
11408
|
+
b%= a;
|
|
11409
|
+
if (!b)
|
|
11410
|
+
return a;
|
|
11411
|
+
}
|
|
11412
|
+
};
|
|
11413
|
+
|
|
11414
|
+
/**
|
|
11415
|
+
* Module constructor
|
|
11416
|
+
*
|
|
11417
|
+
* @constructor
|
|
11418
|
+
* @param {number|Fraction=} a
|
|
11419
|
+
* @param {number=} b
|
|
11420
|
+
*/
|
|
11421
|
+
function Fraction(a, b) {
|
|
11422
|
+
|
|
11423
|
+
fraction_parse(a, b);
|
|
11424
|
+
|
|
11425
|
+
if (this instanceof Fraction) {
|
|
11426
|
+
a = gcd(fraction_P["d"], fraction_P["n"]); // Abuse variable a
|
|
11427
|
+
this["s"] = fraction_P["s"];
|
|
11428
|
+
this["n"] = fraction_P["n"] / a;
|
|
11429
|
+
this["d"] = fraction_P["d"] / a;
|
|
11430
|
+
} else {
|
|
11431
|
+
return newFraction(fraction_P['s'] * fraction_P['n'], fraction_P['d']);
|
|
11432
|
+
}
|
|
11433
|
+
}
|
|
11434
|
+
|
|
11435
|
+
var DivisionByZero = function() { return new Error("Division by Zero"); };
|
|
11436
|
+
var InvalidParameter = function() { return new Error("Invalid argument"); };
|
|
11437
|
+
var NonIntegerParameter = function() { return new Error("Parameters must be integer"); };
|
|
11438
|
+
|
|
11439
|
+
Fraction.prototype = {
|
|
11440
|
+
|
|
11441
|
+
"s": 1,
|
|
11442
|
+
"n": 0,
|
|
11443
|
+
"d": 1,
|
|
11444
|
+
|
|
11445
|
+
/**
|
|
11446
|
+
* Calculates the absolute value
|
|
11447
|
+
*
|
|
11448
|
+
* Ex: new Fraction(-4).abs() => 4
|
|
11449
|
+
**/
|
|
11450
|
+
"abs": function() {
|
|
11451
|
+
|
|
11452
|
+
return newFraction(this["n"], this["d"]);
|
|
11453
|
+
},
|
|
11454
|
+
|
|
11455
|
+
/**
|
|
11456
|
+
* Inverts the sign of the current fraction
|
|
11457
|
+
*
|
|
11458
|
+
* Ex: new Fraction(-4).neg() => 4
|
|
11459
|
+
**/
|
|
11460
|
+
"neg": function() {
|
|
11461
|
+
|
|
11462
|
+
return newFraction(-this["s"] * this["n"], this["d"]);
|
|
11463
|
+
},
|
|
11464
|
+
|
|
11465
|
+
/**
|
|
11466
|
+
* Adds two rational numbers
|
|
11467
|
+
*
|
|
11468
|
+
* Ex: new Fraction({n: 2, d: 3}).add("14.9") => 467 / 30
|
|
11469
|
+
**/
|
|
11470
|
+
"add": function(a, b) {
|
|
11471
|
+
|
|
11472
|
+
fraction_parse(a, b);
|
|
11473
|
+
return newFraction(
|
|
11474
|
+
this["s"] * this["n"] * fraction_P["d"] + fraction_P["s"] * this["d"] * fraction_P["n"],
|
|
11475
|
+
this["d"] * fraction_P["d"]
|
|
11476
|
+
);
|
|
11477
|
+
},
|
|
11478
|
+
|
|
11479
|
+
/**
|
|
11480
|
+
* Subtracts two rational numbers
|
|
11481
|
+
*
|
|
11482
|
+
* Ex: new Fraction({n: 2, d: 3}).add("14.9") => -427 / 30
|
|
11483
|
+
**/
|
|
11484
|
+
"sub": function(a, b) {
|
|
11485
|
+
|
|
11486
|
+
fraction_parse(a, b);
|
|
11487
|
+
return newFraction(
|
|
11488
|
+
this["s"] * this["n"] * fraction_P["d"] - fraction_P["s"] * this["d"] * fraction_P["n"],
|
|
11489
|
+
this["d"] * fraction_P["d"]
|
|
11490
|
+
);
|
|
11491
|
+
},
|
|
11492
|
+
|
|
11493
|
+
/**
|
|
11494
|
+
* Multiplies two rational numbers
|
|
11495
|
+
*
|
|
11496
|
+
* Ex: new Fraction("-17.(345)").mul(3) => 5776 / 111
|
|
11497
|
+
**/
|
|
11498
|
+
"mul": function(a, b) {
|
|
11499
|
+
|
|
11500
|
+
fraction_parse(a, b);
|
|
11501
|
+
return newFraction(
|
|
11502
|
+
this["s"] * fraction_P["s"] * this["n"] * fraction_P["n"],
|
|
11503
|
+
this["d"] * fraction_P["d"]
|
|
11504
|
+
);
|
|
11505
|
+
},
|
|
11506
|
+
|
|
11507
|
+
/**
|
|
11508
|
+
* Divides two rational numbers
|
|
11509
|
+
*
|
|
11510
|
+
* Ex: new Fraction("-17.(345)").inverse().div(3)
|
|
11511
|
+
**/
|
|
11512
|
+
"div": function(a, b) {
|
|
11513
|
+
|
|
11514
|
+
fraction_parse(a, b);
|
|
11515
|
+
return newFraction(
|
|
11516
|
+
this["s"] * fraction_P["s"] * this["n"] * fraction_P["d"],
|
|
11517
|
+
this["d"] * fraction_P["n"]
|
|
11518
|
+
);
|
|
11519
|
+
},
|
|
11520
|
+
|
|
11521
|
+
/**
|
|
11522
|
+
* Clones the actual object
|
|
11523
|
+
*
|
|
11524
|
+
* Ex: new Fraction("-17.(345)").clone()
|
|
11525
|
+
**/
|
|
11526
|
+
"clone": function() {
|
|
11527
|
+
return newFraction(this['s'] * this['n'], this['d']);
|
|
11528
|
+
},
|
|
11529
|
+
|
|
11530
|
+
/**
|
|
11531
|
+
* Calculates the modulo of two rational numbers - a more precise fmod
|
|
11532
|
+
*
|
|
11533
|
+
* Ex: new Fraction('4.(3)').mod([7, 8]) => (13/3) % (7/8) = (5/6)
|
|
11534
|
+
**/
|
|
11535
|
+
"mod": function(a, b) {
|
|
11536
|
+
|
|
11537
|
+
if (isNaN(this['n']) || isNaN(this['d'])) {
|
|
11538
|
+
return new Fraction(NaN);
|
|
11539
|
+
}
|
|
11540
|
+
|
|
11541
|
+
if (a === undefined) {
|
|
11542
|
+
return newFraction(this["s"] * this["n"] % this["d"], 1);
|
|
11543
|
+
}
|
|
11544
|
+
|
|
11545
|
+
fraction_parse(a, b);
|
|
11546
|
+
if (0 === fraction_P["n"] && 0 === this["d"]) {
|
|
11547
|
+
throw DivisionByZero();
|
|
11548
|
+
}
|
|
11549
|
+
|
|
11550
|
+
/*
|
|
11551
|
+
* First silly attempt, kinda slow
|
|
11552
|
+
*
|
|
11553
|
+
return that["sub"]({
|
|
11554
|
+
"n": num["n"] * Math.floor((this.n / this.d) / (num.n / num.d)),
|
|
11555
|
+
"d": num["d"],
|
|
11556
|
+
"s": this["s"]
|
|
11557
|
+
});*/
|
|
11558
|
+
|
|
11559
|
+
/*
|
|
11560
|
+
* New attempt: a1 / b1 = a2 / b2 * q + r
|
|
11561
|
+
* => b2 * a1 = a2 * b1 * q + b1 * b2 * r
|
|
11562
|
+
* => (b2 * a1 % a2 * b1) / (b1 * b2)
|
|
11563
|
+
*/
|
|
11564
|
+
return newFraction(
|
|
11565
|
+
this["s"] * (fraction_P["d"] * this["n"]) % (fraction_P["n"] * this["d"]),
|
|
11566
|
+
fraction_P["d"] * this["d"]
|
|
11567
|
+
);
|
|
11568
|
+
},
|
|
11569
|
+
|
|
11570
|
+
/**
|
|
11571
|
+
* Calculates the fractional gcd of two rational numbers
|
|
11572
|
+
*
|
|
11573
|
+
* Ex: new Fraction(5,8).gcd(3,7) => 1/56
|
|
11574
|
+
*/
|
|
11575
|
+
"gcd": function(a, b) {
|
|
11576
|
+
|
|
11577
|
+
fraction_parse(a, b);
|
|
11578
|
+
|
|
11579
|
+
// gcd(a / b, c / d) = gcd(a, c) / lcm(b, d)
|
|
11580
|
+
|
|
11581
|
+
return newFraction(gcd(fraction_P["n"], this["n"]) * gcd(fraction_P["d"], this["d"]), fraction_P["d"] * this["d"]);
|
|
11582
|
+
},
|
|
11583
|
+
|
|
11584
|
+
/**
|
|
11585
|
+
* Calculates the fractional lcm of two rational numbers
|
|
11586
|
+
*
|
|
11587
|
+
* Ex: new Fraction(5,8).lcm(3,7) => 15
|
|
11588
|
+
*/
|
|
11589
|
+
"lcm": function(a, b) {
|
|
11590
|
+
|
|
11591
|
+
fraction_parse(a, b);
|
|
11592
|
+
|
|
11593
|
+
// lcm(a / b, c / d) = lcm(a, c) / gcd(b, d)
|
|
11594
|
+
|
|
11595
|
+
if (fraction_P["n"] === 0 && this["n"] === 0) {
|
|
11596
|
+
return newFraction(0, 1);
|
|
11597
|
+
}
|
|
11598
|
+
return newFraction(fraction_P["n"] * this["n"], gcd(fraction_P["n"], this["n"]) * gcd(fraction_P["d"], this["d"]));
|
|
11599
|
+
},
|
|
11600
|
+
|
|
11601
|
+
/**
|
|
11602
|
+
* Calculates the ceil of a rational number
|
|
11603
|
+
*
|
|
11604
|
+
* Ex: new Fraction('4.(3)').ceil() => (5 / 1)
|
|
11605
|
+
**/
|
|
11606
|
+
"ceil": function(places) {
|
|
11607
|
+
|
|
11608
|
+
places = Math.pow(10, places || 0);
|
|
11609
|
+
|
|
11610
|
+
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
|
11611
|
+
return new Fraction(NaN);
|
|
11612
|
+
}
|
|
11613
|
+
return newFraction(Math.ceil(places * this["s"] * this["n"] / this["d"]), places);
|
|
11614
|
+
},
|
|
11615
|
+
|
|
11616
|
+
/**
|
|
11617
|
+
* Calculates the floor of a rational number
|
|
11618
|
+
*
|
|
11619
|
+
* Ex: new Fraction('4.(3)').floor() => (4 / 1)
|
|
11620
|
+
**/
|
|
11621
|
+
"floor": function(places) {
|
|
11622
|
+
|
|
11623
|
+
places = Math.pow(10, places || 0);
|
|
11624
|
+
|
|
11625
|
+
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
|
11626
|
+
return new Fraction(NaN);
|
|
11627
|
+
}
|
|
11628
|
+
return newFraction(Math.floor(places * this["s"] * this["n"] / this["d"]), places);
|
|
11629
|
+
},
|
|
11630
|
+
|
|
11631
|
+
/**
|
|
11632
|
+
* Rounds a rational number
|
|
11633
|
+
*
|
|
11634
|
+
* Ex: new Fraction('4.(3)').round() => (4 / 1)
|
|
11635
|
+
**/
|
|
11636
|
+
"round": function(places) {
|
|
11637
|
+
|
|
11638
|
+
places = Math.pow(10, places || 0);
|
|
11639
|
+
|
|
11640
|
+
if (isNaN(this["n"]) || isNaN(this["d"])) {
|
|
11641
|
+
return new Fraction(NaN);
|
|
11642
|
+
}
|
|
11643
|
+
return newFraction(Math.round(places * this["s"] * this["n"] / this["d"]), places);
|
|
11644
|
+
},
|
|
11645
|
+
|
|
11646
|
+
/**
|
|
11647
|
+
* Rounds a rational number to a multiple of another rational number
|
|
11648
|
+
*
|
|
11649
|
+
* Ex: new Fraction('0.9').roundTo("1/8") => 7 / 8
|
|
11650
|
+
**/
|
|
11651
|
+
"roundTo": function(a, b) {
|
|
11652
|
+
|
|
11653
|
+
/*
|
|
11654
|
+
k * x/y ≤ a/b < (k+1) * x/y
|
|
11655
|
+
⇔ k ≤ a/b / (x/y) < (k+1)
|
|
11656
|
+
⇔ k = floor(a/b * y/x)
|
|
11657
|
+
*/
|
|
11658
|
+
|
|
11659
|
+
fraction_parse(a, b);
|
|
11660
|
+
|
|
11661
|
+
return newFraction(this['s'] * Math.round(this['n'] * fraction_P['d'] / (this['d'] * fraction_P['n'])) * fraction_P['n'], fraction_P['d']);
|
|
11662
|
+
},
|
|
11663
|
+
|
|
11664
|
+
/**
|
|
11665
|
+
* Gets the inverse of the fraction, means numerator and denominator are exchanged
|
|
11666
|
+
*
|
|
11667
|
+
* Ex: new Fraction([-3, 4]).inverse() => -4 / 3
|
|
11668
|
+
**/
|
|
11669
|
+
"inverse": function() {
|
|
11670
|
+
|
|
11671
|
+
return newFraction(this["s"] * this["d"], this["n"]);
|
|
11672
|
+
},
|
|
11673
|
+
|
|
11674
|
+
/**
|
|
11675
|
+
* Calculates the fraction to some rational exponent, if possible
|
|
11676
|
+
*
|
|
11677
|
+
* Ex: new Fraction(-1,2).pow(-3) => -8
|
|
11678
|
+
*/
|
|
11679
|
+
"pow": function(a, b) {
|
|
11680
|
+
|
|
11681
|
+
fraction_parse(a, b);
|
|
11682
|
+
|
|
11683
|
+
// Trivial case when exp is an integer
|
|
11684
|
+
|
|
11685
|
+
if (fraction_P['d'] === 1) {
|
|
11686
|
+
|
|
11687
|
+
if (fraction_P['s'] < 0) {
|
|
11688
|
+
return newFraction(Math.pow(this['s'] * this["d"], fraction_P['n']), Math.pow(this["n"], fraction_P['n']));
|
|
11689
|
+
} else {
|
|
11690
|
+
return newFraction(Math.pow(this['s'] * this["n"], fraction_P['n']), Math.pow(this["d"], fraction_P['n']));
|
|
11691
|
+
}
|
|
11692
|
+
}
|
|
11693
|
+
|
|
11694
|
+
// Negative roots become complex
|
|
11695
|
+
// (-a/b)^(c/d) = x
|
|
11696
|
+
// <=> (-1)^(c/d) * (a/b)^(c/d) = x
|
|
11697
|
+
// <=> (cos(pi) + i*sin(pi))^(c/d) * (a/b)^(c/d) = x # rotate 1 by 180°
|
|
11698
|
+
// <=> (cos(c*pi/d) + i*sin(c*pi/d)) * (a/b)^(c/d) = x # DeMoivre's formula in Q ( https://proofwiki.org/wiki/De_Moivre%27s_Formula/Rational_Index )
|
|
11699
|
+
// From which follows that only for c=0 the root is non-complex. c/d is a reduced fraction, so that sin(c/dpi)=0 occurs for d=1, which is handled by our trivial case.
|
|
11700
|
+
if (this['s'] < 0) return null;
|
|
11701
|
+
|
|
11702
|
+
// Now prime factor n and d
|
|
11703
|
+
var N = factorize(this['n']);
|
|
11704
|
+
var D = factorize(this['d']);
|
|
11705
|
+
|
|
11706
|
+
// Exponentiate and take root for n and d individually
|
|
11707
|
+
var n = 1;
|
|
11708
|
+
var d = 1;
|
|
11709
|
+
for (var k in N) {
|
|
11710
|
+
if (k === '1') continue;
|
|
11711
|
+
if (k === '0') {
|
|
11712
|
+
n = 0;
|
|
11713
|
+
break;
|
|
11714
|
+
}
|
|
11715
|
+
N[k]*= fraction_P['n'];
|
|
11716
|
+
|
|
11717
|
+
if (N[k] % fraction_P['d'] === 0) {
|
|
11718
|
+
N[k]/= fraction_P['d'];
|
|
11719
|
+
} else return null;
|
|
11720
|
+
n*= Math.pow(k, N[k]);
|
|
11721
|
+
}
|
|
11722
|
+
|
|
11723
|
+
for (var k in D) {
|
|
11724
|
+
if (k === '1') continue;
|
|
11725
|
+
D[k]*= fraction_P['n'];
|
|
11726
|
+
|
|
11727
|
+
if (D[k] % fraction_P['d'] === 0) {
|
|
11728
|
+
D[k]/= fraction_P['d'];
|
|
11729
|
+
} else return null;
|
|
11730
|
+
d*= Math.pow(k, D[k]);
|
|
11731
|
+
}
|
|
11732
|
+
|
|
11733
|
+
if (fraction_P['s'] < 0) {
|
|
11734
|
+
return newFraction(d, n);
|
|
11735
|
+
}
|
|
11736
|
+
return newFraction(n, d);
|
|
11737
|
+
},
|
|
11738
|
+
|
|
11739
|
+
/**
|
|
11740
|
+
* Check if two rational numbers are the same
|
|
11741
|
+
*
|
|
11742
|
+
* Ex: new Fraction(19.6).equals([98, 5]);
|
|
11743
|
+
**/
|
|
11744
|
+
"equals": function(a, b) {
|
|
11745
|
+
|
|
11746
|
+
fraction_parse(a, b);
|
|
11747
|
+
return this["s"] * this["n"] * fraction_P["d"] === fraction_P["s"] * fraction_P["n"] * this["d"]; // Same as compare() === 0
|
|
11748
|
+
},
|
|
11749
|
+
|
|
11750
|
+
/**
|
|
11751
|
+
* Check if two rational numbers are the same
|
|
11752
|
+
*
|
|
11753
|
+
* Ex: new Fraction(19.6).equals([98, 5]);
|
|
11754
|
+
**/
|
|
11755
|
+
"compare": function(a, b) {
|
|
11756
|
+
|
|
11757
|
+
fraction_parse(a, b);
|
|
11758
|
+
var t = (this["s"] * this["n"] * fraction_P["d"] - fraction_P["s"] * fraction_P["n"] * this["d"]);
|
|
11759
|
+
return (0 < t) - (t < 0);
|
|
11760
|
+
},
|
|
11761
|
+
|
|
11762
|
+
"simplify": function(eps) {
|
|
11763
|
+
|
|
11764
|
+
if (isNaN(this['n']) || isNaN(this['d'])) {
|
|
11765
|
+
return this;
|
|
11766
|
+
}
|
|
11767
|
+
|
|
11768
|
+
eps = eps || 0.001;
|
|
11769
|
+
|
|
11770
|
+
var thisABS = this['abs']();
|
|
11771
|
+
var cont = thisABS['toContinued']();
|
|
11772
|
+
|
|
11773
|
+
for (var i = 1; i < cont.length; i++) {
|
|
11774
|
+
|
|
11775
|
+
var s = newFraction(cont[i - 1], 1);
|
|
11776
|
+
for (var k = i - 2; k >= 0; k--) {
|
|
11777
|
+
s = s['inverse']()['add'](cont[k]);
|
|
11778
|
+
}
|
|
11779
|
+
|
|
11780
|
+
if (Math.abs(s['sub'](thisABS).valueOf()) < eps) {
|
|
11781
|
+
return s['mul'](this['s']);
|
|
11782
|
+
}
|
|
11783
|
+
}
|
|
11784
|
+
return this;
|
|
11785
|
+
},
|
|
11786
|
+
|
|
11787
|
+
/**
|
|
11788
|
+
* Check if two rational numbers are divisible
|
|
11789
|
+
*
|
|
11790
|
+
* Ex: new Fraction(19.6).divisible(1.5);
|
|
11791
|
+
*/
|
|
11792
|
+
"divisible": function(a, b) {
|
|
11793
|
+
|
|
11794
|
+
fraction_parse(a, b);
|
|
11795
|
+
return !(!(fraction_P["n"] * this["d"]) || ((this["n"] * fraction_P["d"]) % (fraction_P["n"] * this["d"])));
|
|
11796
|
+
},
|
|
11797
|
+
|
|
11798
|
+
/**
|
|
11799
|
+
* Returns a decimal representation of the fraction
|
|
11800
|
+
*
|
|
11801
|
+
* Ex: new Fraction("100.'91823'").valueOf() => 100.91823918239183
|
|
11802
|
+
**/
|
|
11803
|
+
'valueOf': function() {
|
|
11804
|
+
|
|
11805
|
+
return this["s"] * this["n"] / this["d"];
|
|
11806
|
+
},
|
|
11807
|
+
|
|
11808
|
+
/**
|
|
11809
|
+
* Returns a string-fraction representation of a Fraction object
|
|
11810
|
+
*
|
|
11811
|
+
* Ex: new Fraction("1.'3'").toFraction(true) => "4 1/3"
|
|
11812
|
+
**/
|
|
11813
|
+
'toFraction': function(excludeWhole) {
|
|
11814
|
+
|
|
11815
|
+
var whole, str = "";
|
|
11816
|
+
var n = this["n"];
|
|
11817
|
+
var d = this["d"];
|
|
11818
|
+
if (this["s"] < 0) {
|
|
11819
|
+
str+= '-';
|
|
11820
|
+
}
|
|
11821
|
+
|
|
11822
|
+
if (d === 1) {
|
|
11823
|
+
str+= n;
|
|
11824
|
+
} else {
|
|
11825
|
+
|
|
11826
|
+
if (excludeWhole && (whole = Math.floor(n / d)) > 0) {
|
|
11827
|
+
str+= whole;
|
|
11828
|
+
str+= " ";
|
|
11829
|
+
n%= d;
|
|
11830
|
+
}
|
|
11831
|
+
|
|
11832
|
+
str+= n;
|
|
11833
|
+
str+= '/';
|
|
11834
|
+
str+= d;
|
|
11835
|
+
}
|
|
11836
|
+
return str;
|
|
11837
|
+
},
|
|
11838
|
+
|
|
11839
|
+
/**
|
|
11840
|
+
* Returns a latex representation of a Fraction object
|
|
11841
|
+
*
|
|
11842
|
+
* Ex: new Fraction("1.'3'").toLatex() => "\frac{4}{3}"
|
|
11843
|
+
**/
|
|
11844
|
+
'toLatex': function(excludeWhole) {
|
|
11845
|
+
|
|
11846
|
+
var whole, str = "";
|
|
11847
|
+
var n = this["n"];
|
|
11848
|
+
var d = this["d"];
|
|
11849
|
+
if (this["s"] < 0) {
|
|
11850
|
+
str+= '-';
|
|
11851
|
+
}
|
|
11852
|
+
|
|
11853
|
+
if (d === 1) {
|
|
11854
|
+
str+= n;
|
|
11855
|
+
} else {
|
|
11856
|
+
|
|
11857
|
+
if (excludeWhole && (whole = Math.floor(n / d)) > 0) {
|
|
11858
|
+
str+= whole;
|
|
11859
|
+
n%= d;
|
|
11860
|
+
}
|
|
11861
|
+
|
|
11862
|
+
str+= "\\frac{";
|
|
11863
|
+
str+= n;
|
|
11864
|
+
str+= '}{';
|
|
11865
|
+
str+= d;
|
|
11866
|
+
str+= '}';
|
|
11867
|
+
}
|
|
11868
|
+
return str;
|
|
11869
|
+
},
|
|
11870
|
+
|
|
11871
|
+
/**
|
|
11872
|
+
* Returns an array of continued fraction elements
|
|
11873
|
+
*
|
|
11874
|
+
* Ex: new Fraction("7/8").toContinued() => [0,1,7]
|
|
11875
|
+
*/
|
|
11876
|
+
'toContinued': function() {
|
|
11877
|
+
|
|
11878
|
+
var t;
|
|
11879
|
+
var a = this['n'];
|
|
11880
|
+
var b = this['d'];
|
|
11881
|
+
var res = [];
|
|
11882
|
+
|
|
11883
|
+
if (isNaN(a) || isNaN(b)) {
|
|
11884
|
+
return res;
|
|
11885
|
+
}
|
|
11886
|
+
|
|
11887
|
+
do {
|
|
11888
|
+
res.push(Math.floor(a / b));
|
|
11889
|
+
t = a % b;
|
|
11890
|
+
a = b;
|
|
11891
|
+
b = t;
|
|
11892
|
+
} while (a !== 1);
|
|
11893
|
+
|
|
11894
|
+
return res;
|
|
11895
|
+
},
|
|
11896
|
+
|
|
11897
|
+
/**
|
|
11898
|
+
* Creates a string representation of a fraction with all digits
|
|
11899
|
+
*
|
|
11900
|
+
* Ex: new Fraction("100.'91823'").toString() => "100.(91823)"
|
|
11901
|
+
**/
|
|
11902
|
+
'toString': function(dec) {
|
|
11903
|
+
|
|
11904
|
+
var N = this["n"];
|
|
11905
|
+
var D = this["d"];
|
|
11906
|
+
|
|
11907
|
+
if (isNaN(N) || isNaN(D)) {
|
|
11908
|
+
return "NaN";
|
|
11909
|
+
}
|
|
11910
|
+
|
|
11911
|
+
dec = dec || 15; // 15 = decimal places when no repetation
|
|
11912
|
+
|
|
11913
|
+
var cycLen = cycleLen(N, D); // Cycle length
|
|
11914
|
+
var cycOff = cycleStart(N, D, cycLen); // Cycle start
|
|
11915
|
+
|
|
11916
|
+
var str = this['s'] < 0 ? "-" : "";
|
|
11917
|
+
|
|
11918
|
+
str+= N / D | 0;
|
|
11919
|
+
|
|
11920
|
+
N%= D;
|
|
11921
|
+
N*= 10;
|
|
11922
|
+
|
|
11923
|
+
if (N)
|
|
11924
|
+
str+= ".";
|
|
11925
|
+
|
|
11926
|
+
if (cycLen) {
|
|
11927
|
+
|
|
11928
|
+
for (var i = cycOff; i--;) {
|
|
11929
|
+
str+= N / D | 0;
|
|
11930
|
+
N%= D;
|
|
11931
|
+
N*= 10;
|
|
11932
|
+
}
|
|
11933
|
+
str+= "(";
|
|
11934
|
+
for (var i = cycLen; i--;) {
|
|
11935
|
+
str+= N / D | 0;
|
|
11936
|
+
N%= D;
|
|
11937
|
+
N*= 10;
|
|
11938
|
+
}
|
|
11939
|
+
str+= ")";
|
|
11940
|
+
} else {
|
|
11941
|
+
for (var i = dec; N && i--;) {
|
|
11942
|
+
str+= N / D | 0;
|
|
11943
|
+
N%= D;
|
|
11944
|
+
N*= 10;
|
|
11945
|
+
}
|
|
11946
|
+
}
|
|
11947
|
+
return str;
|
|
11948
|
+
}
|
|
11949
|
+
};
|
|
11950
|
+
|
|
11945
11951
|
;// CONCATENATED MODULE: ../../../node_modules/mathjs/lib/esm/type/fraction/Fraction.js
|
|
11946
11952
|
|
|
11947
11953
|
|
|
@@ -11951,19 +11957,19 @@ var createFractionClass = /* #__PURE__ */factory_factory(Fraction_name, Fraction
|
|
|
11951
11957
|
/**
|
|
11952
11958
|
* Attach type information
|
|
11953
11959
|
*/
|
|
11954
|
-
Object.defineProperty(
|
|
11960
|
+
Object.defineProperty(Fraction, 'name', {
|
|
11955
11961
|
value: 'Fraction'
|
|
11956
11962
|
});
|
|
11957
|
-
|
|
11958
|
-
|
|
11959
|
-
|
|
11963
|
+
Fraction.prototype.constructor = Fraction;
|
|
11964
|
+
Fraction.prototype.type = 'Fraction';
|
|
11965
|
+
Fraction.prototype.isFraction = true;
|
|
11960
11966
|
|
|
11961
11967
|
/**
|
|
11962
11968
|
* Get a JSON representation of a Fraction containing type information
|
|
11963
11969
|
* @returns {Object} Returns a JSON object structured as:
|
|
11964
11970
|
* `{"mathjs": "Fraction", "n": 3, "d": 8}`
|
|
11965
11971
|
*/
|
|
11966
|
-
|
|
11972
|
+
Fraction.prototype.toJSON = function () {
|
|
11967
11973
|
return {
|
|
11968
11974
|
mathjs: 'Fraction',
|
|
11969
11975
|
n: this.s * this.n,
|
|
@@ -11977,10 +11983,10 @@ var createFractionClass = /* #__PURE__ */factory_factory(Fraction_name, Fraction
|
|
|
11977
11983
|
* `{"mathjs": "Fraction", "n": 3, "d": 8}`
|
|
11978
11984
|
* @return {BigNumber}
|
|
11979
11985
|
*/
|
|
11980
|
-
|
|
11981
|
-
return new
|
|
11986
|
+
Fraction.fromJSON = function (json) {
|
|
11987
|
+
return new Fraction(json);
|
|
11982
11988
|
};
|
|
11983
|
-
return
|
|
11989
|
+
return Fraction;
|
|
11984
11990
|
}, {
|
|
11985
11991
|
isClass: true
|
|
11986
11992
|
});
|
|
@@ -64877,7 +64883,7 @@ var fineStructure = /* #__PURE__ */createFineStructure({
|
|
|
64877
64883
|
BigNumber,
|
|
64878
64884
|
config: config
|
|
64879
64885
|
});
|
|
64880
|
-
var
|
|
64886
|
+
var pureFunctionsAny_generated_Fraction = /* #__PURE__ */createFractionClass({});
|
|
64881
64887
|
var i = /* #__PURE__ */createI({
|
|
64882
64888
|
Complex: pureFunctionsAny_generated_Complex
|
|
64883
64889
|
});
|
|
@@ -64943,7 +64949,7 @@ var typed = /* #__PURE__ */createTyped({
|
|
|
64943
64949
|
BigNumber,
|
|
64944
64950
|
Complex: pureFunctionsAny_generated_Complex,
|
|
64945
64951
|
DenseMatrix,
|
|
64946
|
-
Fraction
|
|
64952
|
+
Fraction: pureFunctionsAny_generated_Fraction
|
|
64947
64953
|
});
|
|
64948
64954
|
var unaryPlus = /* #__PURE__ */createUnaryPlus({
|
|
64949
64955
|
BigNumber,
|
|
@@ -65131,7 +65137,7 @@ var sec = /* #__PURE__ */createSec({
|
|
|
65131
65137
|
});
|
|
65132
65138
|
var pureFunctionsAny_generated_sign = /* #__PURE__ */createSign({
|
|
65133
65139
|
BigNumber,
|
|
65134
|
-
Fraction,
|
|
65140
|
+
Fraction: pureFunctionsAny_generated_Fraction,
|
|
65135
65141
|
complex,
|
|
65136
65142
|
typed
|
|
65137
65143
|
});
|
|
@@ -65236,8 +65242,8 @@ var coth = /* #__PURE__ */createCoth({
|
|
|
65236
65242
|
BigNumber,
|
|
65237
65243
|
typed
|
|
65238
65244
|
});
|
|
65239
|
-
var
|
|
65240
|
-
Fraction,
|
|
65245
|
+
var fraction = /* #__PURE__ */createFraction({
|
|
65246
|
+
Fraction: pureFunctionsAny_generated_Fraction,
|
|
65241
65247
|
typed
|
|
65242
65248
|
});
|
|
65243
65249
|
var isNumeric = /* #__PURE__ */createIsNumeric({
|
|
@@ -65261,7 +65267,7 @@ var mode = /* #__PURE__ */createMode({
|
|
|
65261
65267
|
});
|
|
65262
65268
|
var numeric = /* #__PURE__ */createNumeric({
|
|
65263
65269
|
bignumber,
|
|
65264
|
-
fraction
|
|
65270
|
+
fraction,
|
|
65265
65271
|
number
|
|
65266
65272
|
});
|
|
65267
65273
|
var prod = /* #__PURE__ */createProd({
|
|
@@ -65308,7 +65314,7 @@ var pureFunctionsAny_generated_asin = /* #__PURE__ */createAsin({
|
|
|
65308
65314
|
var pureFunctionsAny_generated_cbrt = /* #__PURE__ */createCbrt({
|
|
65309
65315
|
BigNumber,
|
|
65310
65316
|
Complex: pureFunctionsAny_generated_Complex,
|
|
65311
|
-
Fraction,
|
|
65317
|
+
Fraction: pureFunctionsAny_generated_Fraction,
|
|
65312
65318
|
config: config,
|
|
65313
65319
|
isNegative,
|
|
65314
65320
|
matrix,
|
|
@@ -65549,7 +65555,7 @@ var catalan = /* #__PURE__ */createCatalan({
|
|
|
65549
65555
|
var compare = /* #__PURE__ */createCompare({
|
|
65550
65556
|
BigNumber,
|
|
65551
65557
|
DenseMatrix,
|
|
65552
|
-
Fraction,
|
|
65558
|
+
Fraction: pureFunctionsAny_generated_Fraction,
|
|
65553
65559
|
concat: pureFunctionsAny_generated_concat,
|
|
65554
65560
|
config: config,
|
|
65555
65561
|
equalScalar,
|
|
@@ -65607,7 +65613,7 @@ var pureFunctionsAny_generated_floor = /* #__PURE__ */createFloor({
|
|
|
65607
65613
|
typed,
|
|
65608
65614
|
zeros: pureFunctionsAny_generated_zeros
|
|
65609
65615
|
});
|
|
65610
|
-
var
|
|
65616
|
+
var pureFunctionsAny_generated_gcd = /* #__PURE__ */createGcd({
|
|
65611
65617
|
BigNumber,
|
|
65612
65618
|
DenseMatrix,
|
|
65613
65619
|
concat: pureFunctionsAny_generated_concat,
|
|
@@ -66015,7 +66021,7 @@ var pinv = /* #__PURE__ */createPinv({
|
|
|
66015
66021
|
var pureFunctionsAny_generated_pow = /* #__PURE__ */createPow({
|
|
66016
66022
|
Complex: pureFunctionsAny_generated_Complex,
|
|
66017
66023
|
config: config,
|
|
66018
|
-
fraction
|
|
66024
|
+
fraction,
|
|
66019
66025
|
identity,
|
|
66020
66026
|
inv,
|
|
66021
66027
|
matrix,
|
|
@@ -66056,7 +66062,7 @@ var sqrtm = /* #__PURE__ */createSqrtm({
|
|
|
66056
66062
|
var Unit = /* #__PURE__ */createUnitClass({
|
|
66057
66063
|
BigNumber,
|
|
66058
66064
|
Complex: pureFunctionsAny_generated_Complex,
|
|
66059
|
-
Fraction,
|
|
66065
|
+
Fraction: pureFunctionsAny_generated_Fraction,
|
|
66060
66066
|
abs: pureFunctionsAny_generated_abs,
|
|
66061
66067
|
addScalar,
|
|
66062
66068
|
config: config,
|
|
@@ -66757,7 +66763,7 @@ var resolve = createResolve({
|
|
|
66757
66763
|
});
|
|
66758
66764
|
var simplifyConstant = createSimplifyConstant({
|
|
66759
66765
|
bignumber: bignumber,
|
|
66760
|
-
fraction:
|
|
66766
|
+
fraction: fraction,
|
|
66761
66767
|
AccessorNode,
|
|
66762
66768
|
ArrayNode,
|
|
66763
66769
|
ConstantNode,
|
|
@@ -66807,7 +66813,7 @@ var Parser = createParserClass({
|
|
|
66807
66813
|
});
|
|
66808
66814
|
var simplify = createSimplify({
|
|
66809
66815
|
bignumber: bignumber,
|
|
66810
|
-
fraction:
|
|
66816
|
+
fraction: fraction,
|
|
66811
66817
|
AccessorNode,
|
|
66812
66818
|
ArrayNode,
|
|
66813
66819
|
ConstantNode,
|
|
@@ -66849,7 +66855,7 @@ var parser = createParser({
|
|
|
66849
66855
|
});
|
|
66850
66856
|
var rationalize = createRationalize({
|
|
66851
66857
|
bignumber: bignumber,
|
|
66852
|
-
fraction:
|
|
66858
|
+
fraction: fraction,
|
|
66853
66859
|
AccessorNode,
|
|
66854
66860
|
ArrayNode,
|
|
66855
66861
|
ConstantNode,
|
|
@@ -66998,7 +67004,7 @@ var help = createHelp({
|
|
|
66998
67004
|
unaryMinus: unaryMinus,
|
|
66999
67005
|
acoth: acoth,
|
|
67000
67006
|
coth: coth,
|
|
67001
|
-
fraction:
|
|
67007
|
+
fraction: fraction,
|
|
67002
67008
|
isNumeric: isNumeric,
|
|
67003
67009
|
matrix: matrix,
|
|
67004
67010
|
matrixFromFunction: matrixFromFunction,
|
|
@@ -67055,7 +67061,7 @@ var help = createHelp({
|
|
|
67055
67061
|
dot: dot,
|
|
67056
67062
|
equalText: equalText,
|
|
67057
67063
|
floor: pureFunctionsAny_generated_floor,
|
|
67058
|
-
gcd:
|
|
67064
|
+
gcd: pureFunctionsAny_generated_gcd,
|
|
67059
67065
|
hypot: pureFunctionsAny_generated_hypot,
|
|
67060
67066
|
larger: larger,
|
|
67061
67067
|
log: pureFunctionsAny_generated_log,
|
|
@@ -67361,7 +67367,7 @@ var help = createHelp({
|
|
|
67361
67367
|
(0,esm_extends/* default */.A)(classes, {
|
|
67362
67368
|
BigNumber: BigNumber,
|
|
67363
67369
|
Complex: pureFunctionsAny_generated_Complex,
|
|
67364
|
-
Fraction:
|
|
67370
|
+
Fraction: pureFunctionsAny_generated_Fraction,
|
|
67365
67371
|
Matrix: Matrix,
|
|
67366
67372
|
Node,
|
|
67367
67373
|
ObjectNode,
|