pimath 0.0.35 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pi.js +190 -259
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/docs/modules/random.Random.html +1 -1
- package/esm/main.d.ts +16 -5
- package/esm/main.js +33 -22
- package/esm/main.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +1 -1
- package/esm/maths/algebra/equation.js +8 -7
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +1 -1
- package/esm/maths/algebra/linearSystem.js +7 -7
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +1 -4
- package/esm/maths/algebra/monom.js +28 -28
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +3 -3
- package/esm/maths/algebra/polynom.js +23 -23
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.d.ts +1 -1
- package/esm/maths/algebra/rational.js +2 -2
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/expressions/numexp.js +2 -2
- package/esm/maths/expressions/numexp.js.map +1 -1
- package/esm/maths/expressions/polynomexp.bkp.d.ts +2 -2
- package/esm/maths/expressions/polynomexp.bkp.js +6 -6
- package/esm/maths/expressions/polynomexp.bkp.js.map +1 -1
- package/esm/maths/expressions/polynomexp.d.ts +2 -2
- package/esm/maths/expressions/polynomexp.js +5 -5
- package/esm/maths/expressions/polynomexp.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +2 -2
- package/esm/maths/geometry/circle.js +16 -15
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +2 -2
- package/esm/maths/geometry/line.js +19 -18
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +1 -1
- package/esm/maths/geometry/point.js +12 -12
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/{random/index.d.ts → randomization/random.d.ts} +3 -2
- package/esm/maths/{random/index.js → randomization/random.js} +1 -1
- package/esm/maths/randomization/random.js.map +1 -0
- package/esm/maths/{random → randomization}/randomCore.d.ts +0 -0
- package/esm/maths/{random → randomization}/randomCore.js +0 -0
- package/esm/maths/randomization/randomCore.js.map +1 -0
- package/esm/maths/{random → randomization}/rndFraction.d.ts +1 -1
- package/esm/maths/{random → randomization}/rndFraction.js +6 -6
- package/esm/maths/randomization/rndFraction.js.map +1 -0
- package/esm/maths/{random → randomization}/rndHelpers.d.ts +0 -0
- package/esm/maths/{random → randomization}/rndHelpers.js +0 -0
- package/esm/maths/randomization/rndHelpers.js.map +1 -0
- package/esm/maths/{random → randomization}/rndMonom.d.ts +1 -1
- package/esm/maths/{random → randomization}/rndMonom.js +6 -6
- package/esm/maths/randomization/rndMonom.js.map +1 -0
- package/esm/maths/{random → randomization}/rndPolynom.d.ts +1 -1
- package/esm/maths/{random → randomization}/rndPolynom.js +6 -6
- package/esm/maths/randomization/rndPolynom.js.map +1 -0
- package/esm/maths/{random → randomization}/rndTypes.d.ts +0 -0
- package/esm/maths/{random → randomization}/rndTypes.js +0 -0
- package/esm/maths/randomization/rndTypes.js.map +1 -0
- package/package.json +1 -1
- package/src/main.ts +17 -15
- package/src/maths/algebra/equation.ts +2 -1
- package/src/maths/algebra/linearSystem.ts +2 -2
- package/src/maths/algebra/monom.ts +1 -1
- package/src/maths/algebra/polynom.ts +136 -136
- package/src/maths/algebra/rational.ts +1 -1
- package/src/maths/expressions/numexp.ts +1 -1
- package/src/maths/expressions/polynomexp.bkp.ts +2 -2
- package/src/maths/expressions/polynomexp.ts +2 -2
- package/src/maths/geometry/circle.ts +4 -2
- package/src/maths/geometry/line.ts +3 -2
- package/src/maths/geometry/point.ts +1 -1
- package/src/maths/{random/index.ts → randomization/random.ts} +3 -2
- package/src/maths/{random → randomization}/randomCore.ts +0 -0
- package/src/maths/{random → randomization}/rndFraction.ts +2 -2
- package/src/maths/{random → randomization}/rndHelpers.ts +0 -0
- package/src/maths/{random → randomization}/rndMonom.ts +2 -2
- package/src/maths/{random → randomization}/rndPolynom.ts +3 -3
- package/src/maths/{random → randomization}/rndTypes.ts +0 -0
- package/tests/algebra/monom.test.ts +1 -1
- package/tests/algebra/polynom.test.ts +8 -9
- package/esm/maths/algebra/index.d.ts +0 -7
- package/esm/maths/algebra/index.js +0 -24
- package/esm/maths/algebra/index.js.map +0 -1
- package/esm/maths/coefficients/index.d.ts +0 -2
- package/esm/maths/coefficients/index.js +0 -19
- package/esm/maths/coefficients/index.js.map +0 -1
- package/esm/maths/geometry/index.d.ts +0 -5
- package/esm/maths/geometry/index.js +0 -22
- package/esm/maths/geometry/index.js.map +0 -1
- package/esm/maths/random/index.js.map +0 -1
- package/esm/maths/random/randomCore.js.map +0 -1
- package/esm/maths/random/rndFraction.js.map +0 -1
- package/esm/maths/random/rndHelpers.js.map +0 -1
- package/esm/maths/random/rndMonom.js.map +0 -1
- package/esm/maths/random/rndPolynom.js.map +0 -1
- package/esm/maths/random/rndTypes.js.map +0 -1
- package/src/maths/algebra/index.ts +0 -7
- package/src/maths/coefficients/index.ts +0 -2
- package/src/maths/geometry/index.ts +0 -5
package/dist/pi.js
CHANGED
|
@@ -8,39 +8,50 @@
|
|
|
8
8
|
var __webpack_unused_export__;
|
|
9
9
|
|
|
10
10
|
__webpack_unused_export__ = ({ value: true });
|
|
11
|
-
exports.
|
|
11
|
+
exports.Pi = void 0;
|
|
12
12
|
const numeric_1 = __webpack_require__(956);
|
|
13
13
|
const numexp_1 = __webpack_require__(735);
|
|
14
14
|
const shutingyard_1 = __webpack_require__(505);
|
|
15
|
-
const random_1 = __webpack_require__(
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
15
|
+
const random_1 = __webpack_require__(330);
|
|
16
|
+
const fraction_1 = __webpack_require__(506);
|
|
17
|
+
const nthroot_1 = __webpack_require__(923);
|
|
18
|
+
const monom_1 = __webpack_require__(937);
|
|
19
|
+
const polynom_1 = __webpack_require__(38);
|
|
20
|
+
const equation_1 = __webpack_require__(760);
|
|
21
|
+
const linearSystem_1 = __webpack_require__(554);
|
|
22
|
+
const rational_1 = __webpack_require__(107);
|
|
23
|
+
const logicalset_1 = __webpack_require__(236);
|
|
24
|
+
const polynomexp_1 = __webpack_require__(75);
|
|
25
|
+
const vector_1 = __webpack_require__(586);
|
|
26
|
+
const line_1 = __webpack_require__(9);
|
|
27
|
+
const triangle_1 = __webpack_require__(164);
|
|
28
|
+
const circle_1 = __webpack_require__(699);
|
|
29
|
+
const point_1 = __webpack_require__(557);
|
|
19
30
|
// Expose as global
|
|
20
|
-
exports.
|
|
31
|
+
exports.Pi = {
|
|
21
32
|
ShutingYard: shutingyard_1.Shutingyard,
|
|
22
33
|
Numeric: numeric_1.Numeric,
|
|
23
34
|
NumExp: numexp_1.NumExp,
|
|
24
|
-
Fraction:
|
|
25
|
-
Root:
|
|
26
|
-
Monom:
|
|
27
|
-
Polynom:
|
|
28
|
-
Equation:
|
|
29
|
-
LinearSystem:
|
|
30
|
-
Rational:
|
|
31
|
-
Logicalset:
|
|
35
|
+
Fraction: fraction_1.Fraction,
|
|
36
|
+
Root: nthroot_1.Nthroot,
|
|
37
|
+
Monom: monom_1.Monom,
|
|
38
|
+
Polynom: polynom_1.Polynom,
|
|
39
|
+
Equation: equation_1.Equation,
|
|
40
|
+
LinearSystem: linearSystem_1.LinearSystem,
|
|
41
|
+
Rational: rational_1.Rational,
|
|
42
|
+
Logicalset: logicalset_1.Logicalset,
|
|
32
43
|
Random: random_1.Random,
|
|
33
|
-
PolynomExpFactor:
|
|
34
|
-
PolynomExpProduct:
|
|
44
|
+
PolynomExpFactor: polynomexp_1.PolynomExpFactor,
|
|
45
|
+
PolynomExpProduct: polynomexp_1.PolynomExpProduct,
|
|
35
46
|
Geometry: {
|
|
36
|
-
Vector:
|
|
37
|
-
Point:
|
|
38
|
-
Line:
|
|
39
|
-
Triangle:
|
|
40
|
-
Circle:
|
|
47
|
+
Vector: vector_1.Vector,
|
|
48
|
+
Point: point_1.Point,
|
|
49
|
+
Line: line_1.Line,
|
|
50
|
+
Triangle: triangle_1.Triangle,
|
|
51
|
+
Circle: circle_1.Circle
|
|
41
52
|
}
|
|
42
53
|
};
|
|
43
|
-
window.Pi = exports.
|
|
54
|
+
window.Pi = exports.Pi;
|
|
44
55
|
|
|
45
56
|
|
|
46
57
|
/***/ }),
|
|
@@ -53,7 +64,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
53
64
|
exports.Equation = void 0;
|
|
54
65
|
const polynom_1 = __webpack_require__(38);
|
|
55
66
|
const numeric_1 = __webpack_require__(956);
|
|
56
|
-
const
|
|
67
|
+
const fraction_1 = __webpack_require__(506);
|
|
68
|
+
const nthroot_1 = __webpack_require__(923);
|
|
57
69
|
class Equation {
|
|
58
70
|
/**
|
|
59
71
|
* Create an Equation using two polynoms.
|
|
@@ -186,7 +198,7 @@ class Equation {
|
|
|
186
198
|
*/
|
|
187
199
|
this.multiply = (value) => {
|
|
188
200
|
// Make sure we have a fraction.
|
|
189
|
-
let F = new
|
|
201
|
+
let F = new fraction_1.Fraction(value);
|
|
190
202
|
// Multiply each part of the equation by the fraction
|
|
191
203
|
this._left.multiply(F);
|
|
192
204
|
this._right.multiply(F);
|
|
@@ -212,7 +224,7 @@ class Equation {
|
|
|
212
224
|
*/
|
|
213
225
|
this.divide = (value) => {
|
|
214
226
|
// Make sure we have a fraction.
|
|
215
|
-
let F = new
|
|
227
|
+
let F = new fraction_1.Fraction(value);
|
|
216
228
|
if (F.isZero()) {
|
|
217
229
|
return this;
|
|
218
230
|
}
|
|
@@ -225,7 +237,7 @@ class Equation {
|
|
|
225
237
|
* @param letter
|
|
226
238
|
*/
|
|
227
239
|
this.degree = (letter) => {
|
|
228
|
-
return
|
|
240
|
+
return fraction_1.Fraction.max(this._left.degree(letter), this._right.degree(letter));
|
|
229
241
|
};
|
|
230
242
|
/**
|
|
231
243
|
* Determine if the equation contains more than one letter/variable.
|
|
@@ -448,7 +460,7 @@ class Equation {
|
|
|
448
460
|
];
|
|
449
461
|
}
|
|
450
462
|
else {
|
|
451
|
-
nthDelta = new
|
|
463
|
+
nthDelta = new nthroot_1.Nthroot(delta).reduce();
|
|
452
464
|
if (nthDelta.hasRadical()) {
|
|
453
465
|
// -b +- coeff\sqrt{radical}
|
|
454
466
|
// -------------------------
|
|
@@ -520,7 +532,7 @@ class Equation {
|
|
|
520
532
|
}
|
|
521
533
|
else {
|
|
522
534
|
// -b +- d / 2a
|
|
523
|
-
const S1 = new
|
|
535
|
+
const S1 = new fraction_1.Fraction(-b - nthDelta.coefficient, 2 * a).reduce(), S2 = new fraction_1.Fraction(-b + nthDelta.coefficient, 2 * a).reduce();
|
|
524
536
|
this._solutions = [
|
|
525
537
|
{
|
|
526
538
|
tex: S1.dfrac,
|
|
@@ -537,7 +549,7 @@ class Equation {
|
|
|
537
549
|
}
|
|
538
550
|
}
|
|
539
551
|
else if (delta === 0) {
|
|
540
|
-
const sol = new
|
|
552
|
+
const sol = new fraction_1.Fraction(-b, 2 * a).reduce();
|
|
541
553
|
this._solutions = [{
|
|
542
554
|
tex: sol.dfrac,
|
|
543
555
|
value: sol.value,
|
|
@@ -743,36 +755,6 @@ class Equation {
|
|
|
743
755
|
exports.Equation = Equation;
|
|
744
756
|
|
|
745
757
|
|
|
746
|
-
/***/ }),
|
|
747
|
-
|
|
748
|
-
/***/ 667:
|
|
749
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
753
|
-
if (k2 === undefined) k2 = k;
|
|
754
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
755
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
756
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
757
|
-
}
|
|
758
|
-
Object.defineProperty(o, k2, desc);
|
|
759
|
-
}) : (function(o, m, k, k2) {
|
|
760
|
-
if (k2 === undefined) k2 = k;
|
|
761
|
-
o[k2] = m[k];
|
|
762
|
-
}));
|
|
763
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
764
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
765
|
-
};
|
|
766
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
767
|
-
__exportStar(__webpack_require__(760), exports);
|
|
768
|
-
__exportStar(__webpack_require__(554), exports);
|
|
769
|
-
__exportStar(__webpack_require__(236), exports);
|
|
770
|
-
__exportStar(__webpack_require__(937), exports);
|
|
771
|
-
__exportStar(__webpack_require__(38), exports);
|
|
772
|
-
__exportStar(__webpack_require__(107), exports);
|
|
773
|
-
__exportStar(__webpack_require__(75), exports);
|
|
774
|
-
|
|
775
|
-
|
|
776
758
|
/***/ }),
|
|
777
759
|
|
|
778
760
|
/***/ 554:
|
|
@@ -781,10 +763,10 @@ __exportStar(__webpack_require__(75), exports);
|
|
|
781
763
|
|
|
782
764
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
783
765
|
exports.LinearSystem = void 0;
|
|
784
|
-
const coefficients_1 = __webpack_require__(534);
|
|
785
766
|
const equation_1 = __webpack_require__(760);
|
|
786
767
|
const polynom_1 = __webpack_require__(38);
|
|
787
|
-
const random_1 = __webpack_require__(
|
|
768
|
+
const random_1 = __webpack_require__(330);
|
|
769
|
+
const fraction_1 = __webpack_require__(506);
|
|
788
770
|
// TODO: Must check and rework
|
|
789
771
|
class LinearSystem {
|
|
790
772
|
constructor(...equationStrings) {
|
|
@@ -833,7 +815,7 @@ class LinearSystem {
|
|
|
833
815
|
// Convert the numbers to fractions if necessary
|
|
834
816
|
for (let s of solutions) {
|
|
835
817
|
if (typeof s === "number") {
|
|
836
|
-
solutionsF.push(new
|
|
818
|
+
solutionsF.push(new fraction_1.Fraction(s.toString()));
|
|
837
819
|
}
|
|
838
820
|
else {
|
|
839
821
|
solutionsF.push(s.clone());
|
|
@@ -847,7 +829,7 @@ class LinearSystem {
|
|
|
847
829
|
return this;
|
|
848
830
|
};
|
|
849
831
|
this._generateOneEquation = (...solutions) => {
|
|
850
|
-
let coeff = [], leftValue = new
|
|
832
|
+
let coeff = [], leftValue = new fraction_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;
|
|
851
833
|
for (let i = 0; i < solutions.length; i++) {
|
|
852
834
|
coeff.push(random_1.Random.numberSym(5));
|
|
853
835
|
leftValue.add(solutions[i].clone().multiply(coeff[i]));
|
|
@@ -858,7 +840,7 @@ class LinearSystem {
|
|
|
858
840
|
// Must check if it's not a linear combination
|
|
859
841
|
equ = new equation_1.Equation(`${equString}=${leftValue.display}`);
|
|
860
842
|
if (equ.right.monoms[0].coefficient.denominator != 1) {
|
|
861
|
-
equ.multiply(new
|
|
843
|
+
equ.multiply(new fraction_1.Fraction(equ.right.monoms[0].coefficient.denominator, 1));
|
|
862
844
|
}
|
|
863
845
|
if (this._checkIfLinerCombination(equ)) {
|
|
864
846
|
return equ;
|
|
@@ -869,7 +851,7 @@ class LinearSystem {
|
|
|
869
851
|
};
|
|
870
852
|
this.mergeEquations = (eq1, eq2, factor1, factor2) => {
|
|
871
853
|
// Set and clone the equations.
|
|
872
|
-
let eq1multiplied = eq1.clone().multiply(new
|
|
854
|
+
let eq1multiplied = eq1.clone().multiply(new fraction_1.Fraction(factor1)), eq2multiplied = eq2.clone().multiply(new fraction_1.Fraction(factor2));
|
|
873
855
|
// Add both equations together.
|
|
874
856
|
eq1multiplied.left.add(eq2multiplied.left);
|
|
875
857
|
eq1multiplied.right.add(eq2multiplied.right);
|
|
@@ -1031,7 +1013,7 @@ class LinearSystem {
|
|
|
1031
1013
|
let E = this._resolutionSteps[this._resolutionSteps.length - 1].equations[0];
|
|
1032
1014
|
E.solve();
|
|
1033
1015
|
return {
|
|
1034
|
-
value: new
|
|
1016
|
+
value: new fraction_1.Fraction(E.solutions[0].value),
|
|
1035
1017
|
isReal: E.isReal,
|
|
1036
1018
|
isVarnothing: E.isVarnothing
|
|
1037
1019
|
};
|
|
@@ -1215,9 +1197,9 @@ exports.Monom = void 0;
|
|
|
1215
1197
|
/***
|
|
1216
1198
|
* Monom class
|
|
1217
1199
|
*/
|
|
1218
|
-
const coefficients_1 = __webpack_require__(534);
|
|
1219
1200
|
const numeric_1 = __webpack_require__(956);
|
|
1220
1201
|
const shutingyard_1 = __webpack_require__(505);
|
|
1202
|
+
const fraction_1 = __webpack_require__(506);
|
|
1221
1203
|
class Monom {
|
|
1222
1204
|
/**
|
|
1223
1205
|
* Create a Monom
|
|
@@ -1238,10 +1220,10 @@ class Monom {
|
|
|
1238
1220
|
this._shutingYardToReducedMonom(inputStr);
|
|
1239
1221
|
}
|
|
1240
1222
|
else if (typeof inputStr === 'number') {
|
|
1241
|
-
this._coefficient = new
|
|
1223
|
+
this._coefficient = new fraction_1.Fraction(inputStr);
|
|
1242
1224
|
this._literal = {};
|
|
1243
1225
|
}
|
|
1244
|
-
else if (inputStr instanceof
|
|
1226
|
+
else if (inputStr instanceof fraction_1.Fraction) {
|
|
1245
1227
|
this._coefficient = inputStr.clone();
|
|
1246
1228
|
this._literal = {};
|
|
1247
1229
|
}
|
|
@@ -1264,7 +1246,7 @@ class Monom {
|
|
|
1264
1246
|
const element = rpn[0];
|
|
1265
1247
|
this.one();
|
|
1266
1248
|
if (element.tokenType === 'coefficient') {
|
|
1267
|
-
this.coefficient = new
|
|
1249
|
+
this.coefficient = new fraction_1.Fraction(element.token);
|
|
1268
1250
|
}
|
|
1269
1251
|
else if (element.tokenType === 'variable') {
|
|
1270
1252
|
this.setLetter(element.token, 1);
|
|
@@ -1311,7 +1293,7 @@ class Monom {
|
|
|
1311
1293
|
* Create a zero value monom
|
|
1312
1294
|
*/
|
|
1313
1295
|
this.zero = () => {
|
|
1314
|
-
this._coefficient = new
|
|
1296
|
+
this._coefficient = new fraction_1.Fraction().zero();
|
|
1315
1297
|
this._literal = {};
|
|
1316
1298
|
return this;
|
|
1317
1299
|
};
|
|
@@ -1319,7 +1301,7 @@ class Monom {
|
|
|
1319
1301
|
* Create a one value monom
|
|
1320
1302
|
*/
|
|
1321
1303
|
this.one = () => {
|
|
1322
|
-
this._coefficient = new
|
|
1304
|
+
this._coefficient = new fraction_1.Fraction().one();
|
|
1323
1305
|
this._literal = {};
|
|
1324
1306
|
return this;
|
|
1325
1307
|
};
|
|
@@ -1564,7 +1546,7 @@ class Monom {
|
|
|
1564
1546
|
* @param pow (number) Power of the setLetter (must be positive integer.
|
|
1565
1547
|
*/
|
|
1566
1548
|
this.setLetter = (letter, pow) => {
|
|
1567
|
-
if (pow instanceof
|
|
1549
|
+
if (pow instanceof fraction_1.Fraction) {
|
|
1568
1550
|
// Set the power of the letter to zero => remove it
|
|
1569
1551
|
if (this.hasLetter(letter) && pow.isZero()) {
|
|
1570
1552
|
delete this._literal[letter];
|
|
@@ -1572,7 +1554,7 @@ class Monom {
|
|
|
1572
1554
|
this._literal[letter] = pow.clone();
|
|
1573
1555
|
}
|
|
1574
1556
|
else {
|
|
1575
|
-
this.setLetter(letter, new
|
|
1557
|
+
this.setLetter(letter, new fraction_1.Fraction(pow));
|
|
1576
1558
|
}
|
|
1577
1559
|
};
|
|
1578
1560
|
/**
|
|
@@ -1581,7 +1563,7 @@ class Monom {
|
|
|
1581
1563
|
*/
|
|
1582
1564
|
this.degree = (letter) => {
|
|
1583
1565
|
if (this.variables.length === 0) {
|
|
1584
|
-
return new
|
|
1566
|
+
return new fraction_1.Fraction().zero();
|
|
1585
1567
|
}
|
|
1586
1568
|
if (letter === undefined) {
|
|
1587
1569
|
// Not setLetter given -> we get the global monom degree (sum of all the letters).
|
|
@@ -1589,7 +1571,7 @@ class Monom {
|
|
|
1589
1571
|
}
|
|
1590
1572
|
else {
|
|
1591
1573
|
// A setLetter is given -> get the corresponding power.
|
|
1592
|
-
return this._literal[letter] === undefined ? new
|
|
1574
|
+
return this._literal[letter] === undefined ? new fraction_1.Fraction().zero() : this._literal[letter].clone();
|
|
1593
1575
|
}
|
|
1594
1576
|
};
|
|
1595
1577
|
/**
|
|
@@ -1598,17 +1580,17 @@ class Monom {
|
|
|
1598
1580
|
*/
|
|
1599
1581
|
this.evaluate = (values) => {
|
|
1600
1582
|
let r = this.coefficient.clone();
|
|
1601
|
-
if (typeof values === 'number' || values instanceof
|
|
1583
|
+
if (typeof values === 'number' || values instanceof fraction_1.Fraction) {
|
|
1602
1584
|
let tmpValues = {};
|
|
1603
|
-
tmpValues[this.variables[0]] = new
|
|
1585
|
+
tmpValues[this.variables[0]] = new fraction_1.Fraction(values);
|
|
1604
1586
|
return this.evaluate(tmpValues);
|
|
1605
1587
|
}
|
|
1606
1588
|
if (typeof values === 'object') {
|
|
1607
1589
|
for (let L in this._literal) {
|
|
1608
1590
|
if (values[L] === undefined) {
|
|
1609
|
-
return new
|
|
1591
|
+
return new fraction_1.Fraction().zero();
|
|
1610
1592
|
}
|
|
1611
|
-
let value = new
|
|
1593
|
+
let value = new fraction_1.Fraction(values[L]);
|
|
1612
1594
|
r.multiply(value.pow(this._literal[L]));
|
|
1613
1595
|
}
|
|
1614
1596
|
}
|
|
@@ -1628,7 +1610,7 @@ class Monom {
|
|
|
1628
1610
|
// Subtract one to the degree.
|
|
1629
1611
|
dM._literal[letter].subtract(1);
|
|
1630
1612
|
// Multiply the coefficient by the previous degree
|
|
1631
|
-
dM._coefficient.multiply(new
|
|
1613
|
+
dM._coefficient.multiply(new fraction_1.Fraction(d.clone()));
|
|
1632
1614
|
return dM;
|
|
1633
1615
|
}
|
|
1634
1616
|
else {
|
|
@@ -1651,7 +1633,7 @@ class Monom {
|
|
|
1651
1633
|
// There is no letter.
|
|
1652
1634
|
// The coefficient might be zero (=> x) or a number a (=> ax)
|
|
1653
1635
|
if (M.coefficient.isZero()) {
|
|
1654
|
-
M.coefficient = new
|
|
1636
|
+
M.coefficient = new fraction_1.Fraction().one();
|
|
1655
1637
|
}
|
|
1656
1638
|
M.setLetter(letter, 1);
|
|
1657
1639
|
}
|
|
@@ -1713,7 +1695,7 @@ class Monom {
|
|
|
1713
1695
|
* @param {Fraction | number | string} F
|
|
1714
1696
|
*/
|
|
1715
1697
|
set coefficient(F) {
|
|
1716
|
-
this._coefficient = new
|
|
1698
|
+
this._coefficient = new fraction_1.Fraction(F);
|
|
1717
1699
|
}
|
|
1718
1700
|
/**
|
|
1719
1701
|
* Get the literal part of \\(x^{n_1}y^{n_2}\\) as dictionary \\[\\begin{array}{ll}x&=n_1\\\\y&=n_2\\end{array}\\]
|
|
@@ -1756,7 +1738,7 @@ class Monom {
|
|
|
1756
1738
|
for (const v of [...inputStr.matchAll(/([a-z])\^([+-]?[0-9]+)/g)]) {
|
|
1757
1739
|
// Create the default letter entry if necessary.
|
|
1758
1740
|
if (!(v[1] in this._literal)) {
|
|
1759
|
-
this._literal[v[1]] = new
|
|
1741
|
+
this._literal[v[1]] = new fraction_1.Fraction().zero();
|
|
1760
1742
|
}
|
|
1761
1743
|
// Add the new value.
|
|
1762
1744
|
// TODO: actually, it adds only numeric value
|
|
@@ -1766,7 +1748,7 @@ class Monom {
|
|
|
1766
1748
|
for (const v of [...inputStr.matchAll(/([a-z](?!\^))/g)]) {
|
|
1767
1749
|
// Match all single letters
|
|
1768
1750
|
if (!(v[1] in this._literal)) {
|
|
1769
|
-
this._literal[v[1]] = new
|
|
1751
|
+
this._literal[v[1]] = new fraction_1.Fraction().zero();
|
|
1770
1752
|
}
|
|
1771
1753
|
// Add one to the value.
|
|
1772
1754
|
this._literal[v[1]].add(1);
|
|
@@ -1843,7 +1825,7 @@ class Monom {
|
|
|
1843
1825
|
for (let N of dividers) {
|
|
1844
1826
|
for (let L of literals) {
|
|
1845
1827
|
let M = new Monom();
|
|
1846
|
-
M.coefficient = new
|
|
1828
|
+
M.coefficient = new fraction_1.Fraction(N);
|
|
1847
1829
|
M.literal = L;
|
|
1848
1830
|
monomDividers.push(M);
|
|
1849
1831
|
}
|
|
@@ -1852,7 +1834,7 @@ class Monom {
|
|
|
1852
1834
|
else if (dividers.length === 0) {
|
|
1853
1835
|
for (let L of literals) {
|
|
1854
1836
|
let M = new Monom();
|
|
1855
|
-
M.coefficient = new
|
|
1837
|
+
M.coefficient = new fraction_1.Fraction().one();
|
|
1856
1838
|
M.literal = L;
|
|
1857
1839
|
monomDividers.push(M);
|
|
1858
1840
|
}
|
|
@@ -1860,7 +1842,7 @@ class Monom {
|
|
|
1860
1842
|
else {
|
|
1861
1843
|
for (let N of dividers) {
|
|
1862
1844
|
let M = new Monom();
|
|
1863
|
-
M.coefficient = new
|
|
1845
|
+
M.coefficient = new fraction_1.Fraction(N);
|
|
1864
1846
|
monomDividers.push(M);
|
|
1865
1847
|
}
|
|
1866
1848
|
}
|
|
@@ -1872,7 +1854,7 @@ class Monom {
|
|
|
1872
1854
|
for (let d = 0; d <= this.literal[letter].value; d++) {
|
|
1873
1855
|
if (arr.length === 0) {
|
|
1874
1856
|
let litt = {};
|
|
1875
|
-
litt[letter] = new
|
|
1857
|
+
litt[letter] = new fraction_1.Fraction(d);
|
|
1876
1858
|
tmpList.push(litt);
|
|
1877
1859
|
}
|
|
1878
1860
|
else {
|
|
@@ -1881,7 +1863,7 @@ class Monom {
|
|
|
1881
1863
|
for (let currentLetter in item) {
|
|
1882
1864
|
litt[currentLetter] = item[currentLetter];
|
|
1883
1865
|
}
|
|
1884
|
-
litt[letter] = new
|
|
1866
|
+
litt[letter] = new fraction_1.Fraction(d);
|
|
1885
1867
|
tmpList.push(litt);
|
|
1886
1868
|
}
|
|
1887
1869
|
}
|
|
@@ -1956,7 +1938,7 @@ exports.Monom = Monom;
|
|
|
1956
1938
|
Monom.addToken = (stack, element) => {
|
|
1957
1939
|
let q1, q2, m, letter, pow;
|
|
1958
1940
|
if (element.tokenType === shutingyard_1.ShutingyardType.COEFFICIENT) {
|
|
1959
|
-
stack.push(new Monom(new
|
|
1941
|
+
stack.push(new Monom(new fraction_1.Fraction(element.token)));
|
|
1960
1942
|
}
|
|
1961
1943
|
else if (element.tokenType === shutingyard_1.ShutingyardType.VARIABLE) {
|
|
1962
1944
|
let M = new Monom().one();
|
|
@@ -1985,7 +1967,7 @@ Monom.addToken = (stack, element) => {
|
|
|
1985
1967
|
break;
|
|
1986
1968
|
case '^':
|
|
1987
1969
|
// get the two last elements in the stack
|
|
1988
|
-
pow = (stack.pop().coefficient) || new
|
|
1970
|
+
pow = (stack.pop().coefficient) || new fraction_1.Fraction().one();
|
|
1989
1971
|
m = (stack.pop()) || new Monom().one();
|
|
1990
1972
|
letter = m.variables[0];
|
|
1991
1973
|
if (letter !== undefined) {
|
|
@@ -2013,7 +1995,7 @@ Monom.lcm = (...monoms) => {
|
|
|
2013
1995
|
}
|
|
2014
1996
|
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);
|
|
2015
1997
|
// Get the coefficient.
|
|
2016
|
-
M.coefficient = new
|
|
1998
|
+
M.coefficient = new fraction_1.Fraction(n, d).reduce();
|
|
2017
1999
|
// Set the literal parts - go through each monoms literal parts and get only the lowest degree of each letters.
|
|
2018
2000
|
for (let m of monoms) {
|
|
2019
2001
|
// Remove the inexistant letters from the resulting monom
|
|
@@ -2027,7 +2009,7 @@ Monom.lcm = (...monoms) => {
|
|
|
2027
2009
|
M.literal[letter] = m.literal[letter].clone();
|
|
2028
2010
|
}
|
|
2029
2011
|
else {
|
|
2030
|
-
M.literal[letter] = new
|
|
2012
|
+
M.literal[letter] = new fraction_1.Fraction(Math.min(m.literal[letter].value, M.literal[letter].value));
|
|
2031
2013
|
}
|
|
2032
2014
|
}
|
|
2033
2015
|
}
|
|
@@ -2060,7 +2042,7 @@ exports.Polynom = void 0;
|
|
|
2060
2042
|
const monom_1 = __webpack_require__(937);
|
|
2061
2043
|
const shutingyard_1 = __webpack_require__(505);
|
|
2062
2044
|
const numeric_1 = __webpack_require__(956);
|
|
2063
|
-
const
|
|
2045
|
+
const fraction_1 = __webpack_require__(506);
|
|
2064
2046
|
/**
|
|
2065
2047
|
* Polynom class can handle polynoms, reorder, resolve, ...
|
|
2066
2048
|
* ```
|
|
@@ -2087,7 +2069,7 @@ class Polynom {
|
|
|
2087
2069
|
if (typeof inputStr === 'string') {
|
|
2088
2070
|
return this._parseString(inputStr, ...values);
|
|
2089
2071
|
}
|
|
2090
|
-
else if (typeof inputStr === 'number' || inputStr instanceof
|
|
2072
|
+
else if (typeof inputStr === 'number' || inputStr instanceof fraction_1.Fraction || inputStr instanceof monom_1.Monom) {
|
|
2091
2073
|
this._monoms.push(new monom_1.Monom(inputStr));
|
|
2092
2074
|
}
|
|
2093
2075
|
else if (inputStr instanceof Polynom) {
|
|
@@ -2238,7 +2220,7 @@ class Polynom {
|
|
|
2238
2220
|
if (value instanceof Polynom) {
|
|
2239
2221
|
return this.multiplyByPolynom(value);
|
|
2240
2222
|
}
|
|
2241
|
-
else if (value instanceof
|
|
2223
|
+
else if (value instanceof fraction_1.Fraction) {
|
|
2242
2224
|
return this.multiplyByFraction(value);
|
|
2243
2225
|
}
|
|
2244
2226
|
else if (value instanceof monom_1.Monom) {
|
|
@@ -2285,7 +2267,7 @@ class Polynom {
|
|
|
2285
2267
|
return { quotient, reminder };
|
|
2286
2268
|
};
|
|
2287
2269
|
this.divide = (value) => {
|
|
2288
|
-
if (value instanceof
|
|
2270
|
+
if (value instanceof fraction_1.Fraction) {
|
|
2289
2271
|
return this.divideByFraction(value);
|
|
2290
2272
|
}
|
|
2291
2273
|
else if (typeof value === 'number' && Number.isSafeInteger(value)) {
|
|
@@ -2473,9 +2455,9 @@ class Polynom {
|
|
|
2473
2455
|
return this.reduce();
|
|
2474
2456
|
};
|
|
2475
2457
|
this.degree = (letter) => {
|
|
2476
|
-
let d = new
|
|
2458
|
+
let d = new fraction_1.Fraction().zero();
|
|
2477
2459
|
for (const m of this._monoms) {
|
|
2478
|
-
d =
|
|
2460
|
+
d = fraction_1.Fraction.max(m.degree(letter).value, d);
|
|
2479
2461
|
}
|
|
2480
2462
|
return d;
|
|
2481
2463
|
};
|
|
@@ -2513,7 +2495,7 @@ class Polynom {
|
|
|
2513
2495
|
};
|
|
2514
2496
|
// Evaluate a polynom.
|
|
2515
2497
|
this.evaluate = (values) => {
|
|
2516
|
-
const r = new
|
|
2498
|
+
const r = new fraction_1.Fraction().zero();
|
|
2517
2499
|
this._monoms.forEach(monom => {
|
|
2518
2500
|
//console.log('Evaluate polynom: ', monom.display, values, monom.evaluate(values).display);
|
|
2519
2501
|
r.add(monom.evaluate(values));
|
|
@@ -2542,8 +2524,8 @@ class Polynom {
|
|
|
2542
2524
|
letter = 'x';
|
|
2543
2525
|
}
|
|
2544
2526
|
let valuesA = {}, valuesB = {};
|
|
2545
|
-
valuesA[letter] = new
|
|
2546
|
-
valuesB[letter] = new
|
|
2527
|
+
valuesA[letter] = new fraction_1.Fraction(a);
|
|
2528
|
+
valuesB[letter] = new fraction_1.Fraction(b);
|
|
2547
2529
|
return primitive.evaluate(valuesB).subtract(primitive.evaluate(valuesA));
|
|
2548
2530
|
};
|
|
2549
2531
|
// -------------------------------------
|
|
@@ -2613,7 +2595,7 @@ class Polynom {
|
|
|
2613
2595
|
case 1:
|
|
2614
2596
|
// There is only one monoms,
|
|
2615
2597
|
if (this._monoms.length === 1) {
|
|
2616
|
-
return [new
|
|
2598
|
+
return [new fraction_1.Fraction().zero()];
|
|
2617
2599
|
}
|
|
2618
2600
|
else {
|
|
2619
2601
|
const P = this.clone().reduce().reorder();
|
|
@@ -2636,8 +2618,8 @@ class Polynom {
|
|
|
2636
2618
|
if (D.value > 0) {
|
|
2637
2619
|
/*console.log('Two zeroes for ', P.tex); */
|
|
2638
2620
|
let x1 = (-(B.value) + Math.sqrt(D.value)) / (2 * A.value), x2 = (-(B.value) - Math.sqrt(D.value)) / (2 * A.value);
|
|
2639
|
-
zeroes.push(new
|
|
2640
|
-
zeroes.push(new
|
|
2621
|
+
zeroes.push(new fraction_1.Fraction(x1.toFixed(3)).reduce());
|
|
2622
|
+
zeroes.push(new fraction_1.Fraction(x2.toFixed(3)).reduce());
|
|
2641
2623
|
}
|
|
2642
2624
|
else if (D.value === 0) {
|
|
2643
2625
|
/*console.log('One zero for ', P.tex); */
|
|
@@ -2741,12 +2723,12 @@ class Polynom {
|
|
|
2741
2723
|
let M = new monom_1.Monom().one(), numerator, denominator, degree = this.degree();
|
|
2742
2724
|
numerator = this.gcdNumerator();
|
|
2743
2725
|
denominator = this.gcdDenominator();
|
|
2744
|
-
M.coefficient = new
|
|
2726
|
+
M.coefficient = new fraction_1.Fraction(numerator, denominator);
|
|
2745
2727
|
for (let L of this.variables) {
|
|
2746
2728
|
// Initialize the setLetter with the max degree
|
|
2747
2729
|
M.setLetter(L, degree);
|
|
2748
2730
|
for (let m of this._monoms) {
|
|
2749
|
-
M.setLetter(L,
|
|
2731
|
+
M.setLetter(L, fraction_1.Fraction.min(m.degree(L), M.degree(L)));
|
|
2750
2732
|
if (M.degree(L).isZero()) {
|
|
2751
2733
|
break;
|
|
2752
2734
|
}
|
|
@@ -2847,7 +2829,7 @@ class Polynom {
|
|
|
2847
2829
|
return this.reduce();
|
|
2848
2830
|
};
|
|
2849
2831
|
this.multiplyByInteger = (nb) => {
|
|
2850
|
-
return this.multiplyByFraction(new
|
|
2832
|
+
return this.multiplyByFraction(new fraction_1.Fraction(nb));
|
|
2851
2833
|
};
|
|
2852
2834
|
this.multiplyByMonom = (M) => {
|
|
2853
2835
|
for (const m of this._monoms) {
|
|
@@ -2856,7 +2838,7 @@ class Polynom {
|
|
|
2856
2838
|
return this.reduce();
|
|
2857
2839
|
};
|
|
2858
2840
|
this.divideByInteger = (nb) => {
|
|
2859
|
-
const nbF = new
|
|
2841
|
+
const nbF = new fraction_1.Fraction(nb);
|
|
2860
2842
|
for (const m of this._monoms) {
|
|
2861
2843
|
m.coefficient.divide(nbF);
|
|
2862
2844
|
}
|
|
@@ -3056,6 +3038,12 @@ class Polynom {
|
|
|
3056
3038
|
get numberOfVars() {
|
|
3057
3039
|
return this.variables.length;
|
|
3058
3040
|
}
|
|
3041
|
+
isZero() {
|
|
3042
|
+
return (this._monoms.length === 1 && this._monoms[0].coefficient.isZero()) || this._monoms.length === 0;
|
|
3043
|
+
}
|
|
3044
|
+
isOne() {
|
|
3045
|
+
return this._monoms.length === 1 && this._monoms[0].coefficient.isOne();
|
|
3046
|
+
}
|
|
3059
3047
|
_parseString(inputStr, ...values) {
|
|
3060
3048
|
if (values === undefined || values.length === 0) {
|
|
3061
3049
|
inputStr = '' + inputStr;
|
|
@@ -3076,7 +3064,7 @@ class Polynom {
|
|
|
3076
3064
|
else if (/^[a-z]/.test(inputStr)) {
|
|
3077
3065
|
// We assume the inputStr contains only letters.
|
|
3078
3066
|
this.empty();
|
|
3079
|
-
let fractions = values.map(x => new
|
|
3067
|
+
let fractions = values.map(x => new fraction_1.Fraction(x));
|
|
3080
3068
|
// Multiple setLetter version
|
|
3081
3069
|
if (inputStr.length > 1) {
|
|
3082
3070
|
// TODO: check that the number of values given correspond to the letters (+1 eventually)
|
|
@@ -3106,12 +3094,6 @@ class Polynom {
|
|
|
3106
3094
|
return this.zero();
|
|
3107
3095
|
}
|
|
3108
3096
|
}
|
|
3109
|
-
isZero() {
|
|
3110
|
-
return (this._monoms.length === 1 && this._monoms[0].coefficient.isZero()) || this._monoms.length === 0;
|
|
3111
|
-
}
|
|
3112
|
-
isOne() {
|
|
3113
|
-
return this._monoms.length === 1 && this._monoms[0].coefficient.isOne();
|
|
3114
|
-
}
|
|
3115
3097
|
}
|
|
3116
3098
|
exports.Polynom = Polynom;
|
|
3117
3099
|
Polynom.addToken = (stack, element) => {
|
|
@@ -3205,7 +3187,7 @@ Polynom.addToken = (stack, element) => {
|
|
|
3205
3187
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3206
3188
|
exports.Rational = void 0;
|
|
3207
3189
|
const polynom_1 = __webpack_require__(38);
|
|
3208
|
-
const
|
|
3190
|
+
const fraction_1 = __webpack_require__(506);
|
|
3209
3191
|
/**
|
|
3210
3192
|
* Rational class can handle rational polynoms
|
|
3211
3193
|
*/
|
|
@@ -3298,7 +3280,7 @@ class Rational {
|
|
|
3298
3280
|
}
|
|
3299
3281
|
}
|
|
3300
3282
|
else {
|
|
3301
|
-
return this._numerator.evaluate({ letter: new
|
|
3283
|
+
return this._numerator.evaluate({ letter: new fraction_1.Fraction(value) }).divide(this._denominator.evaluate({ letter: new fraction_1.Fraction(value) }));
|
|
3302
3284
|
}
|
|
3303
3285
|
};
|
|
3304
3286
|
this._numerator = numerator ? numerator.clone() : new polynom_1.Polynom();
|
|
@@ -3782,32 +3764,7 @@ Fraction.min = (...fractions) => {
|
|
|
3782
3764
|
|
|
3783
3765
|
/***/ }),
|
|
3784
3766
|
|
|
3785
|
-
/***/
|
|
3786
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3790
|
-
if (k2 === undefined) k2 = k;
|
|
3791
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3792
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3793
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
3794
|
-
}
|
|
3795
|
-
Object.defineProperty(o, k2, desc);
|
|
3796
|
-
}) : (function(o, m, k, k2) {
|
|
3797
|
-
if (k2 === undefined) k2 = k;
|
|
3798
|
-
o[k2] = m[k];
|
|
3799
|
-
}));
|
|
3800
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
3801
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3802
|
-
};
|
|
3803
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3804
|
-
__exportStar(__webpack_require__(506), exports);
|
|
3805
|
-
__exportStar(__webpack_require__(330), exports);
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
/***/ }),
|
|
3809
|
-
|
|
3810
|
-
/***/ 330:
|
|
3767
|
+
/***/ 923:
|
|
3811
3768
|
/***/ ((__unused_webpack_module, exports) => {
|
|
3812
3769
|
|
|
3813
3770
|
|
|
@@ -3934,7 +3891,7 @@ exports.Nthroot = Nthroot;
|
|
|
3934
3891
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3935
3892
|
exports.NumExp = void 0;
|
|
3936
3893
|
const shutingyard_1 = __webpack_require__(505);
|
|
3937
|
-
const
|
|
3894
|
+
const fraction_1 = __webpack_require__(506);
|
|
3938
3895
|
class NumExp {
|
|
3939
3896
|
constructor(value) {
|
|
3940
3897
|
this._expression = value;
|
|
@@ -4008,7 +3965,7 @@ class NumExp {
|
|
|
4008
3965
|
this._addToStack(stack, +element.token);
|
|
4009
3966
|
}
|
|
4010
3967
|
else {
|
|
4011
|
-
this._addToStack(stack, new
|
|
3968
|
+
this._addToStack(stack, new fraction_1.Fraction(element.token).value);
|
|
4012
3969
|
}
|
|
4013
3970
|
}
|
|
4014
3971
|
else if (element.tokenType === shutingyard_1.ShutingyardType.VARIABLE) {
|
|
@@ -4094,12 +4051,12 @@ exports.NumExp = NumExp;
|
|
|
4094
4051
|
|
|
4095
4052
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4096
4053
|
exports.PolynomExpProduct = exports.PolynomExpFactor = void 0;
|
|
4097
|
-
const
|
|
4098
|
-
const
|
|
4054
|
+
const polynom_1 = __webpack_require__(38);
|
|
4055
|
+
const fraction_1 = __webpack_require__(506);
|
|
4099
4056
|
class PolynomExpFactor {
|
|
4100
4057
|
constructor(polynom, degree, mathFunction) {
|
|
4101
|
-
this._polynom = new
|
|
4102
|
-
this._degree = new
|
|
4058
|
+
this._polynom = new polynom_1.Polynom(polynom);
|
|
4059
|
+
this._degree = new fraction_1.Fraction(degree === undefined ? 1 : degree);
|
|
4103
4060
|
this._fn = mathFunction;
|
|
4104
4061
|
this._powerAsInteger = true;
|
|
4105
4062
|
this._forceParenthesis = true;
|
|
@@ -4260,7 +4217,7 @@ class PolynomExpProduct {
|
|
|
4260
4217
|
}
|
|
4261
4218
|
reduce() {
|
|
4262
4219
|
let coefficients = this._factors.filter(factor => factor.isCoefficient), polynoms = this._factors.filter(factor => !factor.isCoefficient);
|
|
4263
|
-
let result = new
|
|
4220
|
+
let result = new fraction_1.Fraction().one();
|
|
4264
4221
|
if (coefficients.length > 1) {
|
|
4265
4222
|
for (const factor of coefficients) {
|
|
4266
4223
|
if (factor.degree.isPositive()) {
|
|
@@ -4347,12 +4304,13 @@ exports.PolynomExpProduct = PolynomExpProduct;
|
|
|
4347
4304
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4348
4305
|
exports.Circle = void 0;
|
|
4349
4306
|
const point_1 = __webpack_require__(557);
|
|
4350
|
-
const coefficients_1 = __webpack_require__(534);
|
|
4351
|
-
const algebra_1 = __webpack_require__(667);
|
|
4352
4307
|
const line_1 = __webpack_require__(9);
|
|
4353
4308
|
const vector_1 = __webpack_require__(586);
|
|
4354
4309
|
const triangle_1 = __webpack_require__(164);
|
|
4355
4310
|
const numeric_1 = __webpack_require__(956);
|
|
4311
|
+
const fraction_1 = __webpack_require__(506);
|
|
4312
|
+
const equation_1 = __webpack_require__(760);
|
|
4313
|
+
const polynom_1 = __webpack_require__(38);
|
|
4356
4314
|
class Circle {
|
|
4357
4315
|
constructor(...values) {
|
|
4358
4316
|
/**
|
|
@@ -4378,21 +4336,21 @@ class Circle {
|
|
|
4378
4336
|
return [];
|
|
4379
4337
|
}
|
|
4380
4338
|
const equX = this._cartesian.clone(), lineX = L.equation.clone().isolate('x'), lineY = L.equation.clone().isolate('y');
|
|
4381
|
-
if (lineX instanceof
|
|
4339
|
+
if (lineX instanceof equation_1.Equation && lineY instanceof equation_1.Equation) {
|
|
4382
4340
|
equX.replaceBy('y', lineY.right).simplify();
|
|
4383
4341
|
equX.solve();
|
|
4384
4342
|
for (let x of equX.solutions) {
|
|
4385
4343
|
if (x.exact === false && isNaN(x.value)) {
|
|
4386
4344
|
continue;
|
|
4387
4345
|
}
|
|
4388
|
-
solX = new
|
|
4346
|
+
solX = new fraction_1.Fraction(x.exact === false ? x.value : x.exact);
|
|
4389
4347
|
intersectionPoints.push(new point_1.Point(solX.clone(), lineY.right.evaluate(solX)));
|
|
4390
4348
|
}
|
|
4391
4349
|
}
|
|
4392
4350
|
return intersectionPoints;
|
|
4393
4351
|
};
|
|
4394
4352
|
this.tangents = (P) => {
|
|
4395
|
-
if (P instanceof
|
|
4353
|
+
if (P instanceof fraction_1.Fraction) {
|
|
4396
4354
|
return this._tangentsWithSlope(P);
|
|
4397
4355
|
}
|
|
4398
4356
|
else if (this.isPointOnCircle(P)) {
|
|
@@ -4442,15 +4400,15 @@ class Circle {
|
|
|
4442
4400
|
// Centre: cx, cy, radius: r
|
|
4443
4401
|
// (m.cx - cy -m.px + py)^2 = r^2 * (m^2 + 1)
|
|
4444
4402
|
// (m(cx-py) - (cy - py))^2 = r^2 * (m^2 + 1)
|
|
4445
|
-
let cx_px = this.center.x.clone().subtract(P.x), cy_py = this.center.y.clone().subtract(P.y), polyLeft = new
|
|
4403
|
+
let cx_px = this.center.x.clone().subtract(P.x), cy_py = this.center.y.clone().subtract(P.y), polyLeft = new polynom_1.Polynom('x'), polyRight = new polynom_1.Polynom('x^2+1');
|
|
4446
4404
|
polyLeft.multiply(cx_px).subtract(cy_py).pow(2);
|
|
4447
4405
|
polyRight.multiply(this.squareRadius);
|
|
4448
|
-
let equ = new
|
|
4406
|
+
let equ = new equation_1.Equation(polyLeft, polyRight);
|
|
4449
4407
|
equ.moveLeft().simplify().solve();
|
|
4450
4408
|
return equ.solutions.map(sol => {
|
|
4451
4409
|
// h = -m px + py
|
|
4452
|
-
let h, equ = new
|
|
4453
|
-
if (sol.exact instanceof
|
|
4410
|
+
let h, equ = new equation_1.Equation('y', 'x');
|
|
4411
|
+
if (sol.exact instanceof fraction_1.Fraction) {
|
|
4454
4412
|
h = P.x.clone().opposed().multiply(sol.exact).add(P.y);
|
|
4455
4413
|
equ.right.multiply(sol.exact).add(h);
|
|
4456
4414
|
}
|
|
@@ -4554,9 +4512,9 @@ class Circle {
|
|
|
4554
4512
|
// three values: Point, Fraction, Boolean (center, square radius, true)
|
|
4555
4513
|
this._reset();
|
|
4556
4514
|
if (typeof values[0] === 'string') {
|
|
4557
|
-
this._parseEquation(new
|
|
4515
|
+
this._parseEquation(new equation_1.Equation(values[0]));
|
|
4558
4516
|
}
|
|
4559
|
-
else if (values[0] instanceof
|
|
4517
|
+
else if (values[0] instanceof equation_1.Equation) {
|
|
4560
4518
|
this._parseEquation(values[0]);
|
|
4561
4519
|
}
|
|
4562
4520
|
else if (values[0] instanceof Circle) {
|
|
@@ -4571,7 +4529,7 @@ class Circle {
|
|
|
4571
4529
|
this._parseCenterAndPointThrough(values[0], values[1]);
|
|
4572
4530
|
}
|
|
4573
4531
|
}
|
|
4574
|
-
else if (values[1] instanceof
|
|
4532
|
+
else if (values[1] instanceof fraction_1.Fraction || typeof values[1] === 'number') {
|
|
4575
4533
|
this._parseCenterAndRadius(values[0], values[1], (typeof values[2] === "boolean") ? values[2] : false);
|
|
4576
4534
|
}
|
|
4577
4535
|
}
|
|
@@ -4586,7 +4544,7 @@ class Circle {
|
|
|
4586
4544
|
return this;
|
|
4587
4545
|
}
|
|
4588
4546
|
_calculateCartesian() {
|
|
4589
|
-
this._cartesian = (new
|
|
4547
|
+
this._cartesian = (new equation_1.Equation(new polynom_1.Polynom(`(x-(${this._center.x.display}))^2+(y-(${this._center.y.display}))^2`), new polynom_1.Polynom(`${this._squareRadius.display}`))).moveLeft();
|
|
4590
4548
|
}
|
|
4591
4549
|
_parseCopyCircle(circle) {
|
|
4592
4550
|
this._center = circle.center.clone();
|
|
@@ -4598,10 +4556,10 @@ class Circle {
|
|
|
4598
4556
|
_parseCenterAndRadius(center, radius, square) {
|
|
4599
4557
|
this._center = center.clone();
|
|
4600
4558
|
if (square) {
|
|
4601
|
-
this._squareRadius = (new
|
|
4559
|
+
this._squareRadius = (new fraction_1.Fraction(radius));
|
|
4602
4560
|
}
|
|
4603
4561
|
else {
|
|
4604
|
-
this._squareRadius = new
|
|
4562
|
+
this._squareRadius = new fraction_1.Fraction(radius).pow(2);
|
|
4605
4563
|
}
|
|
4606
4564
|
this._exists = true;
|
|
4607
4565
|
return this;
|
|
@@ -4650,34 +4608,6 @@ class Circle {
|
|
|
4650
4608
|
exports.Circle = Circle;
|
|
4651
4609
|
|
|
4652
4610
|
|
|
4653
|
-
/***/ }),
|
|
4654
|
-
|
|
4655
|
-
/***/ 272:
|
|
4656
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4660
|
-
if (k2 === undefined) k2 = k;
|
|
4661
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4662
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4663
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
4664
|
-
}
|
|
4665
|
-
Object.defineProperty(o, k2, desc);
|
|
4666
|
-
}) : (function(o, m, k, k2) {
|
|
4667
|
-
if (k2 === undefined) k2 = k;
|
|
4668
|
-
o[k2] = m[k];
|
|
4669
|
-
}));
|
|
4670
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
4671
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4672
|
-
};
|
|
4673
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4674
|
-
__exportStar(__webpack_require__(586), exports);
|
|
4675
|
-
__exportStar(__webpack_require__(164), exports);
|
|
4676
|
-
__exportStar(__webpack_require__(557), exports);
|
|
4677
|
-
__exportStar(__webpack_require__(699), exports);
|
|
4678
|
-
__exportStar(__webpack_require__(9), exports);
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
4611
|
/***/ }),
|
|
4682
4612
|
|
|
4683
4613
|
/***/ 9:
|
|
@@ -4689,11 +4619,12 @@ __exportStar(__webpack_require__(9), exports);
|
|
|
4689
4619
|
*/
|
|
4690
4620
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4691
4621
|
exports.Line = exports.LinePropriety = void 0;
|
|
4692
|
-
const coefficients_1 = __webpack_require__(534);
|
|
4693
4622
|
const vector_1 = __webpack_require__(586);
|
|
4694
4623
|
const point_1 = __webpack_require__(557);
|
|
4695
|
-
const algebra_1 = __webpack_require__(667);
|
|
4696
4624
|
const numeric_1 = __webpack_require__(956);
|
|
4625
|
+
const fraction_1 = __webpack_require__(506);
|
|
4626
|
+
const equation_1 = __webpack_require__(760);
|
|
4627
|
+
const polynom_1 = __webpack_require__(38);
|
|
4697
4628
|
var LinePropriety;
|
|
4698
4629
|
(function (LinePropriety) {
|
|
4699
4630
|
LinePropriety[LinePropriety["None"] = 0] = "None";
|
|
@@ -4723,14 +4654,14 @@ class Line {
|
|
|
4723
4654
|
// Already a Line
|
|
4724
4655
|
return values[0].clone();
|
|
4725
4656
|
}
|
|
4726
|
-
else if (values[0] instanceof
|
|
4657
|
+
else if (values[0] instanceof equation_1.Equation) {
|
|
4727
4658
|
// It's an Equation
|
|
4728
4659
|
return this.parseEquation(values[0]);
|
|
4729
4660
|
}
|
|
4730
4661
|
else if (typeof values[0] === "string") {
|
|
4731
4662
|
// It's a string - create an Equation from it.
|
|
4732
4663
|
try {
|
|
4733
|
-
let E = new
|
|
4664
|
+
let E = new equation_1.Equation(values[0]);
|
|
4734
4665
|
return this.parse(E);
|
|
4735
4666
|
}
|
|
4736
4667
|
catch (e) {
|
|
@@ -4750,11 +4681,11 @@ class Line {
|
|
|
4750
4681
|
}
|
|
4751
4682
|
}
|
|
4752
4683
|
if (values.length === 3) {
|
|
4753
|
-
if ((values[0] instanceof
|
|
4684
|
+
if ((values[0] instanceof fraction_1.Fraction || typeof values[0] === 'number')
|
|
4754
4685
|
&&
|
|
4755
|
-
(values[1] instanceof
|
|
4686
|
+
(values[1] instanceof fraction_1.Fraction || typeof values[1] === 'number')
|
|
4756
4687
|
&&
|
|
4757
|
-
(values[2] instanceof
|
|
4688
|
+
(values[2] instanceof fraction_1.Fraction || typeof values[2] === 'number')) {
|
|
4758
4689
|
return this.parseByCoefficient(values[0], values[1], values[2]);
|
|
4759
4690
|
}
|
|
4760
4691
|
else if (values[0] instanceof point_1.Point && values[1] instanceof vector_1.Vector) {
|
|
@@ -4792,11 +4723,11 @@ class Line {
|
|
|
4792
4723
|
return this.parseByCoefficient(equ.left.monomByLetter('x').coefficient, equ.left.monomByLetter('y').coefficient, equ.left.monomByDegree(0).coefficient);
|
|
4793
4724
|
};
|
|
4794
4725
|
this.parseByCoefficient = (a, b, c) => {
|
|
4795
|
-
this._a = new
|
|
4796
|
-
this._b = new
|
|
4797
|
-
this._c = new
|
|
4726
|
+
this._a = new fraction_1.Fraction(a);
|
|
4727
|
+
this._b = new fraction_1.Fraction(b);
|
|
4728
|
+
this._c = new fraction_1.Fraction(c);
|
|
4798
4729
|
this._d = new vector_1.Vector(this._b.clone(), this._a.clone().opposed());
|
|
4799
|
-
this._OA = new point_1.Point(new
|
|
4730
|
+
this._OA = new point_1.Point(new fraction_1.Fraction().zero(), this._c.clone());
|
|
4800
4731
|
this._n = this._d.clone().normal();
|
|
4801
4732
|
this._exists = true;
|
|
4802
4733
|
return this;
|
|
@@ -4913,15 +4844,15 @@ class Line {
|
|
|
4913
4844
|
};
|
|
4914
4845
|
};
|
|
4915
4846
|
this.getValueAtX = (value) => {
|
|
4916
|
-
const equ = this.equation.clone().isolate('y'), F = new
|
|
4917
|
-
if (equ instanceof
|
|
4847
|
+
const equ = this.equation.clone().isolate('y'), F = new fraction_1.Fraction(value);
|
|
4848
|
+
if (equ instanceof equation_1.Equation) {
|
|
4918
4849
|
return equ.right.evaluate({ x: F });
|
|
4919
4850
|
}
|
|
4920
4851
|
return;
|
|
4921
4852
|
};
|
|
4922
4853
|
this.getValueAtY = (value) => {
|
|
4923
|
-
const equ = this.equation.clone().isolate('x'), F = new
|
|
4924
|
-
if (equ instanceof
|
|
4854
|
+
const equ = this.equation.clone().isolate('x'), F = new fraction_1.Fraction(value);
|
|
4855
|
+
if (equ instanceof equation_1.Equation) {
|
|
4925
4856
|
return equ.right.evaluate({ y: F });
|
|
4926
4857
|
}
|
|
4927
4858
|
return;
|
|
@@ -4939,7 +4870,7 @@ class Line {
|
|
|
4939
4870
|
// Getter and setter
|
|
4940
4871
|
// ------------------------------------------
|
|
4941
4872
|
get equation() {
|
|
4942
|
-
return new
|
|
4873
|
+
return new equation_1.Equation(new polynom_1.Polynom().parse('xy', this._a, this._b, this._c), new polynom_1.Polynom('0')).simplify();
|
|
4943
4874
|
}
|
|
4944
4875
|
get tex() {
|
|
4945
4876
|
// canonical => ax + by + c = 0
|
|
@@ -4952,7 +4883,7 @@ class Line {
|
|
|
4952
4883
|
}
|
|
4953
4884
|
return {
|
|
4954
4885
|
canonical: canonical.tex,
|
|
4955
|
-
mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new
|
|
4886
|
+
mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new polynom_1.Polynom().parse('x', this.slope, this.height).tex,
|
|
4956
4887
|
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)}`
|
|
4957
4888
|
};
|
|
4958
4889
|
}
|
|
@@ -5010,7 +4941,7 @@ class Line {
|
|
|
5010
4941
|
return {
|
|
5011
4942
|
value: NaN,
|
|
5012
4943
|
tex: 'Not a line',
|
|
5013
|
-
fraction: new
|
|
4944
|
+
fraction: new fraction_1.Fraction().infinite()
|
|
5014
4945
|
};
|
|
5015
4946
|
}
|
|
5016
4947
|
// The denominator is a perfect square - simplify the tex result
|
|
@@ -5092,9 +5023,9 @@ exports.Point = void 0;
|
|
|
5092
5023
|
* Vector module contains everything necessary to handle 2d or 3d vectors.
|
|
5093
5024
|
* @module Vector
|
|
5094
5025
|
*/
|
|
5095
|
-
const coefficients_1 = __webpack_require__(534);
|
|
5096
5026
|
const line_1 = __webpack_require__(9);
|
|
5097
5027
|
const vector_1 = __webpack_require__(586);
|
|
5028
|
+
const fraction_1 = __webpack_require__(506);
|
|
5098
5029
|
/**
|
|
5099
5030
|
* Helper class - a way to identify an object {x: number, y: number}
|
|
5100
5031
|
*/
|
|
@@ -5124,15 +5055,15 @@ class Point {
|
|
|
5124
5055
|
if (typeof values[0] === 'string') {
|
|
5125
5056
|
let xy = values[0].split(',');
|
|
5126
5057
|
if (xy.length === 2) {
|
|
5127
|
-
this._x = new
|
|
5128
|
-
this._y = new
|
|
5058
|
+
this._x = new fraction_1.Fraction(xy[0]).reduce();
|
|
5059
|
+
this._y = new fraction_1.Fraction(xy[1]).reduce();
|
|
5129
5060
|
return this;
|
|
5130
5061
|
}
|
|
5131
5062
|
}
|
|
5132
5063
|
// Value given as an object with {x: value, y: value}
|
|
5133
5064
|
if (values[0] instanceof PointXY) {
|
|
5134
|
-
this._x = new
|
|
5135
|
-
this._y = new
|
|
5065
|
+
this._x = new fraction_1.Fraction(values[0].x).reduce();
|
|
5066
|
+
this._y = new fraction_1.Fraction(values[0].y).reduce();
|
|
5136
5067
|
return this;
|
|
5137
5068
|
}
|
|
5138
5069
|
else {
|
|
@@ -5140,8 +5071,8 @@ class Point {
|
|
|
5140
5071
|
}
|
|
5141
5072
|
}
|
|
5142
5073
|
if (values.length === 2) {
|
|
5143
|
-
this._x = new
|
|
5144
|
-
this._y = new
|
|
5074
|
+
this._x = new fraction_1.Fraction(values[0]).reduce();
|
|
5075
|
+
this._y = new fraction_1.Fraction(values[1]).reduce();
|
|
5145
5076
|
return this;
|
|
5146
5077
|
}
|
|
5147
5078
|
return this;
|
|
@@ -5152,8 +5083,8 @@ class Point {
|
|
|
5152
5083
|
return this;
|
|
5153
5084
|
};
|
|
5154
5085
|
this.zero = () => {
|
|
5155
|
-
this._x = new
|
|
5156
|
-
this._y = new
|
|
5086
|
+
this._x = new fraction_1.Fraction(null);
|
|
5087
|
+
this._y = new fraction_1.Fraction(null);
|
|
5157
5088
|
return this;
|
|
5158
5089
|
};
|
|
5159
5090
|
this.origin = () => {
|
|
@@ -5175,7 +5106,7 @@ class Point {
|
|
|
5175
5106
|
return `\\left(${pts.join(';')}\\right)`;
|
|
5176
5107
|
};
|
|
5177
5108
|
this.distanceTo = (item) => {
|
|
5178
|
-
let value = 0, fraction = new
|
|
5109
|
+
let value = 0, fraction = new fraction_1.Fraction(), tex = '';
|
|
5179
5110
|
if (item instanceof line_1.Line) {
|
|
5180
5111
|
return item.distanceTo(this);
|
|
5181
5112
|
}
|
|
@@ -5191,8 +5122,8 @@ class Point {
|
|
|
5191
5122
|
const keyList = list.map(x => x.key);
|
|
5192
5123
|
return keyList.includes(this.key);
|
|
5193
5124
|
};
|
|
5194
|
-
this._x = new
|
|
5195
|
-
this._y = new
|
|
5125
|
+
this._x = new fraction_1.Fraction().zero();
|
|
5126
|
+
this._y = new fraction_1.Fraction().zero();
|
|
5196
5127
|
if (values !== undefined) {
|
|
5197
5128
|
this.parse(...values);
|
|
5198
5129
|
}
|
|
@@ -5823,7 +5754,7 @@ exports.Numeric = Numeric;
|
|
|
5823
5754
|
|
|
5824
5755
|
/***/ }),
|
|
5825
5756
|
|
|
5826
|
-
/***/
|
|
5757
|
+
/***/ 330:
|
|
5827
5758
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
5828
5759
|
|
|
5829
5760
|
|
|
@@ -5843,11 +5774,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
5843
5774
|
};
|
|
5844
5775
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5845
5776
|
exports.Random = void 0;
|
|
5846
|
-
const rndPolynom_1 = __webpack_require__(
|
|
5847
|
-
const rndMonom_1 = __webpack_require__(
|
|
5848
|
-
const rndHelpers_1 = __webpack_require__(
|
|
5849
|
-
const rndFraction_1 = __webpack_require__(
|
|
5850
|
-
__exportStar(__webpack_require__(
|
|
5777
|
+
const rndPolynom_1 = __webpack_require__(22);
|
|
5778
|
+
const rndMonom_1 = __webpack_require__(793);
|
|
5779
|
+
const rndHelpers_1 = __webpack_require__(140);
|
|
5780
|
+
const rndFraction_1 = __webpack_require__(754);
|
|
5781
|
+
__exportStar(__webpack_require__(230), exports);
|
|
5851
5782
|
var Random;
|
|
5852
5783
|
(function (Random) {
|
|
5853
5784
|
function polynom(config) {
|
|
@@ -5891,7 +5822,7 @@ var Random;
|
|
|
5891
5822
|
|
|
5892
5823
|
/***/ }),
|
|
5893
5824
|
|
|
5894
|
-
/***/
|
|
5825
|
+
/***/ 373:
|
|
5895
5826
|
/***/ ((__unused_webpack_module, exports) => {
|
|
5896
5827
|
|
|
5897
5828
|
|
|
@@ -5919,15 +5850,15 @@ exports.randomCore = randomCore;
|
|
|
5919
5850
|
|
|
5920
5851
|
/***/ }),
|
|
5921
5852
|
|
|
5922
|
-
/***/
|
|
5853
|
+
/***/ 754:
|
|
5923
5854
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
5924
5855
|
|
|
5925
5856
|
|
|
5926
5857
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5927
5858
|
exports.rndFraction = void 0;
|
|
5928
|
-
const randomCore_1 = __webpack_require__(
|
|
5929
|
-
const
|
|
5930
|
-
const
|
|
5859
|
+
const randomCore_1 = __webpack_require__(373);
|
|
5860
|
+
const random_1 = __webpack_require__(330);
|
|
5861
|
+
const fraction_1 = __webpack_require__(506);
|
|
5931
5862
|
/**
|
|
5932
5863
|
* Create a random monom based on a based configuration
|
|
5933
5864
|
*/
|
|
@@ -5935,18 +5866,18 @@ class rndFraction extends randomCore_1.randomCore {
|
|
|
5935
5866
|
constructor(userConfig) {
|
|
5936
5867
|
super();
|
|
5937
5868
|
this.generate = () => {
|
|
5938
|
-
let Q = new
|
|
5869
|
+
let Q = new fraction_1.Fraction();
|
|
5939
5870
|
if (this._config.negative) {
|
|
5940
|
-
Q.numerator =
|
|
5871
|
+
Q.numerator = random_1.Random.numberSym(this._config.max, this._config.zero);
|
|
5941
5872
|
}
|
|
5942
5873
|
else {
|
|
5943
|
-
Q.numerator =
|
|
5874
|
+
Q.numerator = random_1.Random.number(this._config.zero ? 0 : 1, this._config.max);
|
|
5944
5875
|
}
|
|
5945
5876
|
if (this._config.natural) {
|
|
5946
5877
|
Q.denominator = 1;
|
|
5947
5878
|
}
|
|
5948
5879
|
else {
|
|
5949
|
-
Q.denominator =
|
|
5880
|
+
Q.denominator = random_1.Random.number(1, this._config.max);
|
|
5950
5881
|
}
|
|
5951
5882
|
return this._config.reduced ? Q.reduce() : Q;
|
|
5952
5883
|
};
|
|
@@ -5965,7 +5896,7 @@ exports.rndFraction = rndFraction;
|
|
|
5965
5896
|
|
|
5966
5897
|
/***/ }),
|
|
5967
5898
|
|
|
5968
|
-
/***/
|
|
5899
|
+
/***/ 140:
|
|
5969
5900
|
/***/ ((__unused_webpack_module, exports) => {
|
|
5970
5901
|
|
|
5971
5902
|
|
|
@@ -6040,15 +5971,15 @@ exports.rndHelpers = rndHelpers;
|
|
|
6040
5971
|
|
|
6041
5972
|
/***/ }),
|
|
6042
5973
|
|
|
6043
|
-
/***/
|
|
5974
|
+
/***/ 793:
|
|
6044
5975
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
6045
5976
|
|
|
6046
5977
|
|
|
6047
5978
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6048
5979
|
exports.rndMonom = void 0;
|
|
6049
|
-
const randomCore_1 = __webpack_require__(
|
|
6050
|
-
const
|
|
6051
|
-
const
|
|
5980
|
+
const randomCore_1 = __webpack_require__(373);
|
|
5981
|
+
const random_1 = __webpack_require__(330);
|
|
5982
|
+
const monom_1 = __webpack_require__(937);
|
|
6052
5983
|
/**
|
|
6053
5984
|
* Create a random monom based on a based configuration
|
|
6054
5985
|
*/
|
|
@@ -6057,17 +5988,17 @@ class rndMonom extends randomCore_1.randomCore {
|
|
|
6057
5988
|
super();
|
|
6058
5989
|
this.generate = () => {
|
|
6059
5990
|
// Create a monom instance
|
|
6060
|
-
let M = new
|
|
5991
|
+
let M = new monom_1.Monom();
|
|
6061
5992
|
// Generate the coefficient
|
|
6062
5993
|
if (typeof this._config.fraction === "boolean") {
|
|
6063
|
-
M.coefficient =
|
|
5994
|
+
M.coefficient = random_1.Random.fraction({
|
|
6064
5995
|
zero: this._config.zero,
|
|
6065
5996
|
reduced: true,
|
|
6066
5997
|
natural: !this._config.fraction
|
|
6067
5998
|
});
|
|
6068
5999
|
}
|
|
6069
6000
|
else {
|
|
6070
|
-
M.coefficient =
|
|
6001
|
+
M.coefficient = random_1.Random.fraction(this._config.fraction);
|
|
6071
6002
|
}
|
|
6072
6003
|
// Calculate the degree of the monom
|
|
6073
6004
|
if (this._config.letters.length > 1) {
|
|
@@ -6076,7 +6007,7 @@ class rndMonom extends randomCore_1.randomCore {
|
|
|
6076
6007
|
M.setLetter(L, 0);
|
|
6077
6008
|
}
|
|
6078
6009
|
for (let i = 0; i < this._config.degree; i++) {
|
|
6079
|
-
const L =
|
|
6010
|
+
const L = random_1.Random.item(this._config.letters.split(""));
|
|
6080
6011
|
M.setLetter(L, M.degree(L).clone().add(1));
|
|
6081
6012
|
}
|
|
6082
6013
|
}
|
|
@@ -6099,16 +6030,16 @@ exports.rndMonom = rndMonom;
|
|
|
6099
6030
|
|
|
6100
6031
|
/***/ }),
|
|
6101
6032
|
|
|
6102
|
-
/***/
|
|
6033
|
+
/***/ 22:
|
|
6103
6034
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
6104
6035
|
|
|
6105
6036
|
|
|
6106
6037
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6107
6038
|
exports.rndPolynom = void 0;
|
|
6108
|
-
const randomCore_1 = __webpack_require__(
|
|
6109
|
-
const rndMonom_1 = __webpack_require__(
|
|
6110
|
-
const
|
|
6111
|
-
const
|
|
6039
|
+
const randomCore_1 = __webpack_require__(373);
|
|
6040
|
+
const rndMonom_1 = __webpack_require__(793);
|
|
6041
|
+
const random_1 = __webpack_require__(330);
|
|
6042
|
+
const polynom_1 = __webpack_require__(38);
|
|
6112
6043
|
/**
|
|
6113
6044
|
* Random polynoms
|
|
6114
6045
|
*/
|
|
@@ -6120,7 +6051,7 @@ class rndPolynom extends randomCore_1.randomCore {
|
|
|
6120
6051
|
return this.factorable();
|
|
6121
6052
|
}
|
|
6122
6053
|
// Create the polynom
|
|
6123
|
-
let P = new
|
|
6054
|
+
let P = new polynom_1.Polynom().empty(), M;
|
|
6124
6055
|
for (let i = this._config.degree; i >= 0; i--) {
|
|
6125
6056
|
// Create monom of corresponding degree.
|
|
6126
6057
|
M = new rndMonom_1.rndMonom({
|
|
@@ -6144,18 +6075,18 @@ class rndPolynom extends randomCore_1.randomCore {
|
|
|
6144
6075
|
if (this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < P.length) {
|
|
6145
6076
|
// Get the greatest degree monom
|
|
6146
6077
|
let M = P.monomByDegree().clone();
|
|
6147
|
-
P.monoms =
|
|
6078
|
+
P.monoms = random_1.Random.array(P.monoms.slice(1), this._config.numberOfMonoms - 1);
|
|
6148
6079
|
P.add(M).reorder().reduce();
|
|
6149
6080
|
}
|
|
6150
6081
|
return P;
|
|
6151
6082
|
};
|
|
6152
6083
|
this.factorable = () => {
|
|
6153
|
-
let P = new
|
|
6084
|
+
let P = new polynom_1.Polynom().one();
|
|
6154
6085
|
let _factorableConfig = { ...this._config };
|
|
6155
6086
|
_factorableConfig.degree = 1;
|
|
6156
6087
|
_factorableConfig.factorable = false;
|
|
6157
6088
|
for (let i = 0; i < this._config.degree; i++) {
|
|
6158
|
-
P.multiply(
|
|
6089
|
+
P.multiply(random_1.Random.polynom(_factorableConfig));
|
|
6159
6090
|
}
|
|
6160
6091
|
return P;
|
|
6161
6092
|
};
|
|
@@ -6180,7 +6111,7 @@ exports.rndPolynom = rndPolynom;
|
|
|
6180
6111
|
|
|
6181
6112
|
/***/ }),
|
|
6182
6113
|
|
|
6183
|
-
/***/
|
|
6114
|
+
/***/ 230:
|
|
6184
6115
|
/***/ ((__unused_webpack_module, exports) => {
|
|
6185
6116
|
|
|
6186
6117
|
|