pimath 0.0.54 → 0.0.57
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/.eslintrc.js +23 -23
- package/dist/pi.js +40 -11
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/docs/assets/highlight.css +78 -78
- package/docs/assets/main.js +52 -52
- package/docs/assets/style.css +1413 -1413
- package/docs/classes/Logicalset.Logicalset-1.html +4 -4
- package/docs/classes/Polynom.Rational.html +3 -3
- package/docs/classes/algebra_equation.Equation.html +25 -25
- package/docs/classes/algebra_monom.Monom.html +113 -113
- package/docs/classes/algebra_polynom.Polynom.html +29 -29
- package/docs/classes/coefficients_fraction.Fraction.html +18 -18
- package/docs/classes/coefficients_nthroot.NthRoot.html +2 -2
- package/docs/classes/geometry_circle.Circle.html +2 -2
- package/docs/classes/geometry_line.Line.html +2 -2
- package/docs/classes/geometry_triangle.Triangle.html +16 -16
- package/docs/classes/numeric.Numeric.html +13 -13
- package/docs/classes/shutingyard.Shutingyard.html +17 -17
- package/docs/index.html +10 -10
- package/docs/interfaces/algebra_equation.ISolution.html +2 -2
- package/docs/modules/Logicalset.html +2 -2
- package/docs/modules/Polynom.html +2 -2
- package/docs/modules/Vector.html +2 -2
- package/esm/maths/algebra/equation.js +4 -4
- package/esm/maths/algebra/equation.js.map +1 -10
- package/esm/maths/algebra/linearSystem.js.map +1 -10
- package/esm/maths/algebra/monom.d.ts +2 -6
- package/esm/maths/algebra/monom.js +11 -6
- package/esm/maths/algebra/monom.js.map +1 -10
- package/esm/maths/algebra/polynom.d.ts +4 -7
- package/esm/maths/algebra/polynom.js +34 -16
- package/esm/maths/algebra/polynom.js.map +1 -10
- package/esm/maths/algebra/rational.d.ts +1 -1
- package/esm/maths/algebra/rational.js +25 -4
- package/esm/maths/algebra/rational.js.map +1 -10
- package/esm/maths/expressions/polynomexp.bkp.js +1 -1
- package/esm/maths/expressions/polynomexp.bkp.js.map +1 -10
- package/esm/maths/expressions/polynomexp.js +2 -2
- package/esm/maths/expressions/polynomexp.js.map +1 -10
- package/esm/maths/geometry/point.js.map +1 -10
- package/esm/maths/randomization/random.js +1 -5
- package/esm/maths/randomization/random.js.map +1 -10
- package/package.json +1 -1
- package/public/index.html +1 -1
- package/public/matrices.html +100 -0
- package/src/maths/algebra/monom.ts +1 -2
- package/src/maths/algebra/polynom.ts +14 -8
- package/src/maths/algebra/rational.ts +26 -7
- package/tests/algebra/polynom.test.ts +13 -1
- package/tests/algebra/rationnal.test.ts +6 -0
package/.eslintrc.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es6": true
|
|
5
|
-
},
|
|
6
|
-
"extends": [
|
|
7
|
-
"eslint:recommended",
|
|
8
|
-
"plugin:@typescript-eslint/eslint-recommended"
|
|
9
|
-
],
|
|
10
|
-
"globals": {
|
|
11
|
-
"Atomics": "readonly",
|
|
12
|
-
"SharedArrayBuffer": "readonly"
|
|
13
|
-
},
|
|
14
|
-
"parser": "@typescript-eslint/parser",
|
|
15
|
-
"parserOptions": {
|
|
16
|
-
"ecmaVersion": 2018,
|
|
17
|
-
"sourceType": "module"
|
|
18
|
-
},
|
|
19
|
-
"plugins": [
|
|
20
|
-
"@typescript-eslint"
|
|
21
|
-
],
|
|
22
|
-
"rules": {
|
|
23
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": true,
|
|
4
|
+
"es6": true
|
|
5
|
+
},
|
|
6
|
+
"extends": [
|
|
7
|
+
"eslint:recommended",
|
|
8
|
+
"plugin:@typescript-eslint/eslint-recommended"
|
|
9
|
+
],
|
|
10
|
+
"globals": {
|
|
11
|
+
"Atomics": "readonly",
|
|
12
|
+
"SharedArrayBuffer": "readonly"
|
|
13
|
+
},
|
|
14
|
+
"parser": "@typescript-eslint/parser",
|
|
15
|
+
"parserOptions": {
|
|
16
|
+
"ecmaVersion": 2018,
|
|
17
|
+
"sourceType": "module"
|
|
18
|
+
},
|
|
19
|
+
"plugins": [
|
|
20
|
+
"@typescript-eslint"
|
|
21
|
+
],
|
|
22
|
+
"rules": {
|
|
23
|
+
}
|
|
24
24
|
};
|
package/dist/pi.js
CHANGED
|
@@ -1897,7 +1897,7 @@ class Monom {
|
|
|
1897
1897
|
return [this.clone()];
|
|
1898
1898
|
}
|
|
1899
1899
|
// Security : do not do this if greater than 10000
|
|
1900
|
-
if (this.coefficient.numerator >
|
|
1900
|
+
if (this.coefficient.numerator > 1000000) {
|
|
1901
1901
|
return [this.clone()];
|
|
1902
1902
|
}
|
|
1903
1903
|
const dividers = numeric_1.Numeric.dividers(Math.abs(this.coefficient.numerator));
|
|
@@ -2161,7 +2161,6 @@ class Polynom {
|
|
|
2161
2161
|
stack.push(stack.pop().opposed());
|
|
2162
2162
|
}
|
|
2163
2163
|
else {
|
|
2164
|
-
console.error('While parsing, cannot apply ', element.token, 'to', stack[0].tex);
|
|
2165
2164
|
throw "Error parsing the polynom " + this._rawString;
|
|
2166
2165
|
}
|
|
2167
2166
|
}
|
|
@@ -2368,9 +2367,13 @@ class Polynom {
|
|
|
2368
2367
|
const letter = P.variables[0];
|
|
2369
2368
|
const quotient = new Polynom().zero();
|
|
2370
2369
|
const reminder = this.clone().reorder(letter);
|
|
2371
|
-
// There is no variable
|
|
2370
|
+
// There is no variable - means it's a number
|
|
2372
2371
|
if (P.variables.length === 0) {
|
|
2373
|
-
|
|
2372
|
+
let q = this.clone().divide(P);
|
|
2373
|
+
return {
|
|
2374
|
+
quotient: this.clone().divide(P),
|
|
2375
|
+
reminder: new Polynom().zero()
|
|
2376
|
+
};
|
|
2374
2377
|
}
|
|
2375
2378
|
// Get at least a letter
|
|
2376
2379
|
const maxMP = P.monomByDegree(undefined, letter);
|
|
@@ -2400,6 +2403,11 @@ class Polynom {
|
|
|
2400
2403
|
else if (typeof value === 'number' && Number.isSafeInteger(value)) {
|
|
2401
2404
|
return this.divideByInteger(value);
|
|
2402
2405
|
}
|
|
2406
|
+
else if (value instanceof Polynom) {
|
|
2407
|
+
if (value.monoms.length === 1 && value.variables.length === 0) {
|
|
2408
|
+
return this.divideByFraction(value.monoms[0].coefficient);
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2403
2411
|
};
|
|
2404
2412
|
this.pow = (nb) => {
|
|
2405
2413
|
if (!Number.isSafeInteger(nb)) {
|
|
@@ -2666,8 +2674,7 @@ class Polynom {
|
|
|
2666
2674
|
let P = this.clone().reorder(), M = P.commonMonom(), tempPolynom;
|
|
2667
2675
|
// It has a common monom.
|
|
2668
2676
|
if (!M.isOne()) {
|
|
2669
|
-
tempPolynom = new Polynom();
|
|
2670
|
-
tempPolynom.monoms = [M];
|
|
2677
|
+
tempPolynom = new Polynom(M);
|
|
2671
2678
|
factors = [tempPolynom.clone()];
|
|
2672
2679
|
P = P.euclidian(tempPolynom).quotient;
|
|
2673
2680
|
}
|
|
@@ -2690,7 +2697,8 @@ class Polynom {
|
|
|
2690
2697
|
}
|
|
2691
2698
|
else {
|
|
2692
2699
|
// Get the first and last monom and build all their dividers.
|
|
2693
|
-
let m1 = P.monoms[0].dividers,
|
|
2700
|
+
// let m1 = P.monoms[0].dividers,
|
|
2701
|
+
// m2 = P.monoms[P.monoms.length - 1].dividers
|
|
2694
2702
|
// Create the list of all "potential" polynom dividers.
|
|
2695
2703
|
let allDividers = this._getAllPotentialFactors(P, letter);
|
|
2696
2704
|
allDividers.every(div => {
|
|
@@ -3430,7 +3438,7 @@ class Rational {
|
|
|
3430
3438
|
// Factorize the numerator and the denominator
|
|
3431
3439
|
this._numerator.factorize();
|
|
3432
3440
|
this._denominator.factorize();
|
|
3433
|
-
let zeroes = equation_1.Equation.makeSolutionsUnique([...this._numerator.getZeroes(), ...this._denominator.getZeroes()], true), NFactors = this._numerator.factors, DFactors = this._denominator.factors;
|
|
3441
|
+
let zeroes = equation_1.Equation.makeSolutionsUnique([...this._numerator.getZeroes(), ...this._denominator.getZeroes()], true).filter(x => !isNaN(x.value)), NFactors = this._numerator.factors, DFactors = this._denominator.factors;
|
|
3434
3442
|
let tableOfSigns = [], result = [];
|
|
3435
3443
|
NFactors.forEach(factor => {
|
|
3436
3444
|
tableOfSigns.push(this._makeOneLineOfTableOfSigns(factor, zeroes, 'z'));
|
|
@@ -3498,7 +3506,12 @@ class Rational {
|
|
|
3498
3506
|
let oneLine = [], currentZero = factor.getZeroes().map(x => x.tex);
|
|
3499
3507
|
// First +/- sign, before the first zero
|
|
3500
3508
|
oneLine.push('');
|
|
3501
|
-
|
|
3509
|
+
if (factor.degree().isZero()) {
|
|
3510
|
+
oneLine.push(factor.monoms[0].coefficient.sign() === 1 ? '+' : '-');
|
|
3511
|
+
}
|
|
3512
|
+
else {
|
|
3513
|
+
oneLine.push(factor.evaluate(zeroes[0].value - 1).sign() === 1 ? '+' : '-');
|
|
3514
|
+
}
|
|
3502
3515
|
for (let i = 0; i < zeroes.length; i++) {
|
|
3503
3516
|
// Add the zero if it's the current one
|
|
3504
3517
|
oneLine.push(currentZero.includes(zeroes[i].tex) ? zeroSign : 't');
|
|
@@ -3513,8 +3526,24 @@ class Rational {
|
|
|
3513
3526
|
oneLine.push('');
|
|
3514
3527
|
return oneLine;
|
|
3515
3528
|
};
|
|
3516
|
-
|
|
3517
|
-
|
|
3529
|
+
if (numerator instanceof polynom_1.Polynom) {
|
|
3530
|
+
this._numerator = numerator.clone();
|
|
3531
|
+
}
|
|
3532
|
+
else if (typeof numerator === 'string') {
|
|
3533
|
+
this._numerator = new polynom_1.Polynom(numerator);
|
|
3534
|
+
}
|
|
3535
|
+
else {
|
|
3536
|
+
this._numerator = new polynom_1.Polynom();
|
|
3537
|
+
}
|
|
3538
|
+
if (denominator instanceof polynom_1.Polynom) {
|
|
3539
|
+
this._denominator = denominator.clone();
|
|
3540
|
+
}
|
|
3541
|
+
else if (typeof denominator === 'string') {
|
|
3542
|
+
this._denominator = new polynom_1.Polynom(denominator);
|
|
3543
|
+
}
|
|
3544
|
+
else {
|
|
3545
|
+
this._denominator = new polynom_1.Polynom();
|
|
3546
|
+
}
|
|
3518
3547
|
}
|
|
3519
3548
|
get numerator() {
|
|
3520
3549
|
return this._numerator;
|