pimath 0.0.14 → 0.0.18
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/dev/index.html +37 -3
- package/dev/pi.js +901 -721
- package/dev/pi.js.map +1 -1
- package/dist/pi.js +1 -1
- package/dist/pi.js.map +1 -1
- package/esm/main.js +24 -22
- package/esm/main.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +2 -1
- package/esm/maths/algebra/equation.js +29 -25
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/index.d.ts +0 -20
- package/esm/maths/algebra/index.js +18 -33
- package/esm/maths/algebra/index.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +1 -1
- package/esm/maths/algebra/linearSystem.js +19 -15
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.js +7 -3
- package/esm/maths/algebra/logicalset.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +15 -18
- package/esm/maths/algebra/monom.js +182 -84
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +6 -27
- package/esm/maths/algebra/polynom.js +62 -218
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.js +15 -10
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +20 -10
- package/esm/maths/coefficients/fraction.js +83 -15
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/index.js +14 -2
- package/esm/maths/coefficients/index.js.map +1 -1
- package/esm/maths/coefficients/nthroot.js +5 -1
- package/esm/maths/coefficients/nthroot.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +12 -0
- package/esm/maths/geometry/circle.js +79 -13
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/index.d.ts +0 -17
- package/esm/maths/geometry/index.js +17 -28
- package/esm/maths/geometry/index.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +18 -4
- package/esm/maths/geometry/line.js +109 -49
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +1 -0
- package/esm/maths/geometry/point.js +22 -12
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.js +31 -27
- package/esm/maths/geometry/triangle.js.map +1 -1
- package/esm/maths/geometry/vector.d.ts +0 -1
- package/esm/maths/geometry/vector.js +22 -21
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/numeric.js +5 -1
- package/esm/maths/numeric.js.map +1 -1
- package/esm/maths/random/index.d.ts +3 -1
- package/esm/maths/random/index.js +32 -14
- package/esm/maths/random/index.js.map +1 -1
- package/esm/maths/random/randomCore.js +5 -1
- package/esm/maths/random/randomCore.js.map +1 -1
- package/esm/maths/random/rndFraction.d.ts +9 -0
- package/esm/maths/random/rndFraction.js +30 -0
- package/esm/maths/random/rndFraction.js.map +1 -0
- package/esm/maths/random/rndHelpers.js +5 -1
- package/esm/maths/random/rndHelpers.js.map +1 -1
- package/esm/maths/random/rndMonom.d.ts +2 -2
- package/esm/maths/random/rndMonom.js +15 -8
- package/esm/maths/random/rndMonom.js.map +1 -1
- package/esm/maths/random/rndPolynom.d.ts +1 -1
- package/esm/maths/random/rndPolynom.js +22 -10
- package/esm/maths/random/rndPolynom.js.map +1 -1
- package/esm/maths/random/rndTypes.d.ts +5 -0
- package/esm/maths/random/rndTypes.js +2 -1
- package/esm/maths/shutingyard.js +5 -1
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +5 -5
- package/src/maths/algebra/equation.ts +8 -7
- package/src/maths/algebra/index.ts +1 -17
- package/src/maths/algebra/linearSystem.ts +3 -3
- package/src/maths/algebra/monom.ts +764 -612
- package/src/maths/algebra/monom_bck.backup +746 -0
- package/src/maths/algebra/polynom.ts +977 -1176
- package/src/maths/algebra/rational.ts +6 -6
- package/src/maths/coefficients/fraction.ts +98 -27
- package/src/maths/geometry/circle.ts +106 -19
- package/src/maths/geometry/index.ts +0 -14
- package/src/maths/geometry/line.ts +145 -58
- package/src/maths/geometry/point.ts +9 -0
- package/src/maths/geometry/vector.ts +1 -5
- package/src/maths/random/index.ts +7 -1
- package/src/maths/random/rndFraction.ts +37 -0
- package/src/maths/random/rndMonom.ts +6 -3
- package/src/maths/random/rndPolynom.ts +15 -5
- package/src/maths/random/rndTypes.ts +5 -0
- package/src/maths/shutingyard.ts +2 -0
- package/tests/algebra/monom.test.ts +47 -8
- package/tests/algebra/polynom.test.ts +13 -22
- package/tests/coefficients/fraction.test.ts +35 -38
- package/tests/shutingyard.test.ts +0 -1
- package/tsconfig.json +2 -2
- package/tsconfig.testing.json +28 -0
package/dev/pi.js
CHANGED
|
@@ -6,20 +6,15 @@
|
|
|
6
6
|
/*!***************************************!*\
|
|
7
7
|
!*** ./src/maths/algebra/equation.ts ***!
|
|
8
8
|
\***************************************/
|
|
9
|
-
/***/ ((__unused_webpack_module,
|
|
9
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
10
10
|
|
|
11
|
-
__webpack_require__.r(__webpack_exports__);
|
|
12
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
13
|
-
/* harmony export */ "default": () => (/* binding */ Equation)
|
|
14
|
-
/* harmony export */ });
|
|
15
|
-
/* harmony import */ var _polynom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
16
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
17
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
18
|
-
/* harmony import */ var _coefficients_nthroot__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../coefficients/nthroot */ "./src/maths/coefficients/nthroot.ts");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
11
|
|
|
12
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
13
|
+
exports.Equation = void 0;
|
|
14
|
+
const polynom_1 = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
15
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
16
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
17
|
+
const coefficients_2 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
23
18
|
class Equation {
|
|
24
19
|
_left;
|
|
25
20
|
_right;
|
|
@@ -29,8 +24,8 @@ class Equation {
|
|
|
29
24
|
_varnothing = '\\varnothing';
|
|
30
25
|
_real = '\\mathbb{R}';
|
|
31
26
|
constructor(...equations) {
|
|
32
|
-
this._left = new
|
|
33
|
-
this._right = new
|
|
27
|
+
this._left = new polynom_1.Polynom().zero();
|
|
28
|
+
this._right = new polynom_1.Polynom().zero();
|
|
34
29
|
this._sign = '=';
|
|
35
30
|
if (equations.length === 1) {
|
|
36
31
|
if (equations[0].isEquation === true) {
|
|
@@ -41,8 +36,8 @@ class Equation {
|
|
|
41
36
|
}
|
|
42
37
|
}
|
|
43
38
|
else if (equations.length === 2) {
|
|
44
|
-
this.left = equations[0].
|
|
45
|
-
this.right = equations[1].
|
|
39
|
+
this.left = (equations[0] instanceof polynom_1.Polynom) ? equations[0].clone() : new polynom_1.Polynom(equations[0]);
|
|
40
|
+
this.right = (equations[1] instanceof polynom_1.Polynom) ? equations[1].clone() : new polynom_1.Polynom(equations[1]);
|
|
46
41
|
}
|
|
47
42
|
else {
|
|
48
43
|
return this;
|
|
@@ -124,7 +119,7 @@ class Equation {
|
|
|
124
119
|
return;
|
|
125
120
|
}
|
|
126
121
|
pStr = equationString.split(strSign);
|
|
127
|
-
return this.create(new
|
|
122
|
+
return this.create(new polynom_1.Polynom(pStr[0]), new polynom_1.Polynom(pStr[1]), this._formatSign(strSign));
|
|
128
123
|
};
|
|
129
124
|
_findSign = (equationString) => {
|
|
130
125
|
let strSign = '';
|
|
@@ -225,7 +220,7 @@ class Equation {
|
|
|
225
220
|
this._randomizeDefaults = value;
|
|
226
221
|
}
|
|
227
222
|
randomize = (opts, sign) => {
|
|
228
|
-
return new Equation().create(new
|
|
223
|
+
return new Equation().create(new polynom_1.Polynom(), new polynom_1.Polynom(), sign);
|
|
229
224
|
};
|
|
230
225
|
moveLeft = () => {
|
|
231
226
|
this._left = this._left.clone().subtract(this._right);
|
|
@@ -240,7 +235,7 @@ class Equation {
|
|
|
240
235
|
}
|
|
241
236
|
let mMove;
|
|
242
237
|
for (let m of this._left.monoms) {
|
|
243
|
-
if (m.degree()
|
|
238
|
+
if (m.degree().isZero()) {
|
|
244
239
|
mMove = m.clone();
|
|
245
240
|
this._left.subtract(mMove);
|
|
246
241
|
this._right.subtract(mMove);
|
|
@@ -251,12 +246,12 @@ class Equation {
|
|
|
251
246
|
return this;
|
|
252
247
|
};
|
|
253
248
|
simplify = () => {
|
|
254
|
-
this.multiply(
|
|
255
|
-
this.divide(
|
|
249
|
+
this.multiply(numeric_1.Numeric.lcm(...this._left.getDenominators(), ...this._right.getDenominators()));
|
|
250
|
+
this.divide(numeric_1.Numeric.gcd(...this._left.getNumerators(), ...this._right.getNumerators()));
|
|
256
251
|
return this;
|
|
257
252
|
};
|
|
258
253
|
isolate = (letter) => {
|
|
259
|
-
if (this.degree(letter)
|
|
254
|
+
if (!this.degree(letter).isOne()) {
|
|
260
255
|
return false;
|
|
261
256
|
}
|
|
262
257
|
if (this.isMultiVariable()) {
|
|
@@ -286,7 +281,7 @@ class Equation {
|
|
|
286
281
|
return this;
|
|
287
282
|
};
|
|
288
283
|
multiply = (value) => {
|
|
289
|
-
let F = new
|
|
284
|
+
let F = new coefficients_1.Fraction(value);
|
|
290
285
|
this._left.multiply(F);
|
|
291
286
|
this._right.multiply(F);
|
|
292
287
|
if (this._sign !== '=' && F.sign() === -1) {
|
|
@@ -295,7 +290,7 @@ class Equation {
|
|
|
295
290
|
return this;
|
|
296
291
|
};
|
|
297
292
|
divide = (value) => {
|
|
298
|
-
let F = new
|
|
293
|
+
let F = new coefficients_1.Fraction(value);
|
|
299
294
|
if (F.isZero()) {
|
|
300
295
|
return this;
|
|
301
296
|
}
|
|
@@ -304,7 +299,7 @@ class Equation {
|
|
|
304
299
|
}
|
|
305
300
|
};
|
|
306
301
|
degree = (letter) => {
|
|
307
|
-
return
|
|
302
|
+
return coefficients_1.Fraction.max(this._left.degree(letter), this._right.degree(letter));
|
|
308
303
|
};
|
|
309
304
|
isMultiVariable = () => {
|
|
310
305
|
return this._left.isMultiVariable || this._right.isMultiVariable;
|
|
@@ -315,7 +310,7 @@ class Equation {
|
|
|
315
310
|
solve = (letter) => {
|
|
316
311
|
this._solutions = [];
|
|
317
312
|
this._polynom = this._left.clone().subtract(this._right);
|
|
318
|
-
switch (this._polynom.degree(letter)) {
|
|
313
|
+
switch (this._polynom.degree(letter).value) {
|
|
319
314
|
case 0:
|
|
320
315
|
case 1:
|
|
321
316
|
this._solveDegree1(letter);
|
|
@@ -391,7 +386,7 @@ class Equation {
|
|
|
391
386
|
return this._solutions;
|
|
392
387
|
};
|
|
393
388
|
_solveDegree2 = (letter) => {
|
|
394
|
-
let aF = this._polynom.monomByDegree(2, letter).coefficient, bF = this._polynom.monomByDegree(1, letter).coefficient, cF = this._polynom.monomByDegree(0, letter).coefficient, delta, nthDelta, lcm =
|
|
389
|
+
let aF = this._polynom.monomByDegree(2, letter).coefficient, bF = this._polynom.monomByDegree(1, letter).coefficient, cF = this._polynom.monomByDegree(0, letter).coefficient, delta, nthDelta, lcm = numeric_1.Numeric.lcm(aF.denominator, bF.denominator, cF.denominator), a = aF.multiply(lcm).value, b = bF.multiply(lcm).value, c = cF.multiply(lcm).value, realX1, realX2, sX1, sX2;
|
|
395
390
|
delta = b * b - 4 * a * c;
|
|
396
391
|
if (delta > 0) {
|
|
397
392
|
realX1 = (-b - Math.sqrt(delta)) / (2 * a);
|
|
@@ -403,9 +398,9 @@ class Equation {
|
|
|
403
398
|
];
|
|
404
399
|
}
|
|
405
400
|
else {
|
|
406
|
-
nthDelta = new
|
|
401
|
+
nthDelta = new coefficients_2.Nthroot().parse(delta).reduce();
|
|
407
402
|
if (nthDelta.hasRadical()) {
|
|
408
|
-
let gcd =
|
|
403
|
+
let gcd = numeric_1.Numeric.gcd(b, 2 * a, nthDelta.coefficient);
|
|
409
404
|
nthDelta.coefficient = nthDelta.coefficient / gcd;
|
|
410
405
|
if (b !== 0) {
|
|
411
406
|
if (2 * a / gcd === 1) {
|
|
@@ -438,14 +433,14 @@ class Equation {
|
|
|
438
433
|
}
|
|
439
434
|
else {
|
|
440
435
|
this._solutions = [
|
|
441
|
-
new
|
|
442
|
-
new
|
|
436
|
+
new coefficients_1.Fraction(-b - nthDelta.coefficient, 2 * a).reduce().dfrac,
|
|
437
|
+
new coefficients_1.Fraction(-b + nthDelta.coefficient, 2 * a).reduce().dfrac
|
|
443
438
|
];
|
|
444
439
|
}
|
|
445
440
|
}
|
|
446
441
|
}
|
|
447
442
|
else if (delta === 0) {
|
|
448
|
-
this._solutions = [new
|
|
443
|
+
this._solutions = [new coefficients_1.Fraction(-b, 2 * a).reduce().dfrac];
|
|
449
444
|
}
|
|
450
445
|
else {
|
|
451
446
|
this._solutions = [this._varnothing];
|
|
@@ -500,6 +495,35 @@ class Equation {
|
|
|
500
495
|
return this._solutions;
|
|
501
496
|
};
|
|
502
497
|
}
|
|
498
|
+
exports.Equation = Equation;
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
/***/ }),
|
|
502
|
+
|
|
503
|
+
/***/ "./src/maths/algebra/index.ts":
|
|
504
|
+
/*!************************************!*\
|
|
505
|
+
!*** ./src/maths/algebra/index.ts ***!
|
|
506
|
+
\************************************/
|
|
507
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
511
|
+
if (k2 === undefined) k2 = k;
|
|
512
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
513
|
+
}) : (function(o, m, k, k2) {
|
|
514
|
+
if (k2 === undefined) k2 = k;
|
|
515
|
+
o[k2] = m[k];
|
|
516
|
+
}));
|
|
517
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
518
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
519
|
+
};
|
|
520
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
521
|
+
__exportStar(__webpack_require__(/*! ./equation */ "./src/maths/algebra/equation.ts"), exports);
|
|
522
|
+
__exportStar(__webpack_require__(/*! ./linearSystem */ "./src/maths/algebra/linearSystem.ts"), exports);
|
|
523
|
+
__exportStar(__webpack_require__(/*! ./logicalset */ "./src/maths/algebra/logicalset.ts"), exports);
|
|
524
|
+
__exportStar(__webpack_require__(/*! ./monom */ "./src/maths/algebra/monom.ts"), exports);
|
|
525
|
+
__exportStar(__webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts"), exports);
|
|
526
|
+
__exportStar(__webpack_require__(/*! ./rational */ "./src/maths/algebra/rational.ts"), exports);
|
|
503
527
|
|
|
504
528
|
|
|
505
529
|
/***/ }),
|
|
@@ -508,20 +532,15 @@ class Equation {
|
|
|
508
532
|
/*!*******************************************!*\
|
|
509
533
|
!*** ./src/maths/algebra/linearSystem.ts ***!
|
|
510
534
|
\*******************************************/
|
|
511
|
-
/***/ ((__unused_webpack_module,
|
|
535
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
512
536
|
|
|
513
|
-
__webpack_require__.r(__webpack_exports__);
|
|
514
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
515
|
-
/* harmony export */ "default": () => (/* binding */ LinearSystem)
|
|
516
|
-
/* harmony export */ });
|
|
517
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
518
|
-
/* harmony import */ var _equation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./equation */ "./src/maths/algebra/equation.ts");
|
|
519
|
-
/* harmony import */ var _polynom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
520
|
-
/* harmony import */ var _random_random__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../random/random */ "./src/maths/random/random.ts");
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
537
|
|
|
538
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
539
|
+
exports.LinearSystem = void 0;
|
|
540
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
541
|
+
const equation_1 = __webpack_require__(/*! ./equation */ "./src/maths/algebra/equation.ts");
|
|
542
|
+
const polynom_1 = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
543
|
+
const random_1 = __webpack_require__(/*! ../random */ "./src/maths/random/index.ts");
|
|
525
544
|
class LinearSystem {
|
|
526
545
|
_solutions;
|
|
527
546
|
_resolutionSteps;
|
|
@@ -535,7 +554,7 @@ class LinearSystem {
|
|
|
535
554
|
}
|
|
536
555
|
return this;
|
|
537
556
|
}
|
|
538
|
-
get
|
|
557
|
+
get isLinearSystem() {
|
|
539
558
|
return true;
|
|
540
559
|
}
|
|
541
560
|
get equations() {
|
|
@@ -602,7 +621,7 @@ class LinearSystem {
|
|
|
602
621
|
return `(${tex.join(';')})`;
|
|
603
622
|
}
|
|
604
623
|
parse = (...equations) => {
|
|
605
|
-
this._equations = equations.map(value => new
|
|
624
|
+
this._equations = equations.map(value => new equation_1.Equation(value));
|
|
606
625
|
this._findLetters();
|
|
607
626
|
return this;
|
|
608
627
|
};
|
|
@@ -610,7 +629,7 @@ class LinearSystem {
|
|
|
610
629
|
this._equations = [];
|
|
611
630
|
let i = 0;
|
|
612
631
|
while (i < coefficients.length - this._letters.length) {
|
|
613
|
-
let left = new
|
|
632
|
+
let left = new polynom_1.Polynom().parse(this._letters.join(''), ...coefficients.slice(i, i + this._letters.length)), right = new polynom_1.Polynom(coefficients[i + this._letters.length].toString()), equ = new equation_1.Equation().create(left, right);
|
|
614
633
|
this._equations.push(equ.clone());
|
|
615
634
|
i = i + this._letters.length + 1;
|
|
616
635
|
}
|
|
@@ -635,7 +654,7 @@ class LinearSystem {
|
|
|
635
654
|
let solutionsF = [];
|
|
636
655
|
for (let s of solutions) {
|
|
637
656
|
if (typeof s === "number") {
|
|
638
|
-
solutionsF.push(new
|
|
657
|
+
solutionsF.push(new coefficients_1.Fraction(s.toString()));
|
|
639
658
|
}
|
|
640
659
|
else {
|
|
641
660
|
solutionsF.push(s.clone());
|
|
@@ -648,15 +667,15 @@ class LinearSystem {
|
|
|
648
667
|
return this;
|
|
649
668
|
};
|
|
650
669
|
_generateOneEquation = (...solutions) => {
|
|
651
|
-
let coeff = [], leftValue = new
|
|
670
|
+
let coeff = [], leftValue = new coefficients_1.Fraction().zero(), letters = ['x', 'y', 'z', 't', 'u', 'v', 'w', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'], equString = '', equ;
|
|
652
671
|
for (let i = 0; i < solutions.length; i++) {
|
|
653
|
-
coeff.push(
|
|
672
|
+
coeff.push(random_1.Random.numberSym(5));
|
|
654
673
|
leftValue.add(solutions[i].clone().multiply(coeff[i]));
|
|
655
674
|
equString += `${(coeff[i] < 0) ? coeff[i] : '+' + coeff[i]}${letters[i]}`;
|
|
656
675
|
}
|
|
657
|
-
equ = new
|
|
676
|
+
equ = new equation_1.Equation(`${equString}=${leftValue.display}`);
|
|
658
677
|
if (equ.right.monoms[0].coefficient.denominator != 1) {
|
|
659
|
-
equ.multiply(new
|
|
678
|
+
equ.multiply(new coefficients_1.Fraction(equ.right.monoms[0].coefficient.denominator, 1));
|
|
660
679
|
}
|
|
661
680
|
if (this._checkIfLinerCombination(equ)) {
|
|
662
681
|
return equ;
|
|
@@ -670,7 +689,7 @@ class LinearSystem {
|
|
|
670
689
|
return this.mergeEquations(eq1, eq2, c2, c1);
|
|
671
690
|
}
|
|
672
691
|
mergeEquations = (eq1, eq2, factor1, factor2) => {
|
|
673
|
-
let eq1multiplied = eq1.clone().multiply(new
|
|
692
|
+
let eq1multiplied = eq1.clone().multiply(new coefficients_1.Fraction(factor1)), eq2multiplied = eq2.clone().multiply(new coefficients_1.Fraction(factor2));
|
|
674
693
|
eq1multiplied.left.add(eq2multiplied.left);
|
|
675
694
|
eq1multiplied.right.add(eq2multiplied.right);
|
|
676
695
|
return eq1multiplied;
|
|
@@ -710,7 +729,7 @@ class LinearSystem {
|
|
|
710
729
|
let E = this._resolutionSteps[this._resolutionSteps.length - 1].equations[0];
|
|
711
730
|
E.solve();
|
|
712
731
|
return {
|
|
713
|
-
value: new
|
|
732
|
+
value: new coefficients_1.Fraction(E.solutions[0]),
|
|
714
733
|
isReal: E.isReal,
|
|
715
734
|
isVarnothing: E.isVarnothing
|
|
716
735
|
};
|
|
@@ -724,6 +743,7 @@ class LinearSystem {
|
|
|
724
743
|
return str;
|
|
725
744
|
};
|
|
726
745
|
}
|
|
746
|
+
exports.LinearSystem = LinearSystem;
|
|
727
747
|
|
|
728
748
|
|
|
729
749
|
/***/ }),
|
|
@@ -732,14 +752,12 @@ class LinearSystem {
|
|
|
732
752
|
/*!*****************************************!*\
|
|
733
753
|
!*** ./src/maths/algebra/logicalset.ts ***!
|
|
734
754
|
\*****************************************/
|
|
735
|
-
/***/ ((__unused_webpack_module,
|
|
755
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
736
756
|
|
|
737
|
-
__webpack_require__.r(__webpack_exports__);
|
|
738
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
739
|
-
/* harmony export */ "default": () => (/* binding */ Logicalset)
|
|
740
|
-
/* harmony export */ });
|
|
741
|
-
/* harmony import */ var _shutingyard__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
742
757
|
|
|
758
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
759
|
+
exports.Logicalset = void 0;
|
|
760
|
+
const shutingyard_1 = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
743
761
|
class Logicalset {
|
|
744
762
|
_rawString;
|
|
745
763
|
_rpn;
|
|
@@ -753,7 +771,7 @@ class Logicalset {
|
|
|
753
771
|
}
|
|
754
772
|
;
|
|
755
773
|
parse = (value) => {
|
|
756
|
-
this._rpn = new
|
|
774
|
+
this._rpn = new shutingyard_1.Shutingyard('set').parse(value).rpn;
|
|
757
775
|
return this;
|
|
758
776
|
};
|
|
759
777
|
evaluate(tokenSets, reference) {
|
|
@@ -880,6 +898,7 @@ class Logicalset {
|
|
|
880
898
|
return varStack[0].token;
|
|
881
899
|
}
|
|
882
900
|
}
|
|
901
|
+
exports.Logicalset = Logicalset;
|
|
883
902
|
|
|
884
903
|
|
|
885
904
|
/***/ }),
|
|
@@ -888,16 +907,14 @@ class Logicalset {
|
|
|
888
907
|
/*!************************************!*\
|
|
889
908
|
!*** ./src/maths/algebra/monom.ts ***!
|
|
890
909
|
\************************************/
|
|
891
|
-
/***/ ((__unused_webpack_module,
|
|
910
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
892
911
|
|
|
893
|
-
__webpack_require__.r(__webpack_exports__);
|
|
894
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
895
|
-
/* harmony export */ "default": () => (/* binding */ Monom)
|
|
896
|
-
/* harmony export */ });
|
|
897
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
898
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
899
|
-
|
|
900
912
|
|
|
913
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
914
|
+
exports.Monom = void 0;
|
|
915
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
916
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
917
|
+
const shutingyard_1 = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
901
918
|
class Monom {
|
|
902
919
|
_coefficient;
|
|
903
920
|
_literal;
|
|
@@ -908,9 +925,6 @@ class Monom {
|
|
|
908
925
|
}
|
|
909
926
|
return this;
|
|
910
927
|
}
|
|
911
|
-
get isMonom() {
|
|
912
|
-
return true;
|
|
913
|
-
}
|
|
914
928
|
get coefficient() {
|
|
915
929
|
return this._coefficient;
|
|
916
930
|
}
|
|
@@ -921,10 +935,10 @@ class Monom {
|
|
|
921
935
|
return this._literal;
|
|
922
936
|
}
|
|
923
937
|
get literalSqrt() {
|
|
924
|
-
if (this.
|
|
938
|
+
if (this.isLiteralSquare()) {
|
|
925
939
|
let L = {};
|
|
926
940
|
for (let key in this._literal) {
|
|
927
|
-
L[key] = this._literal[key]
|
|
941
|
+
L[key] = this._literal[key].clone().sqrt();
|
|
928
942
|
}
|
|
929
943
|
return L;
|
|
930
944
|
}
|
|
@@ -938,15 +952,15 @@ class Monom {
|
|
|
938
952
|
set literalStr(inputStr) {
|
|
939
953
|
for (const v of [...inputStr.matchAll(/([a-z])\^([+-]?[0-9]+)/g)]) {
|
|
940
954
|
if (!(v[1] in this._literal)) {
|
|
941
|
-
this._literal[v[1]] =
|
|
955
|
+
this._literal[v[1]] = new coefficients_1.Fraction().zero();
|
|
942
956
|
}
|
|
943
|
-
this._literal[v[1]]
|
|
957
|
+
this._literal[v[1]].add(+v[2]);
|
|
944
958
|
}
|
|
945
959
|
for (const v of [...inputStr.matchAll(/([a-z](?!\^))/g)]) {
|
|
946
960
|
if (!(v[1] in this._literal)) {
|
|
947
|
-
this._literal[v[1]] =
|
|
961
|
+
this._literal[v[1]] = new coefficients_1.Fraction().zero();
|
|
948
962
|
}
|
|
949
|
-
this._literal[v[1]]
|
|
963
|
+
this._literal[v[1]].add(1);
|
|
950
964
|
}
|
|
951
965
|
}
|
|
952
966
|
get variables() {
|
|
@@ -954,12 +968,12 @@ class Monom {
|
|
|
954
968
|
return Object.keys(this._literal);
|
|
955
969
|
}
|
|
956
970
|
get display() {
|
|
957
|
-
let L = '';
|
|
958
|
-
for (let letter
|
|
959
|
-
if (this._literal[letter]
|
|
971
|
+
let L = '', letters = Object.keys(this._literal).sort();
|
|
972
|
+
for (let letter of letters) {
|
|
973
|
+
if (this._literal[letter].isNotZero()) {
|
|
960
974
|
L += `${letter}`;
|
|
961
|
-
if (this._literal[letter]
|
|
962
|
-
L += `^${this._literal[letter]}`;
|
|
975
|
+
if (this._literal[letter].isNotEqual(1)) {
|
|
976
|
+
L += `^${this._literal[letter].display}`;
|
|
963
977
|
}
|
|
964
978
|
}
|
|
965
979
|
}
|
|
@@ -990,29 +1004,32 @@ class Monom {
|
|
|
990
1004
|
if (this.coefficient.denominator !== 1) {
|
|
991
1005
|
return [this.clone()];
|
|
992
1006
|
}
|
|
1007
|
+
if (this.hasFractionCoefficient) {
|
|
1008
|
+
return [this.clone()];
|
|
1009
|
+
}
|
|
993
1010
|
if (this.coefficient.numerator > 10000) {
|
|
994
1011
|
return [this.clone()];
|
|
995
1012
|
}
|
|
996
|
-
const dividers =
|
|
997
|
-
let
|
|
1013
|
+
const dividers = numeric_1.Numeric.dividers(Math.abs(this.coefficient.numerator));
|
|
1014
|
+
let literals = [];
|
|
998
1015
|
for (let L in this.literal) {
|
|
999
|
-
|
|
1016
|
+
literals = this._getLiteralDividers(literals, L);
|
|
1000
1017
|
}
|
|
1001
1018
|
const monomDividers = [];
|
|
1002
|
-
if (
|
|
1019
|
+
if (literals.length > 0 && dividers.length > 0) {
|
|
1003
1020
|
for (let N of dividers) {
|
|
1004
|
-
for (let L of
|
|
1021
|
+
for (let L of literals) {
|
|
1005
1022
|
let M = new Monom();
|
|
1006
|
-
M.coefficient = new
|
|
1023
|
+
M.coefficient = new coefficients_1.Fraction(N);
|
|
1007
1024
|
M.literal = L;
|
|
1008
1025
|
monomDividers.push(M);
|
|
1009
1026
|
}
|
|
1010
1027
|
}
|
|
1011
1028
|
}
|
|
1012
1029
|
else if (dividers.length === 0) {
|
|
1013
|
-
for (let L of
|
|
1030
|
+
for (let L of literals) {
|
|
1014
1031
|
let M = new Monom();
|
|
1015
|
-
M.coefficient = new
|
|
1032
|
+
M.coefficient = new coefficients_1.Fraction().one();
|
|
1016
1033
|
M.literal = L;
|
|
1017
1034
|
monomDividers.push(M);
|
|
1018
1035
|
}
|
|
@@ -1020,18 +1037,18 @@ class Monom {
|
|
|
1020
1037
|
else {
|
|
1021
1038
|
for (let N of dividers) {
|
|
1022
1039
|
let M = new Monom();
|
|
1023
|
-
M.coefficient = new
|
|
1040
|
+
M.coefficient = new coefficients_1.Fraction(N);
|
|
1024
1041
|
monomDividers.push(M);
|
|
1025
1042
|
}
|
|
1026
1043
|
}
|
|
1027
1044
|
return monomDividers.length === 0 ? [new Monom().one()] : monomDividers;
|
|
1028
1045
|
}
|
|
1029
|
-
|
|
1046
|
+
_getLiteralDividers(arr, letter) {
|
|
1030
1047
|
let tmpList = [];
|
|
1031
|
-
for (let d = 0; d <= this.literal[letter]; d++) {
|
|
1048
|
+
for (let d = 0; d <= this.literal[letter].value; d++) {
|
|
1032
1049
|
if (arr.length === 0) {
|
|
1033
1050
|
let litt = {};
|
|
1034
|
-
litt[letter] = d;
|
|
1051
|
+
litt[letter] = new coefficients_1.Fraction(d);
|
|
1035
1052
|
tmpList.push(litt);
|
|
1036
1053
|
}
|
|
1037
1054
|
else {
|
|
@@ -1040,7 +1057,7 @@ class Monom {
|
|
|
1040
1057
|
for (let currentLetter in item) {
|
|
1041
1058
|
litt[currentLetter] = item[currentLetter];
|
|
1042
1059
|
}
|
|
1043
|
-
litt[letter] = d;
|
|
1060
|
+
litt[letter] = new coefficients_1.Fraction(d);
|
|
1044
1061
|
tmpList.push(litt);
|
|
1045
1062
|
}
|
|
1046
1063
|
}
|
|
@@ -1052,12 +1069,12 @@ class Monom {
|
|
|
1052
1069
|
return (d[0] !== '-' ? '+' : '') + d;
|
|
1053
1070
|
}
|
|
1054
1071
|
get tex() {
|
|
1055
|
-
let L = '';
|
|
1056
|
-
for (let letter
|
|
1057
|
-
if (this._literal[letter]
|
|
1072
|
+
let L = '', letters = Object.keys(this._literal).sort();
|
|
1073
|
+
for (let letter of letters) {
|
|
1074
|
+
if (this._literal[letter].isNotZero()) {
|
|
1058
1075
|
L += `${letter}`;
|
|
1059
|
-
if (this._literal[letter]
|
|
1060
|
-
L +=
|
|
1076
|
+
if (this._literal[letter].isNotEqual(1)) {
|
|
1077
|
+
L += `^{${this._literal[letter].display}}`;
|
|
1061
1078
|
}
|
|
1062
1079
|
}
|
|
1063
1080
|
}
|
|
@@ -1085,37 +1102,96 @@ class Monom {
|
|
|
1085
1102
|
}
|
|
1086
1103
|
}
|
|
1087
1104
|
parse = (inputStr) => {
|
|
1088
|
-
this.
|
|
1089
|
-
this
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1105
|
+
this._shutingYardToReducedMonom(inputStr);
|
|
1106
|
+
return this;
|
|
1107
|
+
};
|
|
1108
|
+
_shutingYardToReducedMonom = (inputStr) => {
|
|
1109
|
+
const SY = new shutingyard_1.Shutingyard().parse(inputStr);
|
|
1110
|
+
const rpn = SY.rpn;
|
|
1111
|
+
let stack = [], m, pow, letter, q1, q2;
|
|
1112
|
+
if (rpn.length === 0) {
|
|
1113
|
+
this.zero();
|
|
1114
|
+
return this;
|
|
1115
|
+
}
|
|
1116
|
+
else if (rpn.length === 1) {
|
|
1117
|
+
const element = rpn[0];
|
|
1118
|
+
this.one();
|
|
1119
|
+
if (element.tokenType === 'coefficient') {
|
|
1120
|
+
this.coefficient = new coefficients_1.Fraction(element.token);
|
|
1093
1121
|
}
|
|
1094
|
-
|
|
1122
|
+
else if (element.tokenType === 'variable') {
|
|
1123
|
+
this.setLetter(element.token, 1);
|
|
1124
|
+
}
|
|
1125
|
+
return this;
|
|
1095
1126
|
}
|
|
1127
|
+
else {
|
|
1128
|
+
for (const element of rpn) {
|
|
1129
|
+
if (element.tokenType === 'coefficient') {
|
|
1130
|
+
let M = new Monom().one();
|
|
1131
|
+
M.coefficient = new coefficients_1.Fraction(element.token);
|
|
1132
|
+
stack.push(M.clone());
|
|
1133
|
+
}
|
|
1134
|
+
else if (element.tokenType === 'variable') {
|
|
1135
|
+
let M = new Monom().one();
|
|
1136
|
+
M.setLetter(element.token, 1);
|
|
1137
|
+
stack.push(M.clone());
|
|
1138
|
+
}
|
|
1139
|
+
else if (element.tokenType === 'operation') {
|
|
1140
|
+
switch (element.token) {
|
|
1141
|
+
case '-':
|
|
1142
|
+
q2 = (stack.pop()) || new Monom().zero();
|
|
1143
|
+
q1 = (stack.pop()) || new Monom().zero();
|
|
1144
|
+
stack.push(q1.subtract(q2));
|
|
1145
|
+
break;
|
|
1146
|
+
case '*':
|
|
1147
|
+
q2 = (stack.pop()) || new Monom().one();
|
|
1148
|
+
q1 = (stack.pop()) || new Monom().one();
|
|
1149
|
+
stack.push(q1.multiply(q2));
|
|
1150
|
+
break;
|
|
1151
|
+
case '^':
|
|
1152
|
+
pow = (stack.pop().coefficient) || new coefficients_1.Fraction().one();
|
|
1153
|
+
m = (stack.pop()) || new Monom().one();
|
|
1154
|
+
letter = m.variables[0];
|
|
1155
|
+
if (letter !== undefined) {
|
|
1156
|
+
m.setLetter(letter, pow);
|
|
1157
|
+
}
|
|
1158
|
+
stack.push(m);
|
|
1159
|
+
break;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
this.one();
|
|
1165
|
+
this.multiply(stack[0]);
|
|
1096
1166
|
return this;
|
|
1097
1167
|
};
|
|
1098
1168
|
clone = () => {
|
|
1099
1169
|
let F = new Monom();
|
|
1100
1170
|
F.coefficient = this._coefficient.clone();
|
|
1101
1171
|
for (let k in this._literal) {
|
|
1102
|
-
F.setLetter(k, this._literal[k]);
|
|
1172
|
+
F.setLetter(k, this._literal[k].clone());
|
|
1103
1173
|
}
|
|
1104
1174
|
return F;
|
|
1105
1175
|
};
|
|
1176
|
+
makeSame = (M) => {
|
|
1177
|
+
for (let k in M._literal) {
|
|
1178
|
+
this.setLetter(k, M._literal[k].clone());
|
|
1179
|
+
}
|
|
1180
|
+
return this;
|
|
1181
|
+
};
|
|
1106
1182
|
zero = () => {
|
|
1107
|
-
this._coefficient = new
|
|
1183
|
+
this._coefficient = new coefficients_1.Fraction().zero();
|
|
1108
1184
|
this._literal = {};
|
|
1109
1185
|
return this;
|
|
1110
1186
|
};
|
|
1111
1187
|
one = () => {
|
|
1112
|
-
this._coefficient = new
|
|
1188
|
+
this._coefficient = new coefficients_1.Fraction().one();
|
|
1113
1189
|
this._literal = {};
|
|
1114
1190
|
return this;
|
|
1115
1191
|
};
|
|
1116
1192
|
clean = () => {
|
|
1117
1193
|
for (let letter in this._literal) {
|
|
1118
|
-
if (this._literal[letter]
|
|
1194
|
+
if (this._literal[letter].isZero()) {
|
|
1119
1195
|
delete this._literal[letter];
|
|
1120
1196
|
}
|
|
1121
1197
|
}
|
|
@@ -1128,6 +1204,9 @@ class Monom {
|
|
|
1128
1204
|
add = (...M) => {
|
|
1129
1205
|
for (let m of M) {
|
|
1130
1206
|
if (this.isSameAs(m)) {
|
|
1207
|
+
if (this.isZero()) {
|
|
1208
|
+
this.makeSame(m);
|
|
1209
|
+
}
|
|
1131
1210
|
this._coefficient.add(m.coefficient);
|
|
1132
1211
|
}
|
|
1133
1212
|
else {
|
|
@@ -1139,7 +1218,10 @@ class Monom {
|
|
|
1139
1218
|
subtract = (...M) => {
|
|
1140
1219
|
for (let m of M) {
|
|
1141
1220
|
if (this.isSameAs(m)) {
|
|
1142
|
-
this.
|
|
1221
|
+
if (this.isZero()) {
|
|
1222
|
+
this.makeSame(m);
|
|
1223
|
+
}
|
|
1224
|
+
this._coefficient.add(m.clone().coefficient.opposed());
|
|
1143
1225
|
}
|
|
1144
1226
|
else {
|
|
1145
1227
|
console.log('Subtract: Is not similar: ', m.display);
|
|
@@ -1151,7 +1233,12 @@ class Monom {
|
|
|
1151
1233
|
for (let m of M) {
|
|
1152
1234
|
this._coefficient.multiply(m.coefficient);
|
|
1153
1235
|
for (let letter in m.literal) {
|
|
1154
|
-
|
|
1236
|
+
if (this._literal[letter] === undefined) {
|
|
1237
|
+
this._literal[letter] = m.literal[letter].clone();
|
|
1238
|
+
}
|
|
1239
|
+
else {
|
|
1240
|
+
this._literal[letter].add(m.literal[letter]);
|
|
1241
|
+
}
|
|
1155
1242
|
}
|
|
1156
1243
|
}
|
|
1157
1244
|
return this;
|
|
@@ -1164,8 +1251,8 @@ class Monom {
|
|
|
1164
1251
|
for (let v of M) {
|
|
1165
1252
|
this._coefficient.divide(v.coefficient);
|
|
1166
1253
|
for (let letter in v.literal) {
|
|
1167
|
-
this._literal[letter] = (this._literal[letter] === undefined) ?
|
|
1168
|
-
if (this._literal[letter]
|
|
1254
|
+
this._literal[letter] = (this._literal[letter] === undefined) ? v.literal[letter].clone().opposed() : this._literal[letter].subtract(v.literal[letter]);
|
|
1255
|
+
if (this._literal[letter].isZero()) {
|
|
1169
1256
|
delete this._literal[letter];
|
|
1170
1257
|
}
|
|
1171
1258
|
}
|
|
@@ -1175,7 +1262,7 @@ class Monom {
|
|
|
1175
1262
|
pow = (nb) => {
|
|
1176
1263
|
this._coefficient.pow(nb);
|
|
1177
1264
|
for (let letter in this._literal) {
|
|
1178
|
-
this._literal[letter]
|
|
1265
|
+
this._literal[letter].pow(nb);
|
|
1179
1266
|
}
|
|
1180
1267
|
return this;
|
|
1181
1268
|
};
|
|
@@ -1186,7 +1273,7 @@ class Monom {
|
|
|
1186
1273
|
if (this.isSquare()) {
|
|
1187
1274
|
this._coefficient.sqrt();
|
|
1188
1275
|
for (let letter in this._literal) {
|
|
1189
|
-
this._literal[letter]
|
|
1276
|
+
this._literal[letter].clone().divide(2);
|
|
1190
1277
|
}
|
|
1191
1278
|
}
|
|
1192
1279
|
return this.root(2);
|
|
@@ -1203,12 +1290,14 @@ class Monom {
|
|
|
1203
1290
|
return this._coefficient.isEqual(M.coefficient);
|
|
1204
1291
|
case 'same':
|
|
1205
1292
|
let M1 = this.variables, M2 = M.variables, K = M1.concat(M2.filter((item) => M1.indexOf(item) < 0));
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1293
|
+
if (!this.isZero() && !M.isZero()) {
|
|
1294
|
+
for (let key of K) {
|
|
1295
|
+
if (this._literal[key] === undefined || M.literal[key] === undefined) {
|
|
1296
|
+
return false;
|
|
1297
|
+
}
|
|
1298
|
+
if (!this._literal[key].isEqual(M.literal[key])) {
|
|
1299
|
+
return false;
|
|
1300
|
+
}
|
|
1212
1301
|
}
|
|
1213
1302
|
}
|
|
1214
1303
|
return true;
|
|
@@ -1232,53 +1321,68 @@ class Monom {
|
|
|
1232
1321
|
if (!this.coefficient.isSquare()) {
|
|
1233
1322
|
return false;
|
|
1234
1323
|
}
|
|
1235
|
-
return this.
|
|
1324
|
+
return this.isLiteralSquare();
|
|
1236
1325
|
};
|
|
1237
|
-
|
|
1326
|
+
isLiteralSquare = () => {
|
|
1238
1327
|
for (let letter in this.literal) {
|
|
1239
|
-
if (this.literal[letter]
|
|
1328
|
+
if (this.literal[letter].isRational()) {
|
|
1329
|
+
return false;
|
|
1330
|
+
}
|
|
1331
|
+
if (this.literal[letter].isEven()) {
|
|
1240
1332
|
return false;
|
|
1241
1333
|
}
|
|
1242
1334
|
}
|
|
1243
1335
|
return true;
|
|
1244
1336
|
};
|
|
1337
|
+
hasFractionCoefficient = () => {
|
|
1338
|
+
for (let letter in this._literal) {
|
|
1339
|
+
if (this._literal[letter].isRational()) {
|
|
1340
|
+
return true;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
return false;
|
|
1344
|
+
};
|
|
1245
1345
|
hasLetter = (letter) => {
|
|
1246
|
-
|
|
1346
|
+
if (this._literal[letter === undefined ? 'x' : letter] === undefined) {
|
|
1347
|
+
return false;
|
|
1348
|
+
}
|
|
1349
|
+
return this._literal[letter === undefined ? 'x' : letter].isNotZero();
|
|
1247
1350
|
};
|
|
1248
1351
|
setLetter = (letter, pow) => {
|
|
1249
|
-
if (pow
|
|
1250
|
-
if (this.
|
|
1352
|
+
if (pow instanceof coefficients_1.Fraction) {
|
|
1353
|
+
if (this.hasLetter(letter) && pow.isZero()) {
|
|
1251
1354
|
delete this._literal[letter];
|
|
1252
1355
|
}
|
|
1356
|
+
this._literal[letter] = pow.clone();
|
|
1253
1357
|
}
|
|
1254
1358
|
else {
|
|
1255
|
-
this.
|
|
1359
|
+
this.setLetter(letter, new coefficients_1.Fraction(pow));
|
|
1256
1360
|
}
|
|
1257
1361
|
};
|
|
1258
1362
|
degree = (letter) => {
|
|
1259
1363
|
if (this.variables.length === 0) {
|
|
1260
|
-
return
|
|
1364
|
+
return new coefficients_1.Fraction().zero();
|
|
1261
1365
|
}
|
|
1262
1366
|
if (letter === undefined) {
|
|
1263
|
-
return Object.values(this._literal).reduce((t, n) => t
|
|
1367
|
+
return Object.values(this._literal).reduce((t, n) => t.clone().add(n));
|
|
1264
1368
|
}
|
|
1265
1369
|
else {
|
|
1266
|
-
return this._literal[letter] === undefined ?
|
|
1370
|
+
return this._literal[letter] === undefined ? new coefficients_1.Fraction().zero() : this._literal[letter].clone();
|
|
1267
1371
|
}
|
|
1268
1372
|
};
|
|
1269
1373
|
evaluate = (values) => {
|
|
1270
1374
|
let r = this.coefficient.clone();
|
|
1271
|
-
if (typeof values === 'number' || values instanceof
|
|
1375
|
+
if (typeof values === 'number' || values instanceof coefficients_1.Fraction) {
|
|
1272
1376
|
let tmpValues = {};
|
|
1273
|
-
tmpValues[this.variables[0]] = new
|
|
1377
|
+
tmpValues[this.variables[0]] = new coefficients_1.Fraction(values);
|
|
1274
1378
|
return this.evaluate(tmpValues);
|
|
1275
1379
|
}
|
|
1276
1380
|
if (typeof values === 'object') {
|
|
1277
1381
|
for (let L in this._literal) {
|
|
1278
1382
|
if (values[L] === undefined) {
|
|
1279
|
-
return new
|
|
1383
|
+
return new coefficients_1.Fraction().zero();
|
|
1280
1384
|
}
|
|
1281
|
-
let value = new
|
|
1385
|
+
let value = new coefficients_1.Fraction(values[L]);
|
|
1282
1386
|
r.multiply(value.pow(this._literal[L]));
|
|
1283
1387
|
}
|
|
1284
1388
|
}
|
|
@@ -1289,9 +1393,9 @@ class Monom {
|
|
|
1289
1393
|
letter = 'x';
|
|
1290
1394
|
}
|
|
1291
1395
|
if (this.hasLetter(letter)) {
|
|
1292
|
-
let d =
|
|
1293
|
-
dM._literal[letter]
|
|
1294
|
-
dM._coefficient.multiply(new
|
|
1396
|
+
let d = this._literal[letter].clone(), dM = this.clone();
|
|
1397
|
+
dM._literal[letter].subtract(1);
|
|
1398
|
+
dM._coefficient.multiply(new coefficients_1.Fraction(d.clone()));
|
|
1295
1399
|
return dM;
|
|
1296
1400
|
}
|
|
1297
1401
|
else {
|
|
@@ -1302,34 +1406,40 @@ class Monom {
|
|
|
1302
1406
|
if (letter === undefined) {
|
|
1303
1407
|
letter = 'x';
|
|
1304
1408
|
}
|
|
1305
|
-
let M = this.clone();
|
|
1409
|
+
let M = this.clone(), degree;
|
|
1306
1410
|
if (M.hasLetter(letter)) {
|
|
1307
|
-
|
|
1308
|
-
M.
|
|
1411
|
+
degree = M.degree(letter).clone().add(1);
|
|
1412
|
+
M.coefficient = M.coefficient.clone().divide(degree);
|
|
1413
|
+
M.setLetter(letter, degree);
|
|
1309
1414
|
}
|
|
1310
1415
|
else {
|
|
1311
1416
|
if (M.coefficient.isZero()) {
|
|
1312
|
-
M.coefficient = new
|
|
1417
|
+
M.coefficient = new coefficients_1.Fraction().one();
|
|
1313
1418
|
}
|
|
1314
1419
|
M.setLetter(letter, 1);
|
|
1315
1420
|
}
|
|
1316
1421
|
return M;
|
|
1317
1422
|
};
|
|
1318
1423
|
static lcm = (...monoms) => {
|
|
1319
|
-
|
|
1320
|
-
|
|
1424
|
+
for (let m of monoms) {
|
|
1425
|
+
if (m.hasFractionCoefficient()) {
|
|
1426
|
+
return new Monom().zero();
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
let M = new Monom(), coeffN = monoms.map(value => value.coefficient.numerator), coeffD = monoms.map(value => value.coefficient.denominator), n = numeric_1.Numeric.gcd(...coeffN), d = numeric_1.Numeric.lcm(...coeffD);
|
|
1430
|
+
M.coefficient = new coefficients_1.Fraction(n, d).reduce();
|
|
1321
1431
|
for (let m of monoms) {
|
|
1322
1432
|
for (let letter in M.literal) {
|
|
1323
1433
|
if (!(letter in m.literal)) {
|
|
1324
|
-
M.literal[letter]
|
|
1434
|
+
M.literal[letter].zero();
|
|
1325
1435
|
}
|
|
1326
1436
|
}
|
|
1327
1437
|
for (let letter in m.literal) {
|
|
1328
|
-
if (M.literal[letter] === undefined && m.literal[letter]
|
|
1329
|
-
M.literal[letter] = m.literal[letter];
|
|
1438
|
+
if (M.literal[letter] === undefined && m.literal[letter].isStrictlyPositive()) {
|
|
1439
|
+
M.literal[letter] = m.literal[letter].clone();
|
|
1330
1440
|
}
|
|
1331
1441
|
else {
|
|
1332
|
-
M.literal[letter] = Math.min(m.literal[letter], M.literal[letter]);
|
|
1442
|
+
M.literal[letter] = new coefficients_1.Fraction(Math.min(m.literal[letter].value, M.literal[letter].value));
|
|
1333
1443
|
}
|
|
1334
1444
|
}
|
|
1335
1445
|
}
|
|
@@ -1363,6 +1473,7 @@ class Monom {
|
|
|
1363
1473
|
return true;
|
|
1364
1474
|
};
|
|
1365
1475
|
}
|
|
1476
|
+
exports.Monom = Monom;
|
|
1366
1477
|
|
|
1367
1478
|
|
|
1368
1479
|
/***/ }),
|
|
@@ -1371,22 +1482,15 @@ class Monom {
|
|
|
1371
1482
|
/*!**************************************!*\
|
|
1372
1483
|
!*** ./src/maths/algebra/polynom.ts ***!
|
|
1373
1484
|
\**************************************/
|
|
1374
|
-
/***/ ((__unused_webpack_module,
|
|
1485
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1375
1486
|
|
|
1376
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1377
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1378
|
-
/* harmony export */ "default": () => (/* binding */ Polynom)
|
|
1379
|
-
/* harmony export */ });
|
|
1380
|
-
/* harmony import */ var _monom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./monom */ "./src/maths/algebra/monom.ts");
|
|
1381
|
-
/* harmony import */ var _shutingyard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
1382
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
1383
|
-
/* harmony import */ var _random_random__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../random/random */ "./src/maths/random/random.ts");
|
|
1384
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
1487
|
|
|
1488
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1489
|
+
exports.Polynom = void 0;
|
|
1490
|
+
const monom_1 = __webpack_require__(/*! ./monom */ "./src/maths/algebra/monom.ts");
|
|
1491
|
+
const shutingyard_1 = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
1492
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
1493
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
1390
1494
|
class Polynom {
|
|
1391
1495
|
_rawString;
|
|
1392
1496
|
_monoms;
|
|
@@ -1400,10 +1504,6 @@ class Polynom {
|
|
|
1400
1504
|
}
|
|
1401
1505
|
return this;
|
|
1402
1506
|
}
|
|
1403
|
-
get isPolynom() {
|
|
1404
|
-
return true;
|
|
1405
|
-
}
|
|
1406
|
-
;
|
|
1407
1507
|
get monoms() {
|
|
1408
1508
|
return this._monoms;
|
|
1409
1509
|
}
|
|
@@ -1491,9 +1591,7 @@ class Polynom {
|
|
|
1491
1591
|
this._rawString = inputStr;
|
|
1492
1592
|
if (inputStr !== '' && !isNaN(Number(inputStr))) {
|
|
1493
1593
|
this.empty();
|
|
1494
|
-
let m = new
|
|
1495
|
-
m.coefficient = new _coefficients_fraction__WEBPACK_IMPORTED_MODULE_4__["default"](inputStr);
|
|
1496
|
-
m.literalStr = '';
|
|
1594
|
+
let m = new monom_1.Monom(inputStr);
|
|
1497
1595
|
this.add(m);
|
|
1498
1596
|
return this;
|
|
1499
1597
|
}
|
|
@@ -1501,11 +1599,11 @@ class Polynom {
|
|
|
1501
1599
|
}
|
|
1502
1600
|
else if (/^[a-z]/.test(inputStr)) {
|
|
1503
1601
|
this.empty();
|
|
1504
|
-
let fractions = values.map(x => new
|
|
1602
|
+
let fractions = values.map(x => new coefficients_1.Fraction(x));
|
|
1505
1603
|
if (inputStr.length > 1) {
|
|
1506
1604
|
let letters = inputStr.split(''), i = 0;
|
|
1507
1605
|
for (let F of fractions) {
|
|
1508
|
-
let m = new
|
|
1606
|
+
let m = new monom_1.Monom();
|
|
1509
1607
|
m.coefficient = F.clone();
|
|
1510
1608
|
m.literalStr = letters[i] || '';
|
|
1511
1609
|
this.add(m);
|
|
@@ -1515,7 +1613,7 @@ class Polynom {
|
|
|
1515
1613
|
else {
|
|
1516
1614
|
let n = fractions.length - 1;
|
|
1517
1615
|
for (let F of fractions) {
|
|
1518
|
-
let m = new
|
|
1616
|
+
let m = new monom_1.Monom();
|
|
1519
1617
|
m.coefficient = F.clone();
|
|
1520
1618
|
m.literalStr = `${inputStr}^${n}`;
|
|
1521
1619
|
this.add(m);
|
|
@@ -1529,7 +1627,7 @@ class Polynom {
|
|
|
1529
1627
|
}
|
|
1530
1628
|
};
|
|
1531
1629
|
shutingYardToReducedPolynom = (inputStr) => {
|
|
1532
|
-
const SY = new
|
|
1630
|
+
const SY = new shutingyard_1.Shutingyard().parse(inputStr);
|
|
1533
1631
|
const rpn = SY.rpn;
|
|
1534
1632
|
let m1;
|
|
1535
1633
|
let m2;
|
|
@@ -1537,7 +1635,7 @@ class Polynom {
|
|
|
1537
1635
|
for (const element of rpn) {
|
|
1538
1636
|
if (element.tokenType === 'coefficient' || element.tokenType === 'variable') {
|
|
1539
1637
|
tempPolynom = new Polynom().zero();
|
|
1540
|
-
tempPolynom.monoms = [new
|
|
1638
|
+
tempPolynom.monoms = [new monom_1.Monom(element.token)];
|
|
1541
1639
|
stack.push(tempPolynom.clone());
|
|
1542
1640
|
}
|
|
1543
1641
|
else if (element.tokenType === 'operation') {
|
|
@@ -1573,13 +1671,13 @@ class Polynom {
|
|
|
1573
1671
|
};
|
|
1574
1672
|
zero = () => {
|
|
1575
1673
|
this._monoms = [];
|
|
1576
|
-
this._monoms.push(new
|
|
1674
|
+
this._monoms.push(new monom_1.Monom().zero());
|
|
1577
1675
|
this._rawString = '0';
|
|
1578
1676
|
return this;
|
|
1579
1677
|
};
|
|
1580
1678
|
one = () => {
|
|
1581
1679
|
this._monoms = [];
|
|
1582
|
-
this._monoms.push(new
|
|
1680
|
+
this._monoms.push(new monom_1.Monom().one());
|
|
1583
1681
|
this._rawString = '1';
|
|
1584
1682
|
return this;
|
|
1585
1683
|
};
|
|
@@ -1588,96 +1686,52 @@ class Polynom {
|
|
|
1588
1686
|
this._rawString = '';
|
|
1589
1687
|
return this;
|
|
1590
1688
|
};
|
|
1591
|
-
_randomizeDefaults = {
|
|
1592
|
-
degree: 2,
|
|
1593
|
-
unit: true,
|
|
1594
|
-
fractions: false,
|
|
1595
|
-
factorable: false,
|
|
1596
|
-
letters: 'x',
|
|
1597
|
-
allowNullMonom: false,
|
|
1598
|
-
numberOfMonoms: false
|
|
1599
|
-
};
|
|
1600
|
-
get randomizeDefaults() {
|
|
1601
|
-
return this._randomizeDefaults;
|
|
1602
|
-
}
|
|
1603
|
-
set randomizeDefaults(value) {
|
|
1604
|
-
this._randomizeDefaults = value;
|
|
1605
|
-
}
|
|
1606
|
-
randomize = (config) => {
|
|
1607
|
-
let P = new Polynom();
|
|
1608
|
-
if (config === undefined) {
|
|
1609
|
-
config = {};
|
|
1610
|
-
}
|
|
1611
|
-
for (let k in this._randomizeDefaults) {
|
|
1612
|
-
if (config[k] === undefined) {
|
|
1613
|
-
config[k] = this._randomizeDefaults[k];
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
return P;
|
|
1617
|
-
};
|
|
1618
|
-
rndFactorable = (degree = 2, unit = false, letters = 'x') => {
|
|
1619
|
-
this._factors = [];
|
|
1620
|
-
for (let i = 0; i < degree; i++) {
|
|
1621
|
-
let factorUnit = unit === true || i >= unit, p = _random_random__WEBPACK_IMPORTED_MODULE_3__.Random.polynom({
|
|
1622
|
-
degree: 1,
|
|
1623
|
-
unit: factorUnit,
|
|
1624
|
-
fraction: false,
|
|
1625
|
-
letters
|
|
1626
|
-
});
|
|
1627
|
-
this._factors.push(p);
|
|
1628
|
-
}
|
|
1629
|
-
this.empty().monoms = this._factors[0].monoms;
|
|
1630
|
-
for (let i = 1; i < this._factors.length; i++) {
|
|
1631
|
-
this.multiply(this._factors[i]);
|
|
1632
|
-
}
|
|
1633
|
-
return this;
|
|
1634
|
-
};
|
|
1635
1689
|
opposed = () => {
|
|
1636
1690
|
this._monoms = this._monoms.map(m => m.opposed());
|
|
1637
1691
|
return this;
|
|
1638
1692
|
};
|
|
1639
1693
|
add = (...values) => {
|
|
1640
1694
|
for (let value of values) {
|
|
1641
|
-
if (value
|
|
1695
|
+
if (value instanceof Polynom) {
|
|
1642
1696
|
this._monoms = this._monoms.concat(value.monoms);
|
|
1643
1697
|
}
|
|
1644
|
-
else if (value.
|
|
1698
|
+
else if (value instanceof monom_1.Monom) {
|
|
1645
1699
|
this._monoms.push(value.clone());
|
|
1646
1700
|
}
|
|
1647
1701
|
else if (Number.isSafeInteger(value)) {
|
|
1648
|
-
this._monoms.push(new
|
|
1702
|
+
this._monoms.push(new monom_1.Monom(value.toString()));
|
|
1649
1703
|
}
|
|
1650
1704
|
else {
|
|
1651
|
-
this._monoms.push(new
|
|
1705
|
+
this._monoms.push(new monom_1.Monom(value));
|
|
1652
1706
|
}
|
|
1653
1707
|
}
|
|
1654
1708
|
return this.reduce();
|
|
1655
1709
|
};
|
|
1656
1710
|
subtract = (...values) => {
|
|
1657
1711
|
for (let value of values) {
|
|
1658
|
-
if (value
|
|
1712
|
+
if (value instanceof Polynom) {
|
|
1659
1713
|
this._monoms = this._monoms.concat(value.clone().opposed().monoms);
|
|
1660
1714
|
}
|
|
1661
|
-
else if (value.
|
|
1715
|
+
else if (value instanceof monom_1.Monom) {
|
|
1662
1716
|
this._monoms.push(value.clone().opposed());
|
|
1663
1717
|
}
|
|
1664
1718
|
else if (Number.isSafeInteger(value)) {
|
|
1665
|
-
this._monoms.push(new
|
|
1719
|
+
this._monoms.push(new monom_1.Monom(value.toString()).opposed());
|
|
1666
1720
|
}
|
|
1667
1721
|
else {
|
|
1668
|
-
this._monoms.push(new
|
|
1722
|
+
this._monoms.push(new monom_1.Monom(value).opposed());
|
|
1669
1723
|
}
|
|
1670
1724
|
}
|
|
1671
1725
|
return this.reduce();
|
|
1672
1726
|
};
|
|
1673
1727
|
multiply = (value) => {
|
|
1674
|
-
if (value
|
|
1728
|
+
if (value instanceof Polynom) {
|
|
1675
1729
|
return this.multiplyByPolynom(value);
|
|
1676
1730
|
}
|
|
1677
|
-
else if (value.
|
|
1731
|
+
else if (value instanceof coefficients_1.Fraction) {
|
|
1678
1732
|
return this.multiplyByFraction(value);
|
|
1679
1733
|
}
|
|
1680
|
-
else if (value.
|
|
1734
|
+
else if (value instanceof monom_1.Monom) {
|
|
1681
1735
|
return this.multiplyByMonom(value);
|
|
1682
1736
|
}
|
|
1683
1737
|
else if (Number.isSafeInteger(value)) {
|
|
@@ -1689,7 +1743,7 @@ class Polynom {
|
|
|
1689
1743
|
const M = [];
|
|
1690
1744
|
for (const m1 of this._monoms) {
|
|
1691
1745
|
for (const m2 of P.monoms) {
|
|
1692
|
-
M.push(
|
|
1746
|
+
M.push(monom_1.Monom.xmultiply(m1, m2));
|
|
1693
1747
|
}
|
|
1694
1748
|
}
|
|
1695
1749
|
this._monoms = M;
|
|
@@ -1702,7 +1756,7 @@ class Polynom {
|
|
|
1702
1756
|
return this.reduce();
|
|
1703
1757
|
};
|
|
1704
1758
|
multiplyByInteger = (nb) => {
|
|
1705
|
-
return this.multiplyByFraction(new
|
|
1759
|
+
return this.multiplyByFraction(new coefficients_1.Fraction(nb));
|
|
1706
1760
|
};
|
|
1707
1761
|
multiplyByMonom = (M) => {
|
|
1708
1762
|
for (const m of this._monoms) {
|
|
@@ -1720,9 +1774,9 @@ class Polynom {
|
|
|
1720
1774
|
const maxMP = P.monomByDegree(undefined, letter);
|
|
1721
1775
|
const degreeP = P.degree(letter);
|
|
1722
1776
|
let newM;
|
|
1723
|
-
let MaxIteration = this.degree(letter)
|
|
1724
|
-
while (reminder.degree(letter) >= degreeP && MaxIteration
|
|
1725
|
-
MaxIteration
|
|
1777
|
+
let MaxIteration = this.degree(letter).clone().multiply(2);
|
|
1778
|
+
while (reminder.degree(letter) >= degreeP && MaxIteration.isPositive()) {
|
|
1779
|
+
MaxIteration.subtract(1);
|
|
1726
1780
|
newM = reminder.monomByDegree(undefined, letter).clone().divide(maxMP);
|
|
1727
1781
|
if (newM.isZero()) {
|
|
1728
1782
|
break;
|
|
@@ -1741,7 +1795,7 @@ class Polynom {
|
|
|
1741
1795
|
}
|
|
1742
1796
|
};
|
|
1743
1797
|
divideByInteger = (nb) => {
|
|
1744
|
-
const nbF = new
|
|
1798
|
+
const nbF = new coefficients_1.Fraction(nb);
|
|
1745
1799
|
for (const m of this._monoms) {
|
|
1746
1800
|
m.coefficient.divide(nbF);
|
|
1747
1801
|
}
|
|
@@ -1777,7 +1831,7 @@ class Polynom {
|
|
|
1777
1831
|
const cP2 = P.clone().reduce().reorder();
|
|
1778
1832
|
switch (sign) {
|
|
1779
1833
|
case '=':
|
|
1780
|
-
if (cP1.length !== cP2.length || cP1.degree()
|
|
1834
|
+
if (cP1.length !== cP2.length || cP1.degree().isNotEqual(cP2.degree())) {
|
|
1781
1835
|
return false;
|
|
1782
1836
|
}
|
|
1783
1837
|
for (const i in cP1.monoms) {
|
|
@@ -1901,14 +1955,14 @@ class Polynom {
|
|
|
1901
1955
|
};
|
|
1902
1956
|
reorder = (letter = 'x') => {
|
|
1903
1957
|
this._monoms.sort(function (a, b) {
|
|
1904
|
-
return b.degree(letter)
|
|
1958
|
+
return b.degree(letter).clone().subtract(a.degree(letter)).value;
|
|
1905
1959
|
});
|
|
1906
1960
|
return this.reduce();
|
|
1907
1961
|
};
|
|
1908
1962
|
degree = (letter) => {
|
|
1909
|
-
let d =
|
|
1963
|
+
let d = new coefficients_1.Fraction().zero();
|
|
1910
1964
|
for (const m of this._monoms) {
|
|
1911
|
-
d =
|
|
1965
|
+
d = coefficients_1.Fraction.max(m.degree(letter).value, d);
|
|
1912
1966
|
}
|
|
1913
1967
|
return d;
|
|
1914
1968
|
};
|
|
@@ -1923,7 +1977,7 @@ class Polynom {
|
|
|
1923
1977
|
let pow;
|
|
1924
1978
|
const resultPolynom = new Polynom().zero();
|
|
1925
1979
|
for (const m of this.monoms) {
|
|
1926
|
-
if (m.literal[letter] === undefined || m.literal[letter]
|
|
1980
|
+
if (m.literal[letter] === undefined || m.literal[letter].isZero()) {
|
|
1927
1981
|
resultPolynom.add(m.clone());
|
|
1928
1982
|
}
|
|
1929
1983
|
else {
|
|
@@ -1936,7 +1990,7 @@ class Polynom {
|
|
|
1936
1990
|
return this;
|
|
1937
1991
|
};
|
|
1938
1992
|
evaluate = (values) => {
|
|
1939
|
-
const r = new
|
|
1993
|
+
const r = new coefficients_1.Fraction().zero();
|
|
1940
1994
|
this._monoms.forEach(monom => {
|
|
1941
1995
|
r.add(monom.evaluate(values));
|
|
1942
1996
|
});
|
|
@@ -1962,59 +2016,10 @@ class Polynom {
|
|
|
1962
2016
|
letter = 'x';
|
|
1963
2017
|
}
|
|
1964
2018
|
let valuesA = {}, valuesB = {};
|
|
1965
|
-
valuesA[letter] = a;
|
|
1966
|
-
valuesB[letter] = b;
|
|
2019
|
+
valuesA[letter] = new coefficients_1.Fraction(a);
|
|
2020
|
+
valuesB[letter] = new coefficients_1.Fraction(b);
|
|
1967
2021
|
return primitive.evaluate(valuesB).subtract(primitive.evaluate(valuesA));
|
|
1968
2022
|
};
|
|
1969
|
-
factorize_OLD = (maxValue) => {
|
|
1970
|
-
this._factors = [];
|
|
1971
|
-
let P = this.clone(), nbFactorsFound = 0;
|
|
1972
|
-
if (P.monomByDegree().coefficient.numerator < 0) {
|
|
1973
|
-
this._factors.push(new Polynom('-1'));
|
|
1974
|
-
}
|
|
1975
|
-
let M = P.commonMonom();
|
|
1976
|
-
if (!M.isOne()) {
|
|
1977
|
-
let commonPolynom = new Polynom();
|
|
1978
|
-
commonPolynom.monoms = [M];
|
|
1979
|
-
if (this._factors.length === 0) {
|
|
1980
|
-
this._factors.push(commonPolynom);
|
|
1981
|
-
}
|
|
1982
|
-
else {
|
|
1983
|
-
this._factors = [];
|
|
1984
|
-
this._factors.push(commonPolynom.opposed());
|
|
1985
|
-
}
|
|
1986
|
-
P = P.euclidian(commonPolynom).quotient;
|
|
1987
|
-
nbFactorsFound = commonPolynom.degree();
|
|
1988
|
-
}
|
|
1989
|
-
if (P.degree() <= 1) {
|
|
1990
|
-
this._factors.push(P.clone());
|
|
1991
|
-
}
|
|
1992
|
-
else {
|
|
1993
|
-
let Q = new _coefficients_fraction__WEBPACK_IMPORTED_MODULE_4__["default"](), F, degree = P.degree();
|
|
1994
|
-
maxValue = maxValue === undefined ? 20 : maxValue;
|
|
1995
|
-
for (let a = 1; a <= maxValue; a++) {
|
|
1996
|
-
for (let b = -maxValue; b <= maxValue; b++) {
|
|
1997
|
-
Q.parse(-b, a);
|
|
1998
|
-
if (P.evaluate({ x: Q })) {
|
|
1999
|
-
F = new Polynom(`${a}x+${b}`);
|
|
2000
|
-
while (P.evaluate({ x: Q }).value === 0) {
|
|
2001
|
-
this._factors.push(F.clone());
|
|
2002
|
-
nbFactorsFound++;
|
|
2003
|
-
P = P.euclidian(F).quotient;
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
if (nbFactorsFound > degree) {
|
|
2007
|
-
return this;
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
if (P.degree() > 1) {
|
|
2012
|
-
this._factors.push(P.clone());
|
|
2013
|
-
return this;
|
|
2014
|
-
}
|
|
2015
|
-
}
|
|
2016
|
-
return this;
|
|
2017
|
-
};
|
|
2018
2023
|
factorize = (letter) => {
|
|
2019
2024
|
let factors = [];
|
|
2020
2025
|
let P = this.clone().reorder(), M = P.commonMonom(), tempPolynom;
|
|
@@ -2024,7 +2029,7 @@ class Polynom {
|
|
|
2024
2029
|
factors = [tempPolynom.clone()];
|
|
2025
2030
|
P = P.euclidian(tempPolynom).quotient;
|
|
2026
2031
|
}
|
|
2027
|
-
let securityLoop = P.degree()
|
|
2032
|
+
let securityLoop = P.degree().clone().multiply(2).value;
|
|
2028
2033
|
while (securityLoop >= 0) {
|
|
2029
2034
|
securityLoop--;
|
|
2030
2035
|
if (P.monoms.length < 2) {
|
|
@@ -2107,14 +2112,14 @@ class Polynom {
|
|
|
2107
2112
|
a = this.monomByDegree(2, letter);
|
|
2108
2113
|
b = this.monomByDegree(1, letter);
|
|
2109
2114
|
c = this.monomByDegree(0, letter);
|
|
2110
|
-
if (a.
|
|
2115
|
+
if (a.isLiteralSquare() && c.isLiteralSquare()) {
|
|
2111
2116
|
if (b.clone().pow(2).isSameAs(a.clone().multiply(c))) {
|
|
2112
2117
|
let xPolynom = new Polynom('x', a.coefficient, b.coefficient, c.coefficient);
|
|
2113
2118
|
let xFactors = xPolynom._factorize2ndDegree('x');
|
|
2114
2119
|
let factors = [], xyzPolynom;
|
|
2115
2120
|
if (xFactors.length >= 2) {
|
|
2116
2121
|
for (let p of xFactors) {
|
|
2117
|
-
if (p.degree()
|
|
2122
|
+
if (p.degree().isZero()) {
|
|
2118
2123
|
factors.push(p.clone());
|
|
2119
2124
|
}
|
|
2120
2125
|
else {
|
|
@@ -2136,7 +2141,7 @@ class Polynom {
|
|
|
2136
2141
|
};
|
|
2137
2142
|
getZeroes = () => {
|
|
2138
2143
|
const Z = [];
|
|
2139
|
-
switch (this.degree()) {
|
|
2144
|
+
switch (this.degree().value) {
|
|
2140
2145
|
case 0:
|
|
2141
2146
|
if (this._monoms[0].coefficient.value === 0) {
|
|
2142
2147
|
return [true];
|
|
@@ -2146,7 +2151,7 @@ class Polynom {
|
|
|
2146
2151
|
}
|
|
2147
2152
|
case 1:
|
|
2148
2153
|
if (this._monoms.length === 1) {
|
|
2149
|
-
return [new
|
|
2154
|
+
return [new coefficients_1.Fraction().zero()];
|
|
2150
2155
|
}
|
|
2151
2156
|
else {
|
|
2152
2157
|
const P = this.clone().reduce().reorder();
|
|
@@ -2158,14 +2163,14 @@ class Polynom {
|
|
|
2158
2163
|
}
|
|
2159
2164
|
let zeroes = [], zeroesAsTex = [];
|
|
2160
2165
|
for (let P of this._factors) {
|
|
2161
|
-
if (P.degree()
|
|
2166
|
+
if (P.degree().greater(2)) {
|
|
2162
2167
|
}
|
|
2163
|
-
else if (P.degree() === 2) {
|
|
2168
|
+
else if (P.degree().value === 2) {
|
|
2164
2169
|
let A = P.monomByDegree(2).coefficient, B = P.monomByDegree(1).coefficient, C = P.monomByDegree(0).coefficient, D = B.clone().pow(2).subtract(A.clone().multiply(C).multiply(4));
|
|
2165
2170
|
if (D.value > 0) {
|
|
2166
2171
|
let x1 = (-(B.value) + Math.sqrt(D.value)) / (2 * A.value), x2 = (-(B.value) - Math.sqrt(D.value)) / (2 * A.value);
|
|
2167
|
-
zeroes.push(new
|
|
2168
|
-
zeroes.push(new
|
|
2172
|
+
zeroes.push(new coefficients_1.Fraction(x1.toFixed(3)).reduce());
|
|
2173
|
+
zeroes.push(new coefficients_1.Fraction(x2.toFixed(3)).reduce());
|
|
2169
2174
|
}
|
|
2170
2175
|
else if (D.value === 0) {
|
|
2171
2176
|
}
|
|
@@ -2195,11 +2200,11 @@ class Polynom {
|
|
|
2195
2200
|
}
|
|
2196
2201
|
const M = this.clone().reduce();
|
|
2197
2202
|
for (const m of M._monoms) {
|
|
2198
|
-
if (m.degree(letter)
|
|
2203
|
+
if (m.degree(letter).isEqual(degree)) {
|
|
2199
2204
|
return m.clone();
|
|
2200
2205
|
}
|
|
2201
2206
|
}
|
|
2202
|
-
return new
|
|
2207
|
+
return new monom_1.Monom().zero();
|
|
2203
2208
|
};
|
|
2204
2209
|
monomsByDegree = (degree, letter) => {
|
|
2205
2210
|
if (degree === undefined) {
|
|
@@ -2221,7 +2226,7 @@ class Polynom {
|
|
|
2221
2226
|
return m.clone();
|
|
2222
2227
|
}
|
|
2223
2228
|
}
|
|
2224
|
-
return new
|
|
2229
|
+
return new monom_1.Monom().zero();
|
|
2225
2230
|
};
|
|
2226
2231
|
getDenominators = () => {
|
|
2227
2232
|
const denominators = [];
|
|
@@ -2238,91 +2243,35 @@ class Polynom {
|
|
|
2238
2243
|
return numerators;
|
|
2239
2244
|
};
|
|
2240
2245
|
lcmDenominator = () => {
|
|
2241
|
-
return
|
|
2246
|
+
return numeric_1.Numeric.lcm(...this.getDenominators());
|
|
2242
2247
|
};
|
|
2243
2248
|
gcdDenominator = () => {
|
|
2244
|
-
return
|
|
2249
|
+
return numeric_1.Numeric.gcd(...this.getDenominators());
|
|
2245
2250
|
};
|
|
2246
2251
|
lcmNumerator = () => {
|
|
2247
|
-
return
|
|
2252
|
+
return numeric_1.Numeric.lcm(...this.getNumerators());
|
|
2248
2253
|
};
|
|
2249
2254
|
gcdNumerator = () => {
|
|
2250
|
-
return
|
|
2255
|
+
return numeric_1.Numeric.gcd(...this.getNumerators());
|
|
2251
2256
|
};
|
|
2252
2257
|
commonMonom = () => {
|
|
2253
|
-
let M = new
|
|
2258
|
+
let M = new monom_1.Monom().one(), numerator, denominator, degree = this.degree();
|
|
2254
2259
|
numerator = this.gcdNumerator();
|
|
2255
2260
|
denominator = this.gcdDenominator();
|
|
2256
|
-
M.coefficient = new
|
|
2261
|
+
M.coefficient = new coefficients_1.Fraction(numerator, denominator);
|
|
2257
2262
|
for (let L of this.variables) {
|
|
2258
2263
|
M.setLetter(L, degree);
|
|
2259
2264
|
for (let m of this._monoms) {
|
|
2260
|
-
M.setLetter(L,
|
|
2261
|
-
if (M.degree(L)
|
|
2265
|
+
M.setLetter(L, coefficients_1.Fraction.min(m.degree(L), M.degree(L)));
|
|
2266
|
+
if (M.degree(L).isZero()) {
|
|
2262
2267
|
break;
|
|
2263
2268
|
}
|
|
2264
2269
|
}
|
|
2265
2270
|
}
|
|
2266
2271
|
return M;
|
|
2267
2272
|
};
|
|
2268
|
-
makeItComplicate = (complexity = 1) => {
|
|
2269
|
-
this._texString = '';
|
|
2270
|
-
if (this.degree() < 1) {
|
|
2271
|
-
return this;
|
|
2272
|
-
}
|
|
2273
|
-
const mDegree = _random_random__WEBPACK_IMPORTED_MODULE_3__.Random.number(0, this.degree() - 1);
|
|
2274
|
-
return this;
|
|
2275
|
-
};
|
|
2276
|
-
factorizePartial = (forceSign) => {
|
|
2277
|
-
this._texString = '';
|
|
2278
|
-
if (this.length <= 1) {
|
|
2279
|
-
return this;
|
|
2280
|
-
}
|
|
2281
|
-
let mMain, mCheck, mFactor, pFactor, g, sign;
|
|
2282
|
-
for (let i = 0; i < this.length; i++) {
|
|
2283
|
-
mMain = this._monoms[i].clone();
|
|
2284
|
-
for (let j = i + 1; j < this.length; j++) {
|
|
2285
|
-
mCheck = this._monoms[j].clone();
|
|
2286
|
-
g = _numeric__WEBPACK_IMPORTED_MODULE_2__["default"].gcd(mMain.coefficient.numerator, mCheck.coefficient.numerator);
|
|
2287
|
-
if (g !== 1) {
|
|
2288
|
-
mFactor = _monom__WEBPACK_IMPORTED_MODULE_0__["default"].lcm(mMain, mCheck);
|
|
2289
|
-
sign = mMain.coefficient.sign() === 1 ? '+' : '-';
|
|
2290
|
-
this._texString = `${forceSign === true ? sign : (sign === '+' ? '' : sign)}${mFactor.tex}`;
|
|
2291
|
-
pFactor = new Polynom().add(mMain.divide(mFactor)).add(mCheck.divide(mFactor));
|
|
2292
|
-
this._texString += pFactor.genDisplay('tex', false, true);
|
|
2293
|
-
this._texString += this.clone().subtract(pFactor.clone().multiply(mFactor)).genDisplay('tex', true, false);
|
|
2294
|
-
return this;
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
this._texString = this.genDisplay('tex', forceSign);
|
|
2299
|
-
return this;
|
|
2300
|
-
};
|
|
2301
|
-
minify = () => {
|
|
2302
|
-
this.multiply(this.lcmDenominator()).divide(this.gcdNumerator()).reduce();
|
|
2303
|
-
return this.reduce();
|
|
2304
|
-
};
|
|
2305
|
-
canDivide = (P, letter = 'x') => {
|
|
2306
|
-
const d = P.degree();
|
|
2307
|
-
const evalValue = {};
|
|
2308
|
-
if (d === 0) {
|
|
2309
|
-
return !P.isZero;
|
|
2310
|
-
}
|
|
2311
|
-
if (d === 1) {
|
|
2312
|
-
const z = P.getZeroes();
|
|
2313
|
-
if (z[0] === true || z[0] === false) {
|
|
2314
|
-
return false;
|
|
2315
|
-
}
|
|
2316
|
-
evalValue[letter] = z[0];
|
|
2317
|
-
return this.evaluate(evalValue).value === 0;
|
|
2318
|
-
}
|
|
2319
|
-
if (d > 1) {
|
|
2320
|
-
console.log('Currently, only first degree polynom are supported');
|
|
2321
|
-
return false;
|
|
2322
|
-
}
|
|
2323
|
-
return false;
|
|
2324
|
-
};
|
|
2325
2273
|
}
|
|
2274
|
+
exports.Polynom = Polynom;
|
|
2326
2275
|
|
|
2327
2276
|
|
|
2328
2277
|
/***/ }),
|
|
@@ -2331,21 +2280,20 @@ class Polynom {
|
|
|
2331
2280
|
/*!***************************************!*\
|
|
2332
2281
|
!*** ./src/maths/algebra/rational.ts ***!
|
|
2333
2282
|
\***************************************/
|
|
2334
|
-
/***/ ((__unused_webpack_module,
|
|
2283
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2335
2284
|
|
|
2336
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2337
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2338
|
-
/* harmony export */ "default": () => (/* binding */ Rational)
|
|
2339
|
-
/* harmony export */ });
|
|
2340
|
-
/* harmony import */ var _polynom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
2341
2285
|
|
|
2286
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2287
|
+
exports.Rational = void 0;
|
|
2288
|
+
const polynom_1 = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
2289
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
2342
2290
|
class Rational {
|
|
2343
2291
|
_rawString;
|
|
2344
2292
|
_numerator;
|
|
2345
2293
|
_denominator;
|
|
2346
2294
|
constructor(numerator, denominator) {
|
|
2347
|
-
this._numerator = numerator ? numerator.clone() : new
|
|
2348
|
-
this._denominator = denominator ? denominator.clone() : new
|
|
2295
|
+
this._numerator = numerator ? numerator.clone() : new polynom_1.Polynom();
|
|
2296
|
+
this._denominator = denominator ? denominator.clone() : new polynom_1.Polynom();
|
|
2349
2297
|
}
|
|
2350
2298
|
clone = () => {
|
|
2351
2299
|
this._numerator = this._numerator.clone();
|
|
@@ -2426,21 +2374,22 @@ class Rational {
|
|
|
2426
2374
|
if (value === Infinity || value === -Infinity) {
|
|
2427
2375
|
let N = this._numerator.monomByDegree(this._numerator.degree(letter), letter), D = this._denominator.monomByDegree(this._denominator.degree(letter), letter);
|
|
2428
2376
|
N.divide(D);
|
|
2429
|
-
if (N.degree(letter)
|
|
2430
|
-
return N.coefficient.sign() * (Math.pow((value > 0 ? 1 : -1), N.degree(letter) % 2)) === 1 ? Infinity : -Infinity;
|
|
2377
|
+
if (N.degree(letter).isStrictlyPositive()) {
|
|
2378
|
+
return N.coefficient.sign() * (Math.pow((value > 0 ? 1 : -1), N.degree(letter).value % 2)) === 1 ? Infinity : -Infinity;
|
|
2431
2379
|
}
|
|
2432
|
-
if (N.degree(letter)
|
|
2380
|
+
if (N.degree(letter).isZero()) {
|
|
2433
2381
|
return N.coefficient;
|
|
2434
2382
|
}
|
|
2435
|
-
if (N.degree(letter)
|
|
2436
|
-
return N.coefficient.sign() * (Math.pow(-1, N.degree(letter) % 2)) === 1 ? 0 : -0;
|
|
2383
|
+
if (N.degree(letter).isStrictlyPositive()) {
|
|
2384
|
+
return N.coefficient.sign() * (Math.pow(-1, N.degree(letter).value % 2)) === 1 ? 0 : -0;
|
|
2437
2385
|
}
|
|
2438
2386
|
}
|
|
2439
2387
|
else {
|
|
2440
|
-
return this._numerator.evaluate({ letter: value }).divide(this._denominator.evaluate({ letter: value }));
|
|
2388
|
+
return this._numerator.evaluate({ letter: new fraction_1.Fraction(value) }).divide(this._denominator.evaluate({ letter: new fraction_1.Fraction(value) }));
|
|
2441
2389
|
}
|
|
2442
2390
|
};
|
|
2443
2391
|
}
|
|
2392
|
+
exports.Rational = Rational;
|
|
2444
2393
|
|
|
2445
2394
|
|
|
2446
2395
|
/***/ }),
|
|
@@ -2449,14 +2398,12 @@ class Rational {
|
|
|
2449
2398
|
/*!********************************************!*\
|
|
2450
2399
|
!*** ./src/maths/coefficients/fraction.ts ***!
|
|
2451
2400
|
\********************************************/
|
|
2452
|
-
/***/ ((__unused_webpack_module,
|
|
2401
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2453
2402
|
|
|
2454
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2455
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2456
|
-
/* harmony export */ "default": () => (/* binding */ Fraction)
|
|
2457
|
-
/* harmony export */ });
|
|
2458
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
2459
2403
|
|
|
2404
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2405
|
+
exports.Fraction = void 0;
|
|
2406
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
2460
2407
|
class Fraction {
|
|
2461
2408
|
_numerator;
|
|
2462
2409
|
_denominator;
|
|
@@ -2605,13 +2552,23 @@ class Fraction {
|
|
|
2605
2552
|
return this;
|
|
2606
2553
|
};
|
|
2607
2554
|
add = (F) => {
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2555
|
+
if (F instanceof Fraction) {
|
|
2556
|
+
let N = this._numerator, D = this._denominator;
|
|
2557
|
+
this._numerator = N * F.denominator + F.numerator * D;
|
|
2558
|
+
this._denominator = D * F.denominator;
|
|
2559
|
+
}
|
|
2560
|
+
else {
|
|
2561
|
+
return this.add(new Fraction(F));
|
|
2562
|
+
}
|
|
2611
2563
|
return this.reduce();
|
|
2612
2564
|
};
|
|
2613
2565
|
subtract = (F) => {
|
|
2614
|
-
|
|
2566
|
+
if (F instanceof Fraction) {
|
|
2567
|
+
return this.add(F.clone().opposed());
|
|
2568
|
+
}
|
|
2569
|
+
else {
|
|
2570
|
+
return this.add(-F);
|
|
2571
|
+
}
|
|
2615
2572
|
};
|
|
2616
2573
|
multiply = (F) => {
|
|
2617
2574
|
let Q = new Fraction(F);
|
|
@@ -2636,6 +2593,9 @@ class Fraction {
|
|
|
2636
2593
|
return this;
|
|
2637
2594
|
};
|
|
2638
2595
|
pow = (p) => {
|
|
2596
|
+
if (p instanceof Fraction) {
|
|
2597
|
+
return this.pow(p.value);
|
|
2598
|
+
}
|
|
2639
2599
|
if (!Number.isSafeInteger(p)) {
|
|
2640
2600
|
return this.invalid();
|
|
2641
2601
|
}
|
|
@@ -2667,8 +2627,28 @@ class Fraction {
|
|
|
2667
2627
|
this._denominator = Math.abs(this._denominator);
|
|
2668
2628
|
return this;
|
|
2669
2629
|
};
|
|
2630
|
+
static max = (...fractions) => {
|
|
2631
|
+
let M = new Fraction(fractions[0]);
|
|
2632
|
+
for (let m of fractions) {
|
|
2633
|
+
let compare = new Fraction(m);
|
|
2634
|
+
if (compare.greater(M)) {
|
|
2635
|
+
M = compare.clone();
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
return M;
|
|
2639
|
+
};
|
|
2640
|
+
static min = (...fractions) => {
|
|
2641
|
+
let M = new Fraction(fractions[0]);
|
|
2642
|
+
for (let m of fractions) {
|
|
2643
|
+
let compare = new Fraction(m);
|
|
2644
|
+
if (compare.lesser(M)) {
|
|
2645
|
+
M = compare.clone();
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
return M;
|
|
2649
|
+
};
|
|
2670
2650
|
reduce = () => {
|
|
2671
|
-
let g =
|
|
2651
|
+
let g = numeric_1.Numeric.gcd(this._numerator, this._denominator);
|
|
2672
2652
|
this._numerator = this._numerator / g;
|
|
2673
2653
|
this._denominator = this._denominator / g;
|
|
2674
2654
|
if (this._denominator < 0) {
|
|
@@ -2688,19 +2668,26 @@ class Fraction {
|
|
|
2688
2668
|
if (sign === undefined) {
|
|
2689
2669
|
sign = '=';
|
|
2690
2670
|
}
|
|
2671
|
+
let compareFraction;
|
|
2672
|
+
if (F instanceof Fraction) {
|
|
2673
|
+
compareFraction = F.clone();
|
|
2674
|
+
}
|
|
2675
|
+
else {
|
|
2676
|
+
compareFraction = new Fraction(F);
|
|
2677
|
+
}
|
|
2691
2678
|
switch (sign) {
|
|
2692
2679
|
case '>':
|
|
2693
|
-
return this.value >
|
|
2680
|
+
return this.value > compareFraction.value;
|
|
2694
2681
|
case ">=" || 0 || 0:
|
|
2695
|
-
return this.value >=
|
|
2682
|
+
return this.value >= compareFraction.value;
|
|
2696
2683
|
case "<":
|
|
2697
|
-
return this.value <
|
|
2684
|
+
return this.value < compareFraction.value;
|
|
2698
2685
|
case "<=" || 0 || 0:
|
|
2699
|
-
return this.value <=
|
|
2686
|
+
return this.value <= compareFraction.value;
|
|
2700
2687
|
case "=":
|
|
2701
|
-
return this.value ===
|
|
2688
|
+
return this.value === compareFraction.value;
|
|
2702
2689
|
case "<>":
|
|
2703
|
-
return this.value !==
|
|
2690
|
+
return this.value !== compareFraction.value;
|
|
2704
2691
|
default:
|
|
2705
2692
|
return false;
|
|
2706
2693
|
}
|
|
@@ -2720,7 +2707,7 @@ class Fraction {
|
|
|
2720
2707
|
isEqual = (than) => {
|
|
2721
2708
|
return this.compare(than, '=');
|
|
2722
2709
|
};
|
|
2723
|
-
|
|
2710
|
+
isNotEqual = (than) => {
|
|
2724
2711
|
return this.compare(than, '<>');
|
|
2725
2712
|
};
|
|
2726
2713
|
isOpposed = (p) => {
|
|
@@ -2732,15 +2719,27 @@ class Fraction {
|
|
|
2732
2719
|
isZero = () => {
|
|
2733
2720
|
return this._numerator === 0;
|
|
2734
2721
|
};
|
|
2722
|
+
isNotZero = () => {
|
|
2723
|
+
return this._numerator !== 0;
|
|
2724
|
+
};
|
|
2735
2725
|
isOne = () => {
|
|
2736
2726
|
return this._numerator === 1 && this._denominator === 1;
|
|
2737
2727
|
};
|
|
2728
|
+
isNegativeOne = () => {
|
|
2729
|
+
return this._numerator === -1 && this._denominator === 1;
|
|
2730
|
+
};
|
|
2738
2731
|
isPositive = () => {
|
|
2739
2732
|
return this.sign() === 1;
|
|
2740
2733
|
};
|
|
2741
2734
|
isNegative = () => {
|
|
2742
2735
|
return this.sign() === -1;
|
|
2743
2736
|
};
|
|
2737
|
+
isStrictlyPositive = () => {
|
|
2738
|
+
return this.value > 0;
|
|
2739
|
+
};
|
|
2740
|
+
isStrictlyNegative = () => {
|
|
2741
|
+
return this.value < 0;
|
|
2742
|
+
};
|
|
2744
2743
|
isNaN = () => {
|
|
2745
2744
|
return isNaN(this._numerator);
|
|
2746
2745
|
};
|
|
@@ -2754,7 +2753,19 @@ class Fraction {
|
|
|
2754
2753
|
return Math.sqrt(this._numerator) % 1 === 0 && Math.sqrt(this._denominator) % 1 === 0;
|
|
2755
2754
|
};
|
|
2756
2755
|
isReduced = () => {
|
|
2757
|
-
return Math.abs(
|
|
2756
|
+
return Math.abs(numeric_1.Numeric.gcd(this._numerator, this._denominator)) === 1;
|
|
2757
|
+
};
|
|
2758
|
+
isNatural = () => {
|
|
2759
|
+
return this.clone().reduce().denominator === 1;
|
|
2760
|
+
};
|
|
2761
|
+
isRational = () => {
|
|
2762
|
+
return !this.isNatural();
|
|
2763
|
+
};
|
|
2764
|
+
isEven = () => {
|
|
2765
|
+
return this.isNatural() && this.value % 2 === 0;
|
|
2766
|
+
};
|
|
2767
|
+
isOdd = () => {
|
|
2768
|
+
return this.isNatural() && this.value % 2 === 1;
|
|
2758
2769
|
};
|
|
2759
2770
|
sign = () => {
|
|
2760
2771
|
return (this._numerator * this._denominator >= 0) ? 1 : -1;
|
|
@@ -2768,6 +2779,31 @@ class Fraction {
|
|
|
2768
2779
|
return true;
|
|
2769
2780
|
};
|
|
2770
2781
|
}
|
|
2782
|
+
exports.Fraction = Fraction;
|
|
2783
|
+
|
|
2784
|
+
|
|
2785
|
+
/***/ }),
|
|
2786
|
+
|
|
2787
|
+
/***/ "./src/maths/coefficients/index.ts":
|
|
2788
|
+
/*!*****************************************!*\
|
|
2789
|
+
!*** ./src/maths/coefficients/index.ts ***!
|
|
2790
|
+
\*****************************************/
|
|
2791
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2792
|
+
|
|
2793
|
+
|
|
2794
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2795
|
+
if (k2 === undefined) k2 = k;
|
|
2796
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
2797
|
+
}) : (function(o, m, k, k2) {
|
|
2798
|
+
if (k2 === undefined) k2 = k;
|
|
2799
|
+
o[k2] = m[k];
|
|
2800
|
+
}));
|
|
2801
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
2802
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
2803
|
+
};
|
|
2804
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2805
|
+
__exportStar(__webpack_require__(/*! ./fraction */ "./src/maths/coefficients/fraction.ts"), exports);
|
|
2806
|
+
__exportStar(__webpack_require__(/*! ./nthroot */ "./src/maths/coefficients/nthroot.ts"), exports);
|
|
2771
2807
|
|
|
2772
2808
|
|
|
2773
2809
|
/***/ }),
|
|
@@ -2776,12 +2812,11 @@ class Fraction {
|
|
|
2776
2812
|
/*!*******************************************!*\
|
|
2777
2813
|
!*** ./src/maths/coefficients/nthroot.ts ***!
|
|
2778
2814
|
\*******************************************/
|
|
2779
|
-
/***/ ((__unused_webpack_module,
|
|
2815
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2780
2816
|
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
/* harmony export */ });
|
|
2817
|
+
|
|
2818
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2819
|
+
exports.Nthroot = void 0;
|
|
2785
2820
|
class Nthroot {
|
|
2786
2821
|
_radical;
|
|
2787
2822
|
_nth;
|
|
@@ -2873,6 +2908,7 @@ class Nthroot {
|
|
|
2873
2908
|
return !(this._radical === 1 || this._radical === 0 || this._isValid === false);
|
|
2874
2909
|
};
|
|
2875
2910
|
}
|
|
2911
|
+
exports.Nthroot = Nthroot;
|
|
2876
2912
|
|
|
2877
2913
|
|
|
2878
2914
|
/***/ }),
|
|
@@ -2881,23 +2917,20 @@ class Nthroot {
|
|
|
2881
2917
|
/*!**************************************!*\
|
|
2882
2918
|
!*** ./src/maths/geometry/circle.ts ***!
|
|
2883
2919
|
\**************************************/
|
|
2884
|
-
/***/ ((__unused_webpack_module,
|
|
2920
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2885
2921
|
|
|
2886
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2887
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2888
|
-
/* harmony export */ "default": () => (/* binding */ Circle)
|
|
2889
|
-
/* harmony export */ });
|
|
2890
|
-
/* harmony import */ var _point__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
2891
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
2892
|
-
/* harmony import */ var _algebra_equation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
2893
|
-
/* harmony import */ var _algebra_polynom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../algebra/polynom */ "./src/maths/algebra/polynom.ts");
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
2922
|
|
|
2923
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2924
|
+
exports.Circle = void 0;
|
|
2925
|
+
const point_1 = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
2926
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
2927
|
+
const algebra_1 = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
|
|
2928
|
+
const vector_1 = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
2898
2929
|
class Circle {
|
|
2899
2930
|
_center;
|
|
2900
2931
|
_radius;
|
|
2932
|
+
_squareRadius;
|
|
2933
|
+
_cartesian;
|
|
2901
2934
|
_exists;
|
|
2902
2935
|
constructor(...values) {
|
|
2903
2936
|
this._exists = false;
|
|
@@ -2905,11 +2938,44 @@ class Circle {
|
|
|
2905
2938
|
this.parse(...values);
|
|
2906
2939
|
}
|
|
2907
2940
|
}
|
|
2941
|
+
get center() {
|
|
2942
|
+
return this._center;
|
|
2943
|
+
}
|
|
2908
2944
|
parse(...values) {
|
|
2909
|
-
if (values.length ===
|
|
2910
|
-
this.
|
|
2911
|
-
|
|
2945
|
+
if (values.length === 1 && typeof values[0] === 'string') {
|
|
2946
|
+
this.checkCircle(new algebra_1.Equation(values[0]));
|
|
2947
|
+
}
|
|
2948
|
+
else if (values.length >= 2) {
|
|
2949
|
+
this._center = new point_1.Point(values[0]);
|
|
2950
|
+
if (values[1] instanceof point_1.Point) {
|
|
2951
|
+
this._squareRadius = new vector_1.Vector(this._center, values[1]).normSquare;
|
|
2952
|
+
}
|
|
2953
|
+
else {
|
|
2954
|
+
if (values[2] === true) {
|
|
2955
|
+
this._squareRadius = new coefficients_1.Fraction(values[1]);
|
|
2956
|
+
}
|
|
2957
|
+
else {
|
|
2958
|
+
this._radius = new coefficients_1.Fraction(values[1]);
|
|
2959
|
+
this._squareRadius = this._radius.clone().pow(2);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
this._cartesian = (new algebra_1.Equation(new algebra_1.Polynom(`(x-(${this._center.x.display}))^2+(y-(${this._center.y.display}))^2`), new algebra_1.Polynom(`${this._squareRadius.display}`))).moveLeft();
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
get radius() {
|
|
2966
|
+
if (this._squareRadius.isSquare()) {
|
|
2967
|
+
return {
|
|
2968
|
+
tex: this._squareRadius.clone().sqrt().tex,
|
|
2969
|
+
display: this._squareRadius.clone().sqrt().display,
|
|
2970
|
+
};
|
|
2971
|
+
}
|
|
2972
|
+
else {
|
|
2973
|
+
return {
|
|
2974
|
+
tex: `\\sqrt{${this._squareRadius.tex}}`,
|
|
2975
|
+
display: `sqrt(${this._squareRadius.display})`
|
|
2976
|
+
};
|
|
2912
2977
|
}
|
|
2978
|
+
return this._squareRadius;
|
|
2913
2979
|
}
|
|
2914
2980
|
get tex() {
|
|
2915
2981
|
let cx, cy;
|
|
@@ -2917,21 +2983,76 @@ class Circle {
|
|
|
2917
2983
|
cx = 'x^2';
|
|
2918
2984
|
}
|
|
2919
2985
|
else {
|
|
2920
|
-
cx = `\\left(x
|
|
2986
|
+
cx = `\\left(x${this._center.x.isNegative() ? '+' : '-'}${this._center.x.clone().abs().tex}\\right)^2`;
|
|
2921
2987
|
}
|
|
2922
2988
|
if (this._center.y.isZero()) {
|
|
2923
2989
|
cy = 'y^2';
|
|
2924
2990
|
}
|
|
2925
2991
|
else {
|
|
2926
|
-
cy = `\\left(y
|
|
2992
|
+
cy = `\\left(y${this._center.y.isNegative() ? '+' : '-'}${this._center.y.clone().abs().tex}\\right)^2`;
|
|
2927
2993
|
}
|
|
2928
|
-
return `${cx}+${cy}=${this.
|
|
2994
|
+
return `${cx}+${cy}=${this._squareRadius.tex}`;
|
|
2929
2995
|
}
|
|
2930
2996
|
get developed() {
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2997
|
+
return this._cartesian.tex;
|
|
2998
|
+
}
|
|
2999
|
+
checkCircle = (P) => {
|
|
3000
|
+
if (P.degree('x').value === 2 && P.degree('y').value === 2) {
|
|
3001
|
+
let x2 = P.left.monomByDegree(2, 'x'), y2 = P.left.monomByDegree(2, 'y'), x1, y1, c;
|
|
3002
|
+
if (x2.coefficient.isEqual(y2.coefficient)) {
|
|
3003
|
+
P.divide(x2.coefficient);
|
|
3004
|
+
x1 = P.left.monomByDegree(1, 'x');
|
|
3005
|
+
y1 = P.left.monomByDegree(1, 'y');
|
|
3006
|
+
c = P.left.monomByDegree(0);
|
|
3007
|
+
this._center = new point_1.Point(x1.coefficient.clone().divide(2).opposed(), y1.coefficient.clone().divide(2).opposed());
|
|
3008
|
+
this._squareRadius = c.coefficient.clone().opposed()
|
|
3009
|
+
.add(this._center.x.clone().pow(2))
|
|
3010
|
+
.add(this._center.y.clone().pow(2));
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
return false;
|
|
3014
|
+
};
|
|
3015
|
+
relativePosition = (L) => {
|
|
3016
|
+
let distance = L.distanceTo(this.center), radius = Math.sqrt(this._squareRadius.value);
|
|
3017
|
+
if (distance.value - radius > 0.0000000001) {
|
|
3018
|
+
return 0;
|
|
3019
|
+
}
|
|
3020
|
+
else if (Math.abs(distance.value - radius) < 0.0000000001) {
|
|
3021
|
+
return 1;
|
|
3022
|
+
}
|
|
3023
|
+
else {
|
|
3024
|
+
return 2;
|
|
3025
|
+
}
|
|
3026
|
+
};
|
|
2934
3027
|
}
|
|
3028
|
+
exports.Circle = Circle;
|
|
3029
|
+
|
|
3030
|
+
|
|
3031
|
+
/***/ }),
|
|
3032
|
+
|
|
3033
|
+
/***/ "./src/maths/geometry/index.ts":
|
|
3034
|
+
/*!*************************************!*\
|
|
3035
|
+
!*** ./src/maths/geometry/index.ts ***!
|
|
3036
|
+
\*************************************/
|
|
3037
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3038
|
+
|
|
3039
|
+
|
|
3040
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3041
|
+
if (k2 === undefined) k2 = k;
|
|
3042
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
3043
|
+
}) : (function(o, m, k, k2) {
|
|
3044
|
+
if (k2 === undefined) k2 = k;
|
|
3045
|
+
o[k2] = m[k];
|
|
3046
|
+
}));
|
|
3047
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
3048
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3049
|
+
};
|
|
3050
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3051
|
+
__exportStar(__webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts"), exports);
|
|
3052
|
+
__exportStar(__webpack_require__(/*! ./triangle */ "./src/maths/geometry/triangle.ts"), exports);
|
|
3053
|
+
__exportStar(__webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts"), exports);
|
|
3054
|
+
__exportStar(__webpack_require__(/*! ./circle */ "./src/maths/geometry/circle.ts"), exports);
|
|
3055
|
+
__exportStar(__webpack_require__(/*! ./line */ "./src/maths/geometry/line.ts"), exports);
|
|
2935
3056
|
|
|
2936
3057
|
|
|
2937
3058
|
/***/ }),
|
|
@@ -2940,24 +3061,22 @@ class Circle {
|
|
|
2940
3061
|
/*!************************************!*\
|
|
2941
3062
|
!*** ./src/maths/geometry/line.ts ***!
|
|
2942
3063
|
\************************************/
|
|
2943
|
-
/***/ ((__unused_webpack_module,
|
|
3064
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2944
3065
|
|
|
2945
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2946
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2947
|
-
/* harmony export */ "default": () => (/* binding */ Line)
|
|
2948
|
-
/* harmony export */ });
|
|
2949
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
2950
|
-
/* harmony import */ var _vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
2951
|
-
/* harmony import */ var _point__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
2952
|
-
/* harmony import */ var _algebra_polynom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../algebra/polynom */ "./src/maths/algebra/polynom.ts");
|
|
2953
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
2954
|
-
/* harmony import */ var _algebra_equation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
3066
|
|
|
3067
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3068
|
+
exports.Line = void 0;
|
|
3069
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
3070
|
+
const vector_1 = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3071
|
+
const point_1 = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3072
|
+
const algebra_1 = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
|
|
3073
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
3074
|
+
var LinePropriety;
|
|
3075
|
+
(function (LinePropriety) {
|
|
3076
|
+
LinePropriety[LinePropriety["None"] = 0] = "None";
|
|
3077
|
+
LinePropriety[LinePropriety["Parallel"] = 1] = "Parallel";
|
|
3078
|
+
LinePropriety[LinePropriety["Perpendicular"] = 2] = "Perpendicular";
|
|
3079
|
+
})(LinePropriety || (LinePropriety = {}));
|
|
2961
3080
|
class Line {
|
|
2962
3081
|
_a;
|
|
2963
3082
|
_b;
|
|
@@ -2966,17 +3085,25 @@ class Line {
|
|
|
2966
3085
|
_d;
|
|
2967
3086
|
_n;
|
|
2968
3087
|
_exists;
|
|
3088
|
+
_referencePropriety;
|
|
3089
|
+
_referenceLine;
|
|
3090
|
+
static PERPENDICULAR = LinePropriety.Perpendicular;
|
|
3091
|
+
static PARALLEL = LinePropriety.Parallel;
|
|
2969
3092
|
constructor(...values) {
|
|
2970
3093
|
this._exists = false;
|
|
2971
|
-
if (values
|
|
3094
|
+
if (values.length > 0) {
|
|
2972
3095
|
this.parse(...values);
|
|
2973
3096
|
}
|
|
2974
3097
|
return this;
|
|
2975
3098
|
}
|
|
2976
|
-
get isLine() {
|
|
2977
|
-
|
|
3099
|
+
get isLine() {
|
|
3100
|
+
return true;
|
|
3101
|
+
}
|
|
3102
|
+
get exists() {
|
|
3103
|
+
return this._exists;
|
|
3104
|
+
}
|
|
2978
3105
|
get equation() {
|
|
2979
|
-
return new
|
|
3106
|
+
return new algebra_1.Equation(new algebra_1.Polynom().parse('xy', this._a, this._b, this._c), new algebra_1.Polynom('0')).simplify();
|
|
2980
3107
|
}
|
|
2981
3108
|
get tex() {
|
|
2982
3109
|
let canonical = this.equation;
|
|
@@ -2985,8 +3112,8 @@ class Line {
|
|
|
2985
3112
|
}
|
|
2986
3113
|
return {
|
|
2987
3114
|
canonical: canonical.tex,
|
|
2988
|
-
mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new
|
|
2989
|
-
parametric: `${
|
|
3115
|
+
mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new algebra_1.Polynom().parse('x', this.slope, this.height).tex,
|
|
3116
|
+
parametric: `${point_1.Point.pmatrix('x', 'y')} = ${point_1.Point.pmatrix(this._OA.x, this._OA.y)} + k\\cdot ${point_1.Point.pmatrix(this._d.x, this._d.y)}`
|
|
2990
3117
|
};
|
|
2991
3118
|
}
|
|
2992
3119
|
get a() {
|
|
@@ -3020,7 +3147,10 @@ class Line {
|
|
|
3020
3147
|
return this._n;
|
|
3021
3148
|
}
|
|
3022
3149
|
get normal() {
|
|
3023
|
-
return new
|
|
3150
|
+
return new vector_1.Vector(this._a, this._b);
|
|
3151
|
+
}
|
|
3152
|
+
get director() {
|
|
3153
|
+
return this._d.clone();
|
|
3024
3154
|
}
|
|
3025
3155
|
set d(value) {
|
|
3026
3156
|
this._d = value;
|
|
@@ -3033,49 +3163,71 @@ class Line {
|
|
|
3033
3163
|
}
|
|
3034
3164
|
parse = (...values) => {
|
|
3035
3165
|
this._exists = false;
|
|
3036
|
-
if (values.length ===
|
|
3037
|
-
return this
|
|
3038
|
-
}
|
|
3039
|
-
else if (values.length === 2) {
|
|
3040
|
-
if (values[0].isPoint && values[1].isVector) {
|
|
3041
|
-
return this.parseByPointAndVector(values[0], values[1]);
|
|
3042
|
-
}
|
|
3043
|
-
else if (values[0].isPoint && values[1].isPoint) {
|
|
3044
|
-
return this.parseByPointAndVector(values[0], new _vector__WEBPACK_IMPORTED_MODULE_1__["default"](values[0], values[1]));
|
|
3045
|
-
}
|
|
3166
|
+
if (values.length === 0) {
|
|
3167
|
+
return this;
|
|
3046
3168
|
}
|
|
3047
|
-
|
|
3048
|
-
if (values[0]
|
|
3169
|
+
if (values.length === 1) {
|
|
3170
|
+
if (values[0] instanceof Line) {
|
|
3049
3171
|
return values[0].clone();
|
|
3050
3172
|
}
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
for (let elem of ['x', 'y']) {
|
|
3059
|
-
if (letters.has(elem)) {
|
|
3060
|
-
letters.delete(elem);
|
|
3061
|
-
}
|
|
3173
|
+
else if (values[0] instanceof algebra_1.Equation) {
|
|
3174
|
+
return this.parseEquation(values[0]);
|
|
3175
|
+
}
|
|
3176
|
+
else if (typeof values[0] === "string") {
|
|
3177
|
+
try {
|
|
3178
|
+
let E = new algebra_1.Equation(values[0]);
|
|
3179
|
+
return this.parse(E);
|
|
3062
3180
|
}
|
|
3063
|
-
|
|
3064
|
-
console.log('Extra variable in the equation.');
|
|
3181
|
+
catch (e) {
|
|
3065
3182
|
return this;
|
|
3066
3183
|
}
|
|
3067
|
-
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
if (values.length === 2) {
|
|
3187
|
+
if (values[0] instanceof point_1.Point && values[1] instanceof vector_1.Vector) {
|
|
3188
|
+
return this.parseByPointAndVector(values[0], values[1]);
|
|
3189
|
+
}
|
|
3190
|
+
else if (values[0] instanceof point_1.Point && values[1] instanceof point_1.Point) {
|
|
3191
|
+
return this.parseByPointAndVector(values[0], new vector_1.Vector(values[0], values[1]));
|
|
3192
|
+
}
|
|
3193
|
+
else if (values[0] instanceof vector_1.Vector && values[1] instanceof point_1.Point) {
|
|
3194
|
+
return this.parseByPointAndNormal(values[1], values[0]);
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
if (values.length === 3) {
|
|
3198
|
+
if ((values[0] instanceof coefficients_1.Fraction || typeof values[0] === 'number')
|
|
3199
|
+
&&
|
|
3200
|
+
(values[1] instanceof coefficients_1.Fraction || typeof values[1] === 'number')
|
|
3201
|
+
&&
|
|
3202
|
+
(values[2] instanceof coefficients_1.Fraction || typeof values[2] === 'number')) {
|
|
3203
|
+
return this.parseByCoefficient(values[0], values[1], values[2]);
|
|
3068
3204
|
}
|
|
3069
3205
|
}
|
|
3070
3206
|
console.log('Someting wrong happend while creating the line');
|
|
3071
3207
|
return this;
|
|
3072
3208
|
};
|
|
3209
|
+
parseEquation = (equ) => {
|
|
3210
|
+
equ.reorder(true);
|
|
3211
|
+
let letters = new Set(equ.letters());
|
|
3212
|
+
if (!(letters.has('x') || letters.has('y'))) {
|
|
3213
|
+
return this;
|
|
3214
|
+
}
|
|
3215
|
+
for (let elem of ['x', 'y']) {
|
|
3216
|
+
if (letters.has(elem)) {
|
|
3217
|
+
letters.delete(elem);
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
if (letters.size > 0) {
|
|
3221
|
+
return this;
|
|
3222
|
+
}
|
|
3223
|
+
return this.parseByCoefficient(equ.left.monomByLetter('x').coefficient, equ.left.monomByLetter('y').coefficient, equ.left.monomByDegree(0).coefficient);
|
|
3224
|
+
};
|
|
3073
3225
|
parseByCoefficient = (a, b, c) => {
|
|
3074
|
-
this._a = new
|
|
3075
|
-
this._b = new
|
|
3076
|
-
this._c = new
|
|
3077
|
-
this._d = new
|
|
3078
|
-
this._OA = new
|
|
3226
|
+
this._a = new coefficients_1.Fraction(a);
|
|
3227
|
+
this._b = new coefficients_1.Fraction(b);
|
|
3228
|
+
this._c = new coefficients_1.Fraction(c);
|
|
3229
|
+
this._d = new vector_1.Vector(this._b.clone(), this._a.clone().opposed());
|
|
3230
|
+
this._OA = new point_1.Point(new coefficients_1.Fraction().zero(), this._c.clone());
|
|
3079
3231
|
this._n = this._d.clone().normal();
|
|
3080
3232
|
this._exists = true;
|
|
3081
3233
|
return this;
|
|
@@ -3088,6 +3240,23 @@ class Line {
|
|
|
3088
3240
|
this._exists = true;
|
|
3089
3241
|
return this;
|
|
3090
3242
|
};
|
|
3243
|
+
parseByPointAndNormal = (P, n) => {
|
|
3244
|
+
return this.parseByCoefficient(n.x, n.y, P.x.clone().multiply(n.x)
|
|
3245
|
+
.add(P.y.clone().multiply(n.y)).opposed());
|
|
3246
|
+
};
|
|
3247
|
+
parseByPointAndLine = (P, L, orientation) => {
|
|
3248
|
+
if (orientation === undefined) {
|
|
3249
|
+
orientation = LinePropriety.Parallel;
|
|
3250
|
+
}
|
|
3251
|
+
if (orientation === LinePropriety.Parallel) {
|
|
3252
|
+
return this.parseByPointAndNormal(P, L.normal);
|
|
3253
|
+
}
|
|
3254
|
+
else if (orientation === LinePropriety.Perpendicular) {
|
|
3255
|
+
return this.parseByPointAndNormal(P, L.director);
|
|
3256
|
+
}
|
|
3257
|
+
this._exists = false;
|
|
3258
|
+
return this;
|
|
3259
|
+
};
|
|
3091
3260
|
clone = () => {
|
|
3092
3261
|
this._a = this._a.clone();
|
|
3093
3262
|
this._b = this._b.clone();
|
|
@@ -3095,22 +3264,23 @@ class Line {
|
|
|
3095
3264
|
this._d = this._d.clone();
|
|
3096
3265
|
this._OA = this._OA.clone();
|
|
3097
3266
|
this._n = this._n.clone();
|
|
3267
|
+
this._exists = this.exists;
|
|
3098
3268
|
return this;
|
|
3099
3269
|
};
|
|
3100
3270
|
isParellelTo = (line) => {
|
|
3101
|
-
return this.slope.isEqual(line.slope) && this.height.
|
|
3271
|
+
return this.slope.isEqual(line.slope) && this.height.isNotEqual(line.height);
|
|
3102
3272
|
};
|
|
3103
3273
|
isSameAs = (line) => {
|
|
3104
3274
|
return this.slope.isEqual(line.slope) && this.height.isEqual(line.height);
|
|
3105
3275
|
};
|
|
3106
3276
|
simplifyDirection = () => {
|
|
3107
|
-
let lcm =
|
|
3277
|
+
let lcm = numeric_1.Numeric.lcm(this._d.x.denominator, this._d.y.denominator), gcd = numeric_1.Numeric.gcd(this._d.x.numerator, this._d.y.numerator);
|
|
3108
3278
|
this._d.x.multiply(lcm).divide(gcd);
|
|
3109
3279
|
this._d.y.multiply(lcm).divide(gcd);
|
|
3110
3280
|
return this;
|
|
3111
3281
|
};
|
|
3112
3282
|
intersection = (line) => {
|
|
3113
|
-
let Pt = new
|
|
3283
|
+
let Pt = new point_1.Point(), isParallel = false, isSame = false, hasIntersection = true;
|
|
3114
3284
|
if (this._b.isZero() || line.b.isZero()) {
|
|
3115
3285
|
}
|
|
3116
3286
|
if (this.isParellelTo(line)) {
|
|
@@ -3144,7 +3314,7 @@ class Line {
|
|
|
3144
3314
|
return {
|
|
3145
3315
|
value: NaN,
|
|
3146
3316
|
tex: 'Not a line',
|
|
3147
|
-
fraction: new
|
|
3317
|
+
fraction: new coefficients_1.Fraction().infinite()
|
|
3148
3318
|
};
|
|
3149
3319
|
}
|
|
3150
3320
|
let value = numerator.value / Math.sqrt(d2.value), F = numerator.clone().divide(d2.clone().sqrt());
|
|
@@ -3202,6 +3372,7 @@ class Line {
|
|
|
3202
3372
|
return canonical + '=0';
|
|
3203
3373
|
}
|
|
3204
3374
|
}
|
|
3375
|
+
exports.Line = Line;
|
|
3205
3376
|
|
|
3206
3377
|
|
|
3207
3378
|
/***/ }),
|
|
@@ -3210,21 +3381,19 @@ class Line {
|
|
|
3210
3381
|
/*!*************************************!*\
|
|
3211
3382
|
!*** ./src/maths/geometry/point.ts ***!
|
|
3212
3383
|
\*************************************/
|
|
3213
|
-
/***/ ((__unused_webpack_module,
|
|
3384
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3214
3385
|
|
|
3215
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3216
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3217
|
-
/* harmony export */ "default": () => (/* binding */ Point)
|
|
3218
|
-
/* harmony export */ });
|
|
3219
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3220
3386
|
|
|
3387
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3388
|
+
exports.Point = void 0;
|
|
3389
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3221
3390
|
class Point {
|
|
3222
3391
|
_x;
|
|
3223
3392
|
_y;
|
|
3224
3393
|
_exist;
|
|
3225
3394
|
constructor(...values) {
|
|
3226
|
-
this._x = new
|
|
3227
|
-
this._y = new
|
|
3395
|
+
this._x = new fraction_1.Fraction().zero();
|
|
3396
|
+
this._y = new fraction_1.Fraction().zero();
|
|
3228
3397
|
if (values !== undefined) {
|
|
3229
3398
|
this.parse(...values);
|
|
3230
3399
|
}
|
|
@@ -3252,6 +3421,12 @@ class Point {
|
|
|
3252
3421
|
pts.push(this._y.tex);
|
|
3253
3422
|
return `\\left(${pts.join(';')}\\right)`;
|
|
3254
3423
|
}
|
|
3424
|
+
get display() {
|
|
3425
|
+
let pts = [];
|
|
3426
|
+
pts.push(this._x.tex);
|
|
3427
|
+
pts.push(this._y.tex);
|
|
3428
|
+
return `(${pts.join(';')})`;
|
|
3429
|
+
}
|
|
3255
3430
|
parse = (...values) => {
|
|
3256
3431
|
this.zero();
|
|
3257
3432
|
if (values.length === 0) {
|
|
@@ -3266,22 +3441,22 @@ class Point {
|
|
|
3266
3441
|
if (typeof values[0] === 'string') {
|
|
3267
3442
|
let xy = values[0].split(',');
|
|
3268
3443
|
if (xy.length === 2) {
|
|
3269
|
-
this._x = new
|
|
3270
|
-
this._y = new
|
|
3444
|
+
this._x = new fraction_1.Fraction(xy[0]).reduce();
|
|
3445
|
+
this._y = new fraction_1.Fraction(xy[1]).reduce();
|
|
3271
3446
|
return this;
|
|
3272
3447
|
}
|
|
3273
3448
|
}
|
|
3274
3449
|
if (values[0].x !== undefined && values[0].y !== undefined) {
|
|
3275
|
-
this._x = new
|
|
3276
|
-
this._y = new
|
|
3450
|
+
this._x = new fraction_1.Fraction(values[0].x).reduce();
|
|
3451
|
+
this._y = new fraction_1.Fraction(values[0].y).reduce();
|
|
3277
3452
|
}
|
|
3278
3453
|
else {
|
|
3279
3454
|
return this.zero();
|
|
3280
3455
|
}
|
|
3281
3456
|
}
|
|
3282
3457
|
if (values.length === 2) {
|
|
3283
|
-
this._x = new
|
|
3284
|
-
this._y = new
|
|
3458
|
+
this._x = new fraction_1.Fraction(values[0]).reduce();
|
|
3459
|
+
this._y = new fraction_1.Fraction(values[1]).reduce();
|
|
3285
3460
|
}
|
|
3286
3461
|
return this;
|
|
3287
3462
|
};
|
|
@@ -3291,8 +3466,8 @@ class Point {
|
|
|
3291
3466
|
return this;
|
|
3292
3467
|
};
|
|
3293
3468
|
zero = () => {
|
|
3294
|
-
this._x = new
|
|
3295
|
-
this._y = new
|
|
3469
|
+
this._x = new fraction_1.Fraction(null);
|
|
3470
|
+
this._y = new fraction_1.Fraction(null);
|
|
3296
3471
|
return this;
|
|
3297
3472
|
};
|
|
3298
3473
|
origin = () => {
|
|
@@ -3319,6 +3494,7 @@ class Point {
|
|
|
3319
3494
|
}
|
|
3320
3495
|
};
|
|
3321
3496
|
}
|
|
3497
|
+
exports.Point = Point;
|
|
3322
3498
|
|
|
3323
3499
|
|
|
3324
3500
|
/***/ }),
|
|
@@ -3327,22 +3503,16 @@ class Point {
|
|
|
3327
3503
|
/*!****************************************!*\
|
|
3328
3504
|
!*** ./src/maths/geometry/triangle.ts ***!
|
|
3329
3505
|
\****************************************/
|
|
3330
|
-
/***/ ((__unused_webpack_module,
|
|
3506
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3331
3507
|
|
|
3332
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3333
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3334
|
-
/* harmony export */ "default": () => (/* binding */ Triangle)
|
|
3335
|
-
/* harmony export */ });
|
|
3336
|
-
/* harmony import */ var _point__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3337
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3338
|
-
/* harmony import */ var _vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3339
|
-
/* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./line */ "./src/maths/geometry/line.ts");
|
|
3340
|
-
/* harmony import */ var _algebra_equation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
3508
|
|
|
3509
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3510
|
+
exports.Triangle = void 0;
|
|
3511
|
+
const point_1 = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3512
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3513
|
+
const vector_1 = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3514
|
+
const line_1 = __webpack_require__(/*! ./line */ "./src/maths/geometry/line.ts");
|
|
3515
|
+
const equation_1 = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
3346
3516
|
class Triangle {
|
|
3347
3517
|
_A;
|
|
3348
3518
|
_B;
|
|
@@ -3413,12 +3583,12 @@ class Triangle {
|
|
|
3413
3583
|
}
|
|
3414
3584
|
parse = (...values) => {
|
|
3415
3585
|
if (values.length === 6) {
|
|
3416
|
-
let v = values.map((x) => new
|
|
3417
|
-
return this.parse(new
|
|
3586
|
+
let v = values.map((x) => new fraction_1.Fraction(x));
|
|
3587
|
+
return this.parse(new point_1.Point(v[0], v[1]), new point_1.Point(v[2], v[3]), new point_1.Point(v[4], v[5]));
|
|
3418
3588
|
}
|
|
3419
3589
|
else if (values.length === 3) {
|
|
3420
3590
|
if (values.filter((x) => typeof x === 'string').length === 3) {
|
|
3421
|
-
return this.parse(...values.map((x) => new
|
|
3591
|
+
return this.parse(...values.map((x) => new line_1.Line(x)));
|
|
3422
3592
|
}
|
|
3423
3593
|
else if (values.filter((x) => x.isLine === true).length === 3) {
|
|
3424
3594
|
this._lines = {
|
|
@@ -3450,15 +3620,15 @@ class Triangle {
|
|
|
3450
3620
|
}
|
|
3451
3621
|
else {
|
|
3452
3622
|
if (values.filter((x) => x.isPoint === true).length < 3) {
|
|
3453
|
-
return this.parse(new
|
|
3623
|
+
return this.parse(new point_1.Point(values[0]), new point_1.Point(values[1]), new point_1.Point(values[2]));
|
|
3454
3624
|
}
|
|
3455
3625
|
this._A = values[0].clone();
|
|
3456
3626
|
this._B = values[1].clone();
|
|
3457
3627
|
this._C = values[2].clone();
|
|
3458
3628
|
this._lines = {
|
|
3459
|
-
'AB': new
|
|
3460
|
-
'BC': new
|
|
3461
|
-
'AC': new
|
|
3629
|
+
'AB': new line_1.Line(this._A, this._B),
|
|
3630
|
+
'BC': new line_1.Line(this._B, this._C),
|
|
3631
|
+
'AC': new line_1.Line(this._A, this._C)
|
|
3462
3632
|
};
|
|
3463
3633
|
}
|
|
3464
3634
|
}
|
|
@@ -3484,9 +3654,9 @@ class Triangle {
|
|
|
3484
3654
|
};
|
|
3485
3655
|
_updateTriangle = () => {
|
|
3486
3656
|
this._middles = {
|
|
3487
|
-
'AB': new
|
|
3488
|
-
'AC': new
|
|
3489
|
-
'BC': new
|
|
3657
|
+
'AB': new point_1.Point().middleOf(this._A, this._B),
|
|
3658
|
+
'AC': new point_1.Point().middleOf(this._A, this._C),
|
|
3659
|
+
'BC': new point_1.Point().middleOf(this._B, this._C)
|
|
3490
3660
|
};
|
|
3491
3661
|
this._remarquables = this._calculateRemarquableLines();
|
|
3492
3662
|
};
|
|
@@ -3502,26 +3672,26 @@ class Triangle {
|
|
|
3502
3672
|
return this._A;
|
|
3503
3673
|
};
|
|
3504
3674
|
getSegment = (ptName1, ptName2) => {
|
|
3505
|
-
return new
|
|
3675
|
+
return new vector_1.Vector(this.getPointByName(ptName1), this.getPointByName(ptName2));
|
|
3506
3676
|
};
|
|
3507
3677
|
_calculateRemarquableLines = () => {
|
|
3508
3678
|
let remarquables = {
|
|
3509
3679
|
'medians': {
|
|
3510
|
-
'A': new
|
|
3511
|
-
'B': new
|
|
3512
|
-
'C': new
|
|
3680
|
+
'A': new line_1.Line(this._A, this._middles.BC),
|
|
3681
|
+
'B': new line_1.Line(this._B, this._middles.AC),
|
|
3682
|
+
'C': new line_1.Line(this._C, this._middles.AB),
|
|
3513
3683
|
'intersection': null
|
|
3514
3684
|
},
|
|
3515
3685
|
'mediators': {
|
|
3516
|
-
'AB': new
|
|
3517
|
-
'AC': new
|
|
3518
|
-
'BC': new
|
|
3686
|
+
'AB': new line_1.Line(this._middles.AB, new vector_1.Vector(this._A, this._B).normal()),
|
|
3687
|
+
'AC': new line_1.Line(this._middles.AC, new vector_1.Vector(this._A, this._C).normal()),
|
|
3688
|
+
'BC': new line_1.Line(this._middles.BC, new vector_1.Vector(this._B, this._C).normal()),
|
|
3519
3689
|
'intersection': null
|
|
3520
3690
|
},
|
|
3521
3691
|
'heights': {
|
|
3522
|
-
'A': new
|
|
3523
|
-
'B': new
|
|
3524
|
-
'C': new
|
|
3692
|
+
'A': new line_1.Line(this._A, new vector_1.Vector(this._B, this._C).normal()),
|
|
3693
|
+
'B': new line_1.Line(this._B, new vector_1.Vector(this._A, this._C).normal()),
|
|
3694
|
+
'C': new line_1.Line(this._C, new vector_1.Vector(this._A, this._B).normal()),
|
|
3525
3695
|
'intersection': null
|
|
3526
3696
|
},
|
|
3527
3697
|
'bisectors': {
|
|
@@ -3551,7 +3721,7 @@ class Triangle {
|
|
|
3551
3721
|
d1 = tlines.BC;
|
|
3552
3722
|
d2 = tlines.AC;
|
|
3553
3723
|
}
|
|
3554
|
-
let b1 = new
|
|
3724
|
+
let b1 = new line_1.Line(new equation_1.Equation(d1.equation.left.clone().multiply(d2.n.simplify().norm), d2.equation.left.clone().multiply(d1.n.simplify().norm)).reorder(true).simplify()), b2 = new line_1.Line(new equation_1.Equation(d1.equation.left.clone().multiply(d2.n.simplify().norm), d2.equation.left.clone().multiply(d1.n.simplify().norm).opposed()).reorder(true).simplify());
|
|
3555
3725
|
if (pt === 'A') {
|
|
3556
3726
|
return b1.hitSegment(this.B, this.C) ? b1 : b2;
|
|
3557
3727
|
}
|
|
@@ -3564,6 +3734,7 @@ class Triangle {
|
|
|
3564
3734
|
return b1;
|
|
3565
3735
|
};
|
|
3566
3736
|
}
|
|
3737
|
+
exports.Triangle = Triangle;
|
|
3567
3738
|
|
|
3568
3739
|
|
|
3569
3740
|
/***/ }),
|
|
@@ -3572,30 +3743,24 @@ class Triangle {
|
|
|
3572
3743
|
/*!**************************************!*\
|
|
3573
3744
|
!*** ./src/maths/geometry/vector.ts ***!
|
|
3574
3745
|
\**************************************/
|
|
3575
|
-
/***/ ((__unused_webpack_module,
|
|
3746
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3576
3747
|
|
|
3577
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3578
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3579
|
-
/* harmony export */ "default": () => (/* binding */ Vector)
|
|
3580
|
-
/* harmony export */ });
|
|
3581
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3582
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
3583
|
-
|
|
3584
3748
|
|
|
3749
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3750
|
+
exports.Vector = void 0;
|
|
3751
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3752
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
3585
3753
|
class Vector {
|
|
3586
3754
|
_x;
|
|
3587
3755
|
_y;
|
|
3588
3756
|
constructor(...values) {
|
|
3589
|
-
this._x = new
|
|
3590
|
-
this._y = new
|
|
3757
|
+
this._x = new fraction_1.Fraction().zero();
|
|
3758
|
+
this._y = new fraction_1.Fraction().zero();
|
|
3591
3759
|
if (values !== undefined) {
|
|
3592
3760
|
this.parse(...values);
|
|
3593
3761
|
}
|
|
3594
3762
|
}
|
|
3595
3763
|
;
|
|
3596
|
-
get isVector() {
|
|
3597
|
-
return true;
|
|
3598
|
-
}
|
|
3599
3764
|
get x() {
|
|
3600
3765
|
return this._x;
|
|
3601
3766
|
}
|
|
@@ -3623,7 +3788,7 @@ class Vector {
|
|
|
3623
3788
|
return this;
|
|
3624
3789
|
}
|
|
3625
3790
|
if (values.length === 1) {
|
|
3626
|
-
if (values[0]
|
|
3791
|
+
if (values[0] instanceof Vector) {
|
|
3627
3792
|
return values[0].clone();
|
|
3628
3793
|
}
|
|
3629
3794
|
else {
|
|
@@ -3637,10 +3802,10 @@ class Vector {
|
|
|
3637
3802
|
return this;
|
|
3638
3803
|
}
|
|
3639
3804
|
if (values[0].isFraction || !isNaN(values[0])) {
|
|
3640
|
-
this._x = new
|
|
3805
|
+
this._x = new fraction_1.Fraction(values[0]);
|
|
3641
3806
|
}
|
|
3642
3807
|
if (values[1].isFraction || !isNaN(values[1])) {
|
|
3643
|
-
this._y = new
|
|
3808
|
+
this._y = new fraction_1.Fraction(values[1]);
|
|
3644
3809
|
}
|
|
3645
3810
|
}
|
|
3646
3811
|
return this;
|
|
@@ -3662,19 +3827,19 @@ class Vector {
|
|
|
3662
3827
|
};
|
|
3663
3828
|
zero = () => {
|
|
3664
3829
|
this.reset();
|
|
3665
|
-
this._x = new
|
|
3666
|
-
this._y = new
|
|
3830
|
+
this._x = new fraction_1.Fraction(null);
|
|
3831
|
+
this._y = new fraction_1.Fraction(null);
|
|
3667
3832
|
return this;
|
|
3668
3833
|
};
|
|
3669
3834
|
one = () => {
|
|
3670
|
-
this._x = new
|
|
3671
|
-
this._y = new
|
|
3835
|
+
this._x = new fraction_1.Fraction();
|
|
3836
|
+
this._y = new fraction_1.Fraction();
|
|
3672
3837
|
return this;
|
|
3673
3838
|
};
|
|
3674
3839
|
_parseString = (value) => {
|
|
3675
3840
|
let components = value.split(/[,;\s]/g);
|
|
3676
|
-
this.x = new
|
|
3677
|
-
this.y = new
|
|
3841
|
+
this.x = new fraction_1.Fraction(components[0] || null);
|
|
3842
|
+
this.y = new fraction_1.Fraction(components[1] || null);
|
|
3678
3843
|
return this;
|
|
3679
3844
|
};
|
|
3680
3845
|
opposed = () => {
|
|
@@ -3706,17 +3871,17 @@ class Vector {
|
|
|
3706
3871
|
return this.scalarProductWithVector(v).isZero();
|
|
3707
3872
|
};
|
|
3708
3873
|
multiplyByScalar = (k) => {
|
|
3709
|
-
let scalar = new
|
|
3874
|
+
let scalar = new fraction_1.Fraction(k);
|
|
3710
3875
|
this._x.multiply(scalar);
|
|
3711
3876
|
this._y.multiply(scalar);
|
|
3712
3877
|
return this;
|
|
3713
3878
|
};
|
|
3714
3879
|
divideByScalar = (k) => {
|
|
3715
|
-
return this.multiplyByScalar(new
|
|
3880
|
+
return this.multiplyByScalar(new fraction_1.Fraction(k).invert());
|
|
3716
3881
|
};
|
|
3717
3882
|
simplify = () => {
|
|
3718
|
-
return this.multiplyByScalar(
|
|
3719
|
-
.divideByScalar(
|
|
3883
|
+
return this.multiplyByScalar(numeric_1.Numeric.lcm(this._x.denominator, this._y.denominator))
|
|
3884
|
+
.divideByScalar(numeric_1.Numeric.gcd(this._x.numerator, this._y.numerator));
|
|
3720
3885
|
};
|
|
3721
3886
|
angleWith = (V, sharp, radian) => {
|
|
3722
3887
|
let scalar = this.scalarProductWithVector(V).value, toDegree = radian ? 1 : 180 / Math.PI;
|
|
@@ -3726,6 +3891,7 @@ class Vector {
|
|
|
3726
3891
|
return toDegree * Math.acos(scalar / (this.norm * V.norm));
|
|
3727
3892
|
};
|
|
3728
3893
|
}
|
|
3894
|
+
exports.Vector = Vector;
|
|
3729
3895
|
|
|
3730
3896
|
|
|
3731
3897
|
/***/ }),
|
|
@@ -3734,12 +3900,11 @@ class Vector {
|
|
|
3734
3900
|
/*!******************************!*\
|
|
3735
3901
|
!*** ./src/maths/numeric.ts ***!
|
|
3736
3902
|
\******************************/
|
|
3737
|
-
/***/ ((__unused_webpack_module,
|
|
3903
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
3738
3904
|
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
/* harmony export */ });
|
|
3905
|
+
|
|
3906
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3907
|
+
exports.Numeric = void 0;
|
|
3743
3908
|
class Numeric {
|
|
3744
3909
|
static round(value, decimals = 2) {
|
|
3745
3910
|
return Number(Math.round(Number(value + 'e' + decimals)) + 'e-' + decimals);
|
|
@@ -3801,49 +3966,62 @@ class Numeric {
|
|
|
3801
3966
|
});
|
|
3802
3967
|
}
|
|
3803
3968
|
}
|
|
3969
|
+
exports.Numeric = Numeric;
|
|
3804
3970
|
|
|
3805
3971
|
|
|
3806
3972
|
/***/ }),
|
|
3807
3973
|
|
|
3808
|
-
/***/ "./src/maths/random/
|
|
3809
|
-
|
|
3810
|
-
!*** ./src/maths/random/
|
|
3811
|
-
|
|
3812
|
-
/***/ ((__unused_webpack_module,
|
|
3974
|
+
/***/ "./src/maths/random/index.ts":
|
|
3975
|
+
/*!***********************************!*\
|
|
3976
|
+
!*** ./src/maths/random/index.ts ***!
|
|
3977
|
+
\***********************************/
|
|
3978
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3813
3979
|
|
|
3814
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3815
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3816
|
-
/* harmony export */ "Random": () => (/* binding */ Random)
|
|
3817
|
-
/* harmony export */ });
|
|
3818
|
-
/* harmony import */ var _rndPolynom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rndPolynom */ "./src/maths/random/rndPolynom.ts");
|
|
3819
|
-
/* harmony import */ var _rndMonom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
3820
|
-
/* harmony import */ var _rndHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./rndHelpers */ "./src/maths/random/rndHelpers.ts");
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
3980
|
|
|
3981
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3982
|
+
if (k2 === undefined) k2 = k;
|
|
3983
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
3984
|
+
}) : (function(o, m, k, k2) {
|
|
3985
|
+
if (k2 === undefined) k2 = k;
|
|
3986
|
+
o[k2] = m[k];
|
|
3987
|
+
}));
|
|
3988
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
3989
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3990
|
+
};
|
|
3991
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3992
|
+
exports.Random = void 0;
|
|
3993
|
+
const rndPolynom_1 = __webpack_require__(/*! ./rndPolynom */ "./src/maths/random/rndPolynom.ts");
|
|
3994
|
+
const rndMonom_1 = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
3995
|
+
const rndHelpers_1 = __webpack_require__(/*! ./rndHelpers */ "./src/maths/random/rndHelpers.ts");
|
|
3996
|
+
const rndFraction_1 = __webpack_require__(/*! ./rndFraction */ "./src/maths/random/rndFraction.ts");
|
|
3997
|
+
__exportStar(__webpack_require__(/*! ./rndTypes */ "./src/maths/random/rndTypes.ts"), exports);
|
|
3824
3998
|
var Random;
|
|
3825
3999
|
(function (Random) {
|
|
3826
4000
|
function polynom(config) {
|
|
3827
|
-
return new
|
|
4001
|
+
return (new rndPolynom_1.rndPolynom(config)).generate();
|
|
3828
4002
|
}
|
|
3829
4003
|
Random.polynom = polynom;
|
|
3830
4004
|
function monom(config) {
|
|
3831
|
-
return new
|
|
4005
|
+
return (new rndMonom_1.rndMonom(config)).generate();
|
|
3832
4006
|
}
|
|
3833
4007
|
Random.monom = monom;
|
|
3834
|
-
function
|
|
4008
|
+
function fraction(config) {
|
|
4009
|
+
return (new rndFraction_1.rndFraction(config)).generate();
|
|
4010
|
+
}
|
|
4011
|
+
Random.fraction = fraction;
|
|
4012
|
+
function number(from, to) { return rndHelpers_1.rndHelpers.randomInt(from, to); }
|
|
3835
4013
|
Random.number = number;
|
|
3836
|
-
function numberSym(max, allowZero) { return
|
|
4014
|
+
function numberSym(max, allowZero) { return rndHelpers_1.rndHelpers.randomIntSym(max, allowZero); }
|
|
3837
4015
|
Random.numberSym = numberSym;
|
|
3838
|
-
function bool(percent) { return
|
|
4016
|
+
function bool(percent) { return rndHelpers_1.rndHelpers.randomBool(percent); }
|
|
3839
4017
|
Random.bool = bool;
|
|
3840
|
-
function array(arr, number) { return
|
|
4018
|
+
function array(arr, number) { return rndHelpers_1.rndHelpers.randomArray(arr, number); }
|
|
3841
4019
|
Random.array = array;
|
|
3842
|
-
function item(arr) { return
|
|
4020
|
+
function item(arr) { return rndHelpers_1.rndHelpers.randomItem(arr); }
|
|
3843
4021
|
Random.item = item;
|
|
3844
|
-
function shuffle(arr) {
|
|
4022
|
+
function shuffle(arr) { rndHelpers_1.rndHelpers.shuffleArray(arr); }
|
|
3845
4023
|
Random.shuffle = shuffle;
|
|
3846
|
-
})(Random || (Random = {}));
|
|
4024
|
+
})(Random = exports.Random || (exports.Random = {}));
|
|
3847
4025
|
|
|
3848
4026
|
|
|
3849
4027
|
/***/ }),
|
|
@@ -3852,12 +4030,11 @@ var Random;
|
|
|
3852
4030
|
/*!****************************************!*\
|
|
3853
4031
|
!*** ./src/maths/random/randomCore.ts ***!
|
|
3854
4032
|
\****************************************/
|
|
3855
|
-
/***/ ((__unused_webpack_module,
|
|
4033
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
3856
4034
|
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
/* harmony export */ });
|
|
4035
|
+
|
|
4036
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4037
|
+
exports.randomCore = void 0;
|
|
3861
4038
|
class randomCore {
|
|
3862
4039
|
_config;
|
|
3863
4040
|
_defaultConfig;
|
|
@@ -3875,6 +4052,46 @@ class randomCore {
|
|
|
3875
4052
|
return this;
|
|
3876
4053
|
};
|
|
3877
4054
|
}
|
|
4055
|
+
exports.randomCore = randomCore;
|
|
4056
|
+
|
|
4057
|
+
|
|
4058
|
+
/***/ }),
|
|
4059
|
+
|
|
4060
|
+
/***/ "./src/maths/random/rndFraction.ts":
|
|
4061
|
+
/*!*****************************************!*\
|
|
4062
|
+
!*** ./src/maths/random/rndFraction.ts ***!
|
|
4063
|
+
\*****************************************/
|
|
4064
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4065
|
+
|
|
4066
|
+
|
|
4067
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4068
|
+
exports.rndFraction = void 0;
|
|
4069
|
+
const randomCore_1 = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4070
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
4071
|
+
const index_1 = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
|
|
4072
|
+
class rndFraction extends randomCore_1.randomCore {
|
|
4073
|
+
constructor(userConfig) {
|
|
4074
|
+
super();
|
|
4075
|
+
this._defaultConfig = {
|
|
4076
|
+
negative: true,
|
|
4077
|
+
reduced: true,
|
|
4078
|
+
zero: true
|
|
4079
|
+
};
|
|
4080
|
+
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
4081
|
+
}
|
|
4082
|
+
generate = () => {
|
|
4083
|
+
let Q = new coefficients_1.Fraction();
|
|
4084
|
+
if (this._config.negative) {
|
|
4085
|
+
Q.numerator = index_1.Random.numberSym(10, this._config.zero);
|
|
4086
|
+
}
|
|
4087
|
+
else {
|
|
4088
|
+
Q.numerator = index_1.Random.number(this._config.zero ? 0 : 1, 10);
|
|
4089
|
+
}
|
|
4090
|
+
Q.denominator = index_1.Random.number(1, 10);
|
|
4091
|
+
return this._config.reduced ? Q.reduce() : Q;
|
|
4092
|
+
};
|
|
4093
|
+
}
|
|
4094
|
+
exports.rndFraction = rndFraction;
|
|
3878
4095
|
|
|
3879
4096
|
|
|
3880
4097
|
/***/ }),
|
|
@@ -3883,12 +4100,11 @@ class randomCore {
|
|
|
3883
4100
|
/*!****************************************!*\
|
|
3884
4101
|
!*** ./src/maths/random/rndHelpers.ts ***!
|
|
3885
4102
|
\****************************************/
|
|
3886
|
-
/***/ ((__unused_webpack_module,
|
|
4103
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
3887
4104
|
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
/* harmony export */ });
|
|
4105
|
+
|
|
4106
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4107
|
+
exports.rndHelpers = void 0;
|
|
3892
4108
|
class rndHelpers {
|
|
3893
4109
|
static randomBool(percent = 0.5) {
|
|
3894
4110
|
return Math.random() < percent;
|
|
@@ -3933,6 +4149,7 @@ class rndHelpers {
|
|
|
3933
4149
|
return shuffleArray;
|
|
3934
4150
|
}
|
|
3935
4151
|
}
|
|
4152
|
+
exports.rndHelpers = rndHelpers;
|
|
3936
4153
|
|
|
3937
4154
|
|
|
3938
4155
|
/***/ }),
|
|
@@ -3941,19 +4158,15 @@ class rndHelpers {
|
|
|
3941
4158
|
/*!**************************************!*\
|
|
3942
4159
|
!*** ./src/maths/random/rndMonom.ts ***!
|
|
3943
4160
|
\**************************************/
|
|
3944
|
-
/***/ ((__unused_webpack_module,
|
|
4161
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3945
4162
|
|
|
3946
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3947
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3948
|
-
/* harmony export */ "default": () => (/* binding */ rndMonom)
|
|
3949
|
-
/* harmony export */ });
|
|
3950
|
-
/* harmony import */ var _randomCore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
3951
|
-
/* harmony import */ var _random__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./random */ "./src/maths/random/random.ts");
|
|
3952
|
-
/* harmony import */ var _algebra_monom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../algebra/monom */ "./src/maths/algebra/monom.ts");
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
4163
|
|
|
3956
|
-
|
|
4164
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4165
|
+
exports.rndMonom = void 0;
|
|
4166
|
+
const randomCore_1 = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4167
|
+
const index_1 = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
|
|
4168
|
+
const monom_1 = __webpack_require__(/*! ../algebra/monom */ "./src/maths/algebra/monom.ts");
|
|
4169
|
+
class rndMonom extends randomCore_1.randomCore {
|
|
3957
4170
|
constructor(userConfig) {
|
|
3958
4171
|
super();
|
|
3959
4172
|
this._defaultConfig = {
|
|
@@ -3965,15 +4178,18 @@ class rndMonom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
3965
4178
|
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
3966
4179
|
}
|
|
3967
4180
|
generate = () => {
|
|
3968
|
-
let M = new
|
|
3969
|
-
M.coefficient
|
|
4181
|
+
let M = new monom_1.Monom();
|
|
4182
|
+
M.coefficient = index_1.Random.fraction({
|
|
4183
|
+
zero: this._config.zero,
|
|
4184
|
+
reduced: true
|
|
4185
|
+
});
|
|
3970
4186
|
if (this._config.letters.length > 1) {
|
|
3971
4187
|
for (let L of this._config.letters.split('')) {
|
|
3972
4188
|
M.setLetter(L, 0);
|
|
3973
4189
|
}
|
|
3974
4190
|
for (let i = 0; i < this._config.degree; i++) {
|
|
3975
|
-
const L =
|
|
3976
|
-
M.setLetter(L, M.degree(L)
|
|
4191
|
+
const L = index_1.Random.item(this._config.letters.split(""));
|
|
4192
|
+
M.setLetter(L, M.degree(L).clone().add(1));
|
|
3977
4193
|
}
|
|
3978
4194
|
}
|
|
3979
4195
|
else {
|
|
@@ -3982,6 +4198,7 @@ class rndMonom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
3982
4198
|
return M;
|
|
3983
4199
|
};
|
|
3984
4200
|
}
|
|
4201
|
+
exports.rndMonom = rndMonom;
|
|
3985
4202
|
|
|
3986
4203
|
|
|
3987
4204
|
/***/ }),
|
|
@@ -3990,21 +4207,16 @@ class rndMonom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
3990
4207
|
/*!****************************************!*\
|
|
3991
4208
|
!*** ./src/maths/random/rndPolynom.ts ***!
|
|
3992
4209
|
\****************************************/
|
|
3993
|
-
/***/ ((__unused_webpack_module,
|
|
4210
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3994
4211
|
|
|
3995
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3996
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3997
|
-
/* harmony export */ "default": () => (/* binding */ rndPolynom)
|
|
3998
|
-
/* harmony export */ });
|
|
3999
|
-
/* harmony import */ var _randomCore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4000
|
-
/* harmony import */ var _rndMonom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
4001
|
-
/* harmony import */ var _random__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./random */ "./src/maths/random/random.ts");
|
|
4002
|
-
/* harmony import */ var _algebra_polynom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../algebra/polynom */ "./src/maths/algebra/polynom.ts");
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
4212
|
|
|
4006
|
-
|
|
4007
|
-
|
|
4213
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4214
|
+
exports.rndPolynom = void 0;
|
|
4215
|
+
const randomCore_1 = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4216
|
+
const rndMonom_1 = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
4217
|
+
const index_1 = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
|
|
4218
|
+
const algebra_1 = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
|
|
4219
|
+
class rndPolynom extends randomCore_1.randomCore {
|
|
4008
4220
|
constructor(userConfig) {
|
|
4009
4221
|
super();
|
|
4010
4222
|
this._defaultConfig = {
|
|
@@ -4020,9 +4232,12 @@ class rndPolynom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
4020
4232
|
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
4021
4233
|
}
|
|
4022
4234
|
generate = () => {
|
|
4023
|
-
|
|
4235
|
+
if (this._config.factorable && this._config.degree > 1) {
|
|
4236
|
+
return this.factorable();
|
|
4237
|
+
}
|
|
4238
|
+
let P = new algebra_1.Polynom().empty(), M;
|
|
4024
4239
|
for (let i = this._config.degree; i >= 0; i--) {
|
|
4025
|
-
M = new
|
|
4240
|
+
M = new rndMonom_1.rndMonom({
|
|
4026
4241
|
letters: this._config.letters,
|
|
4027
4242
|
degree: i,
|
|
4028
4243
|
fraction: this._config.fraction,
|
|
@@ -4034,16 +4249,34 @@ class rndPolynom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
4034
4249
|
P.add(M);
|
|
4035
4250
|
}
|
|
4036
4251
|
if (this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < P.length) {
|
|
4037
|
-
|
|
4038
|
-
P.monoms = _random__WEBPACK_IMPORTED_MODULE_2__.Random.array(P.monoms, this._config.numberOfMonoms);
|
|
4252
|
+
P.monoms = index_1.Random.array(P.monoms, this._config.numberOfMonoms);
|
|
4039
4253
|
}
|
|
4040
4254
|
return P;
|
|
4041
4255
|
};
|
|
4042
4256
|
factorable = () => {
|
|
4043
|
-
let P = new
|
|
4257
|
+
let P = new algebra_1.Polynom().one();
|
|
4258
|
+
let _factorableConfig = { ...this._config };
|
|
4259
|
+
_factorableConfig.degree = 1;
|
|
4260
|
+
_factorableConfig.factorable = false;
|
|
4261
|
+
for (let i = 0; i < this._config.degree; i++) {
|
|
4262
|
+
P.multiply(index_1.Random.polynom(_factorableConfig));
|
|
4263
|
+
}
|
|
4044
4264
|
return P;
|
|
4045
4265
|
};
|
|
4046
4266
|
}
|
|
4267
|
+
exports.rndPolynom = rndPolynom;
|
|
4268
|
+
|
|
4269
|
+
|
|
4270
|
+
/***/ }),
|
|
4271
|
+
|
|
4272
|
+
/***/ "./src/maths/random/rndTypes.ts":
|
|
4273
|
+
/*!**************************************!*\
|
|
4274
|
+
!*** ./src/maths/random/rndTypes.ts ***!
|
|
4275
|
+
\**************************************/
|
|
4276
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
4277
|
+
|
|
4278
|
+
|
|
4279
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4047
4280
|
|
|
4048
4281
|
|
|
4049
4282
|
/***/ }),
|
|
@@ -4052,12 +4285,11 @@ class rndPolynom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
4052
4285
|
/*!**********************************!*\
|
|
4053
4286
|
!*** ./src/maths/shutingyard.ts ***!
|
|
4054
4287
|
\**********************************/
|
|
4055
|
-
/***/ ((__unused_webpack_module,
|
|
4288
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
4056
4289
|
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
/* harmony export */ });
|
|
4290
|
+
|
|
4291
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4292
|
+
exports.Shutingyard = void 0;
|
|
4061
4293
|
class Shutingyard {
|
|
4062
4294
|
_rpn = [];
|
|
4063
4295
|
_mode;
|
|
@@ -4287,6 +4519,7 @@ class Shutingyard {
|
|
|
4287
4519
|
return this._rpn;
|
|
4288
4520
|
}
|
|
4289
4521
|
}
|
|
4522
|
+
exports.Shutingyard = Shutingyard;
|
|
4290
4523
|
|
|
4291
4524
|
|
|
4292
4525
|
/***/ })
|
|
@@ -4311,99 +4544,46 @@ class Shutingyard {
|
|
|
4311
4544
|
/******/ };
|
|
4312
4545
|
/******/
|
|
4313
4546
|
/******/ // Execute the module function
|
|
4314
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
4547
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
4315
4548
|
/******/
|
|
4316
4549
|
/******/ // Return the exports of the module
|
|
4317
4550
|
/******/ return module.exports;
|
|
4318
4551
|
/******/ }
|
|
4319
4552
|
/******/
|
|
4320
4553
|
/************************************************************************/
|
|
4321
|
-
/******/ /* webpack/runtime/define property getters */
|
|
4322
|
-
/******/ (() => {
|
|
4323
|
-
/******/ // define getter functions for harmony exports
|
|
4324
|
-
/******/ __webpack_require__.d = (exports, definition) => {
|
|
4325
|
-
/******/ for(var key in definition) {
|
|
4326
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
4327
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
4328
|
-
/******/ }
|
|
4329
|
-
/******/ }
|
|
4330
|
-
/******/ };
|
|
4331
|
-
/******/ })();
|
|
4332
|
-
/******/
|
|
4333
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
4334
|
-
/******/ (() => {
|
|
4335
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
4336
|
-
/******/ })();
|
|
4337
|
-
/******/
|
|
4338
|
-
/******/ /* webpack/runtime/make namespace object */
|
|
4339
|
-
/******/ (() => {
|
|
4340
|
-
/******/ // define __esModule on exports
|
|
4341
|
-
/******/ __webpack_require__.r = (exports) => {
|
|
4342
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
4343
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4344
|
-
/******/ }
|
|
4345
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
4346
|
-
/******/ };
|
|
4347
|
-
/******/ })();
|
|
4348
|
-
/******/
|
|
4349
|
-
/************************************************************************/
|
|
4350
4554
|
var __webpack_exports__ = {};
|
|
4351
4555
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
4352
4556
|
(() => {
|
|
4557
|
+
var exports = __webpack_exports__;
|
|
4353
4558
|
/*!*********************!*\
|
|
4354
4559
|
!*** ./src/main.ts ***!
|
|
4355
4560
|
\*********************/
|
|
4356
|
-
__webpack_require__.r(__webpack_exports__);
|
|
4357
|
-
/* harmony import */ var _maths_numeric__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./maths/numeric */ "./src/maths/numeric.ts");
|
|
4358
|
-
/* harmony import */ var _maths_shutingyard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./maths/shutingyard */ "./src/maths/shutingyard.ts");
|
|
4359
|
-
/* harmony import */ var _maths_coefficients_fraction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./maths/coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
4360
|
-
/* harmony import */ var _maths_coefficients_nthroot__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./maths/coefficients/nthroot */ "./src/maths/coefficients/nthroot.ts");
|
|
4361
|
-
/* harmony import */ var _maths_algebra_monom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./maths/algebra/monom */ "./src/maths/algebra/monom.ts");
|
|
4362
|
-
/* harmony import */ var _maths_algebra_polynom__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./maths/algebra/polynom */ "./src/maths/algebra/polynom.ts");
|
|
4363
|
-
/* harmony import */ var _maths_algebra_equation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./maths/algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
4364
|
-
/* harmony import */ var _maths_algebra_linearSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./maths/algebra/linearSystem */ "./src/maths/algebra/linearSystem.ts");
|
|
4365
|
-
/* harmony import */ var _maths_geometry_line__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./maths/geometry/line */ "./src/maths/geometry/line.ts");
|
|
4366
|
-
/* harmony import */ var _maths_geometry_circle__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./maths/geometry/circle */ "./src/maths/geometry/circle.ts");
|
|
4367
|
-
/* harmony import */ var _maths_algebra_logicalset__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./maths/algebra/logicalset */ "./src/maths/algebra/logicalset.ts");
|
|
4368
|
-
/* harmony import */ var _maths_algebra_rational__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./maths/algebra/rational */ "./src/maths/algebra/rational.ts");
|
|
4369
|
-
/* harmony import */ var _maths_random_random__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./maths/random/random */ "./src/maths/random/random.ts");
|
|
4370
|
-
/* harmony import */ var _maths_geometry_triangle__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./maths/geometry/triangle */ "./src/maths/geometry/triangle.ts");
|
|
4371
|
-
/* harmony import */ var _maths_geometry_point__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./maths/geometry/point */ "./src/maths/geometry/point.ts");
|
|
4372
|
-
/* harmony import */ var _maths_geometry_vector__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./maths/geometry/vector */ "./src/maths/geometry/vector.ts");
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
4561
|
|
|
4562
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4563
|
+
const numeric_1 = __webpack_require__(/*! ./maths/numeric */ "./src/maths/numeric.ts");
|
|
4564
|
+
const shutingyard_1 = __webpack_require__(/*! ./maths/shutingyard */ "./src/maths/shutingyard.ts");
|
|
4565
|
+
const random_1 = __webpack_require__(/*! ./maths/random */ "./src/maths/random/index.ts");
|
|
4566
|
+
const coefficients_1 = __webpack_require__(/*! ./maths/coefficients */ "./src/maths/coefficients/index.ts");
|
|
4567
|
+
const algebra_1 = __webpack_require__(/*! ./maths/algebra */ "./src/maths/algebra/index.ts");
|
|
4568
|
+
const geometry_1 = __webpack_require__(/*! ./maths/geometry */ "./src/maths/geometry/index.ts");
|
|
4389
4569
|
window.Pi = {
|
|
4390
|
-
ShutingYard:
|
|
4391
|
-
Numeric:
|
|
4392
|
-
Fraction:
|
|
4393
|
-
Root:
|
|
4394
|
-
Monom:
|
|
4395
|
-
Polynom:
|
|
4396
|
-
Equation:
|
|
4397
|
-
LinearSystem:
|
|
4398
|
-
Rational:
|
|
4399
|
-
Logicalset:
|
|
4400
|
-
Random:
|
|
4570
|
+
ShutingYard: shutingyard_1.Shutingyard,
|
|
4571
|
+
Numeric: numeric_1.Numeric,
|
|
4572
|
+
Fraction: coefficients_1.Fraction,
|
|
4573
|
+
Root: coefficients_1.Nthroot,
|
|
4574
|
+
Monom: algebra_1.Monom,
|
|
4575
|
+
Polynom: algebra_1.Polynom,
|
|
4576
|
+
Equation: algebra_1.Equation,
|
|
4577
|
+
LinearSystem: algebra_1.LinearSystem,
|
|
4578
|
+
Rational: algebra_1.Rational,
|
|
4579
|
+
Logicalset: algebra_1.Logicalset,
|
|
4580
|
+
Random: random_1.Random,
|
|
4401
4581
|
Geometry: {
|
|
4402
|
-
Vector:
|
|
4403
|
-
Point:
|
|
4404
|
-
Line:
|
|
4405
|
-
Triangle:
|
|
4406
|
-
Circle:
|
|
4582
|
+
Vector: geometry_1.Vector,
|
|
4583
|
+
Point: geometry_1.Point,
|
|
4584
|
+
Line: geometry_1.Line,
|
|
4585
|
+
Triangle: geometry_1.Triangle,
|
|
4586
|
+
Circle: geometry_1.Circle
|
|
4407
4587
|
}
|
|
4408
4588
|
};
|
|
4409
4589
|
|