pimath 0.0.119 → 0.0.121
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/.idea/PI.iml +7 -1
- package/dev/pimath.js +7929 -0
- package/dev/pimath.js.map +1 -0
- package/dist/{pi.js → pimath.js} +7612 -7829
- package/dist/pimath.js.map +1 -0
- package/dist/pimath.min.js +2 -0
- package/dist/pimath.min.js.map +1 -0
- package/docs/assets/main.js +3 -3
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +450 -363
- package/docs/classes/Logicalset.Logicalset.html +119 -110
- package/docs/classes/Polynom.Rational.html +230 -227
- package/docs/classes/Vector-1.Vector.html +319 -273
- package/docs/classes/Vector.Point.html +189 -190
- package/docs/classes/algebra_equation.Equation.html +489 -446
- package/docs/classes/algebra_linearSystem.LinearSystem.html +228 -217
- package/docs/classes/algebra_monom.Monom.html +564 -507
- package/docs/classes/algebra_polynom.Polynom.html +774 -753
- package/docs/classes/coefficients_fraction.Fraction.html +573 -565
- package/docs/classes/geometry_circle.Circle.html +299 -299
- package/docs/classes/geometry_line.Line.html +511 -451
- package/docs/classes/geometry_triangle.Triangle.html +273 -264
- package/docs/classes/numeric.Numeric.html +138 -132
- package/docs/classes/shutingyard.Shutingyard.html +144 -133
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +47 -46
- package/docs/enums/geometry_line.LinePropriety.html +58 -58
- package/docs/enums/shutingyard.ShutingyardMode.html +62 -58
- package/docs/enums/shutingyard.ShutingyardType.html +74 -70
- package/docs/index.html +31 -33
- package/docs/interfaces/algebra_equation.ISolution.html +61 -59
- package/docs/interfaces/algebra_polynom.IEuclidian.html +47 -46
- package/docs/interfaces/geometry_triangle.remarquableLines.html +74 -74
- package/docs/modules/Logicalset.html +33 -38
- package/docs/modules/Polynom.html +33 -38
- package/docs/modules/Vector-1.html +33 -38
- package/docs/modules/Vector.html +33 -38
- package/docs/modules/algebra_equation.html +35 -41
- package/docs/modules/algebra_linearSystem.html +31 -37
- package/docs/modules/algebra_monom.html +33 -39
- package/docs/modules/algebra_polynom.html +35 -41
- package/docs/modules/coefficients_fraction.html +33 -39
- package/docs/modules/geometry_circle.html +31 -37
- package/docs/modules/geometry_line.html +33 -39
- package/docs/modules/geometry_triangle.html +33 -39
- package/docs/modules/numeric.html +31 -37
- package/docs/modules/shutingyard.html +41 -47
- package/docs/types/algebra_monom.literalType.html +33 -37
- package/docs/types/algebra_polynom.PolynomParsingType.html +33 -37
- package/docs/types/coefficients_fraction.FractionParsingType.html +32 -36
- package/docs/types/shutingyard.Token.html +38 -42
- package/docs/types/shutingyard.tokenType.html +40 -44
- package/docs/variables/shutingyard.tokenConstant.html +37 -41
- package/esm/index.d.ts +38 -41
- package/esm/index.js +43 -46
- package/esm/index.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +119 -117
- package/esm/maths/algebra/equation.js +796 -785
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +39 -38
- package/esm/maths/algebra/linearSystem.js +278 -262
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.d.ts +28 -28
- package/esm/maths/algebra/logicalset.js +157 -157
- package/esm/maths/algebra/monom.d.ts +206 -206
- package/esm/maths/algebra/monom.js +908 -908
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +157 -157
- package/esm/maths/algebra/polynom.js +1277 -1277
- package/esm/maths/algebra/rational.d.ts +45 -45
- package/esm/maths/algebra/rational.js +183 -183
- package/esm/maths/algebra/study/rationalStudy.d.ts +28 -28
- package/esm/maths/algebra/study/rationalStudy.js +243 -243
- package/esm/maths/algebra/study.d.ts +142 -142
- package/esm/maths/algebra/study.js +377 -377
- package/esm/maths/algebra/study.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +90 -90
- package/esm/maths/coefficients/fraction.js +516 -516
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/nthRoot.d.ts +23 -23
- package/esm/maths/coefficients/nthRoot.js +136 -136
- package/esm/maths/geometry/circle.d.ts +45 -45
- package/esm/maths/geometry/circle.js +323 -323
- package/esm/maths/geometry/line.d.ts +99 -99
- package/esm/maths/geometry/line.js +481 -481
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +34 -34
- package/esm/maths/geometry/point.js +166 -166
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +85 -85
- package/esm/maths/geometry/triangle.js +268 -268
- package/esm/maths/geometry/vector.d.ts +41 -41
- package/esm/maths/geometry/vector.js +197 -197
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/numeric.d.ts +28 -28
- package/esm/maths/numeric.js +180 -169
- package/esm/maths/numeric.js.map +1 -1
- package/esm/maths/numexp.d.ts +19 -0
- package/esm/maths/numexp.js +186 -0
- package/esm/maths/numexp.js.map +1 -0
- package/esm/maths/randomization/random.d.ts +23 -23
- package/esm/maths/randomization/random.js +78 -78
- package/esm/maths/randomization/random.js.map +1 -1
- package/esm/maths/randomization/randomCore.d.ts +7 -7
- package/esm/maths/randomization/randomCore.js +21 -21
- package/esm/maths/randomization/rndFraction.d.ts +12 -12
- package/esm/maths/randomization/rndFraction.js +43 -43
- package/esm/maths/randomization/rndGeometryLine.d.ts +12 -12
- package/esm/maths/randomization/rndGeometryLine.js +45 -45
- package/esm/maths/randomization/rndGeometryPoint.d.ts +12 -12
- package/esm/maths/randomization/rndGeometryPoint.js +60 -60
- package/esm/maths/randomization/rndHelpers.d.ts +23 -23
- package/esm/maths/randomization/rndHelpers.js +76 -76
- package/esm/maths/randomization/rndMonom.d.ts +12 -12
- package/esm/maths/randomization/rndMonom.js +52 -52
- package/esm/maths/randomization/rndPolynom.d.ts +13 -13
- package/esm/maths/randomization/rndPolynom.js +74 -74
- package/esm/maths/randomization/rndTypes.d.ts +34 -34
- package/esm/maths/randomization/rndTypes.js +2 -2
- package/esm/maths/shutingyard.d.ts +59 -59
- package/esm/maths/shutingyard.js +442 -442
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +11 -11
- package/public/index.html +50 -81
- package/public/playground.html +7 -8
- package/src/index.ts +2 -5
- package/src/maths/algebra/equation.ts +16 -0
- package/src/maths/algebra/linearSystem.ts +20 -0
- package/src/maths/algebra/study.ts +1 -1
- package/src/maths/numeric.ts +49 -48
- package/src/maths/{expressions/numexp.ts → numexp.ts} +2 -2
- package/tests/algebra/equation.test.ts +19 -5
- package/tests/algebra/linear.test.ts +3 -11
- package/tests/algebra/polynom.test.ts +7 -8
- package/tests/algebra/rationnal.test.ts +1 -1
- package/tests/algebra/study.test.ts +2 -9
- package/tests/coefficients/fraction.test.ts +8 -8
- package/tests/custom.test.ts +33 -37
- package/tests/numeric.test.ts +1 -2
- package/tests/numexp.test.ts +1 -5
- package/tests/shutingyard.test.ts +3 -3
- package/webpack-production-min.config.js +1 -1
- package/webpack-production.config.js +1 -1
- package/webpack.config.js +1 -1
- package/dist/pi.js.map +0 -1
- package/dist/pi.min.js +0 -2
- package/dist/pi.min.js.map +0 -1
- package/docs/classes/expressions_numexp.NumExp.html +0 -236
- package/docs/classes/expressions_polynomexp.PolynomExpFactor.html +0 -317
- package/docs/classes/expressions_polynomexp.PolynomExpProduct.html +0 -285
- package/docs/modules/expressions_numexp.html +0 -71
- package/docs/modules/expressions_polynomexp.html +0 -73
- package/docs/modules.html +0 -76
- package/graph.svg +0 -1033
- package/src/maths/expressions/ExpressionTree.ts +0 -172
- package/src/maths/expressions/expression.ts +0 -286
- package/src/maths/expressions/expressionFactor.ts +0 -190
- package/src/maths/expressions/expressionMember.ts +0 -233
- package/src/maths/expressions/expressionOperators.ts +0 -49
- package/src/maths/expressions/expressionParser.ts +0 -295
- package/src/maths/expressions/factors/ExpFactor.ts +0 -39
- package/src/maths/expressions/factors/ExpFactorConstant.ts +0 -60
- package/src/maths/expressions/factors/ExpFactorExponential.ts +0 -26
- package/src/maths/expressions/factors/ExpFactorNumber.ts +0 -72
- package/src/maths/expressions/factors/ExpFactorPower.ts +0 -42
- package/src/maths/expressions/factors/ExpFactorTrigo.ts +0 -53
- package/src/maths/expressions/factors/ExpFactorVariable.ts +0 -45
- package/src/maths/expressions/internals.ts +0 -14
- package/src/maths/expressions/polynomexp.bkp.ts +0 -221
- package/src/maths/expressions/polynomexp.ts +0 -310
- package/tests/expressions/expressions.test.ts +0 -145
- package/tests/expressions/expressiontree.test.ts +0 -11
- package/tests/polynomexp.test.ts +0 -12
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rndPolynom = void 0;
|
|
4
|
-
const randomCore_1 = require("./randomCore");
|
|
5
|
-
const rndMonom_1 = require("./rndMonom");
|
|
6
|
-
const random_1 = require("./random");
|
|
7
|
-
const polynom_1 = require("../algebra/polynom");
|
|
8
|
-
/**
|
|
9
|
-
* Random polynoms
|
|
10
|
-
*/
|
|
11
|
-
class rndPolynom extends randomCore_1.randomCore {
|
|
12
|
-
constructor(userConfig) {
|
|
13
|
-
super();
|
|
14
|
-
this.generate = () => {
|
|
15
|
-
if (this._config.factorable && this._config.degree > 1) {
|
|
16
|
-
return this.factorable();
|
|
17
|
-
}
|
|
18
|
-
// Create the polynom
|
|
19
|
-
let P = new polynom_1.Polynom().empty(), M;
|
|
20
|
-
for (let i = this._config.degree; i >= 0; i--) {
|
|
21
|
-
// Create monom of corresponding degree.
|
|
22
|
-
M = new rndMonom_1.rndMonom({
|
|
23
|
-
letters: this._config.letters,
|
|
24
|
-
degree: i,
|
|
25
|
-
fraction: this._config.fraction,
|
|
26
|
-
zero: (i === this._config.degree) ? false : this._config.allowNullMonom
|
|
27
|
-
}).generate();
|
|
28
|
-
// If degree is the greatest and unit is true, set the monom value to one.
|
|
29
|
-
if (this._config.unit && this._config.degree === i) {
|
|
30
|
-
M.coefficient.one();
|
|
31
|
-
}
|
|
32
|
-
// Add to the polynom
|
|
33
|
-
P.add(M);
|
|
34
|
-
}
|
|
35
|
-
// Make sure the first monom is positive.
|
|
36
|
-
if (this._config.positive && P.monomByDegree().coefficient.isNegative()) {
|
|
37
|
-
P.monomByDegree().coefficient.opposed();
|
|
38
|
-
}
|
|
39
|
-
// If the number of monoms is greater than the allowed value, remove some of them... except the first one !
|
|
40
|
-
if (this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < P.length) {
|
|
41
|
-
// Get the greatest degree monom
|
|
42
|
-
let M = P.monomByDegree().clone();
|
|
43
|
-
P.monoms = random_1.Random.array(P.monoms.slice(1), this._config.numberOfMonoms - 1);
|
|
44
|
-
P.add(M).reorder().reduce();
|
|
45
|
-
}
|
|
46
|
-
return P;
|
|
47
|
-
};
|
|
48
|
-
this.factorable = () => {
|
|
49
|
-
let P = new polynom_1.Polynom().one();
|
|
50
|
-
let _factorableConfig = { ...this._config };
|
|
51
|
-
_factorableConfig.degree = 1;
|
|
52
|
-
_factorableConfig.factorable = false;
|
|
53
|
-
for (let i = 0; i < this._config.degree; i++) {
|
|
54
|
-
P.multiply(random_1.Random.polynom(_factorableConfig));
|
|
55
|
-
}
|
|
56
|
-
return P;
|
|
57
|
-
};
|
|
58
|
-
// Default config for a random polynom
|
|
59
|
-
this._defaultConfig = {
|
|
60
|
-
letters: 'x',
|
|
61
|
-
degree: 2,
|
|
62
|
-
fraction: false,
|
|
63
|
-
zero: false,
|
|
64
|
-
unit: false,
|
|
65
|
-
factorable: false,
|
|
66
|
-
allowNullMonom: true,
|
|
67
|
-
numberOfMonoms: 0,
|
|
68
|
-
positive: true
|
|
69
|
-
};
|
|
70
|
-
// Merge config with initialiser
|
|
71
|
-
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.rndPolynom = rndPolynom;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rndPolynom = void 0;
|
|
4
|
+
const randomCore_1 = require("./randomCore");
|
|
5
|
+
const rndMonom_1 = require("./rndMonom");
|
|
6
|
+
const random_1 = require("./random");
|
|
7
|
+
const polynom_1 = require("../algebra/polynom");
|
|
8
|
+
/**
|
|
9
|
+
* Random polynoms
|
|
10
|
+
*/
|
|
11
|
+
class rndPolynom extends randomCore_1.randomCore {
|
|
12
|
+
constructor(userConfig) {
|
|
13
|
+
super();
|
|
14
|
+
this.generate = () => {
|
|
15
|
+
if (this._config.factorable && this._config.degree > 1) {
|
|
16
|
+
return this.factorable();
|
|
17
|
+
}
|
|
18
|
+
// Create the polynom
|
|
19
|
+
let P = new polynom_1.Polynom().empty(), M;
|
|
20
|
+
for (let i = this._config.degree; i >= 0; i--) {
|
|
21
|
+
// Create monom of corresponding degree.
|
|
22
|
+
M = new rndMonom_1.rndMonom({
|
|
23
|
+
letters: this._config.letters,
|
|
24
|
+
degree: i,
|
|
25
|
+
fraction: this._config.fraction,
|
|
26
|
+
zero: (i === this._config.degree) ? false : this._config.allowNullMonom
|
|
27
|
+
}).generate();
|
|
28
|
+
// If degree is the greatest and unit is true, set the monom value to one.
|
|
29
|
+
if (this._config.unit && this._config.degree === i) {
|
|
30
|
+
M.coefficient.one();
|
|
31
|
+
}
|
|
32
|
+
// Add to the polynom
|
|
33
|
+
P.add(M);
|
|
34
|
+
}
|
|
35
|
+
// Make sure the first monom is positive.
|
|
36
|
+
if (this._config.positive && P.monomByDegree().coefficient.isNegative()) {
|
|
37
|
+
P.monomByDegree().coefficient.opposed();
|
|
38
|
+
}
|
|
39
|
+
// If the number of monoms is greater than the allowed value, remove some of them... except the first one !
|
|
40
|
+
if (this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < P.length) {
|
|
41
|
+
// Get the greatest degree monom
|
|
42
|
+
let M = P.monomByDegree().clone();
|
|
43
|
+
P.monoms = random_1.Random.array(P.monoms.slice(1), this._config.numberOfMonoms - 1);
|
|
44
|
+
P.add(M).reorder().reduce();
|
|
45
|
+
}
|
|
46
|
+
return P;
|
|
47
|
+
};
|
|
48
|
+
this.factorable = () => {
|
|
49
|
+
let P = new polynom_1.Polynom().one();
|
|
50
|
+
let _factorableConfig = { ...this._config };
|
|
51
|
+
_factorableConfig.degree = 1;
|
|
52
|
+
_factorableConfig.factorable = false;
|
|
53
|
+
for (let i = 0; i < this._config.degree; i++) {
|
|
54
|
+
P.multiply(random_1.Random.polynom(_factorableConfig));
|
|
55
|
+
}
|
|
56
|
+
return P;
|
|
57
|
+
};
|
|
58
|
+
// Default config for a random polynom
|
|
59
|
+
this._defaultConfig = {
|
|
60
|
+
letters: 'x',
|
|
61
|
+
degree: 2,
|
|
62
|
+
fraction: false,
|
|
63
|
+
zero: false,
|
|
64
|
+
unit: false,
|
|
65
|
+
factorable: false,
|
|
66
|
+
allowNullMonom: true,
|
|
67
|
+
numberOfMonoms: 0,
|
|
68
|
+
positive: true
|
|
69
|
+
};
|
|
70
|
+
// Merge config with initialiser
|
|
71
|
+
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.rndPolynom = rndPolynom;
|
|
75
75
|
//# sourceMappingURL=rndPolynom.js.map
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { Fraction } from "../coefficients/fraction";
|
|
2
|
-
export type randomCoefficientConfig = {
|
|
3
|
-
negative?: boolean;
|
|
4
|
-
max?: number;
|
|
5
|
-
reduced?: boolean;
|
|
6
|
-
zero?: boolean;
|
|
7
|
-
natural?: boolean;
|
|
8
|
-
};
|
|
9
|
-
export type randomMonomConfig = {
|
|
10
|
-
letters?: string;
|
|
11
|
-
degree?: number;
|
|
12
|
-
fraction?: boolean | randomCoefficientConfig;
|
|
13
|
-
zero?: boolean;
|
|
14
|
-
};
|
|
15
|
-
export type randomPolynomConfig = randomMonomConfig & {
|
|
16
|
-
unit?: boolean;
|
|
17
|
-
factorable?: boolean;
|
|
18
|
-
allowNullMonom?: boolean;
|
|
19
|
-
numberOfMonoms?: number;
|
|
20
|
-
positive?: boolean;
|
|
21
|
-
};
|
|
22
|
-
export type randomGeometryLineConfig = {
|
|
23
|
-
A: {
|
|
24
|
-
x: number | Fraction;
|
|
25
|
-
y: number | Fraction;
|
|
26
|
-
};
|
|
27
|
-
slope?: Fraction | string | number;
|
|
28
|
-
};
|
|
29
|
-
export type randomGeometryPointConfig = {
|
|
30
|
-
quadrant?: number;
|
|
31
|
-
axis?: string | boolean;
|
|
32
|
-
fraction?: boolean;
|
|
33
|
-
max?: number;
|
|
34
|
-
};
|
|
1
|
+
import { Fraction } from "../coefficients/fraction";
|
|
2
|
+
export type randomCoefficientConfig = {
|
|
3
|
+
negative?: boolean;
|
|
4
|
+
max?: number;
|
|
5
|
+
reduced?: boolean;
|
|
6
|
+
zero?: boolean;
|
|
7
|
+
natural?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type randomMonomConfig = {
|
|
10
|
+
letters?: string;
|
|
11
|
+
degree?: number;
|
|
12
|
+
fraction?: boolean | randomCoefficientConfig;
|
|
13
|
+
zero?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type randomPolynomConfig = randomMonomConfig & {
|
|
16
|
+
unit?: boolean;
|
|
17
|
+
factorable?: boolean;
|
|
18
|
+
allowNullMonom?: boolean;
|
|
19
|
+
numberOfMonoms?: number;
|
|
20
|
+
positive?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type randomGeometryLineConfig = {
|
|
23
|
+
A: {
|
|
24
|
+
x: number | Fraction;
|
|
25
|
+
y: number | Fraction;
|
|
26
|
+
};
|
|
27
|
+
slope?: Fraction | string | number;
|
|
28
|
+
};
|
|
29
|
+
export type randomGeometryPointConfig = {
|
|
30
|
+
quadrant?: number;
|
|
31
|
+
axis?: string | boolean;
|
|
32
|
+
fraction?: boolean;
|
|
33
|
+
max?: number;
|
|
34
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=rndTypes.js.map
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
export type tokenType = {
|
|
2
|
-
[key: string]: {
|
|
3
|
-
precedence: number;
|
|
4
|
-
associative: string;
|
|
5
|
-
type: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare const tokenConstant: {
|
|
9
|
-
[Key: string]: number;
|
|
10
|
-
};
|
|
11
|
-
export declare enum ShutingyardType {
|
|
12
|
-
VARIABLE = "variable",
|
|
13
|
-
COEFFICIENT = "coefficient",
|
|
14
|
-
OPERATION = "operation",
|
|
15
|
-
CONSTANT = "constant",
|
|
16
|
-
FUNCTION = "function",
|
|
17
|
-
MONOM = "monom"
|
|
18
|
-
}
|
|
19
|
-
export declare enum ShutingyardMode {
|
|
20
|
-
EXPRESSION = "expression",
|
|
21
|
-
POLYNOM = "polynom",
|
|
22
|
-
SET = "set",
|
|
23
|
-
NUMERIC = "numeric"
|
|
24
|
-
}
|
|
25
|
-
export type Token = {
|
|
26
|
-
token: string;
|
|
27
|
-
tokenType: string;
|
|
28
|
-
};
|
|
29
|
-
export declare class Shutingyard {
|
|
30
|
-
readonly _mode: ShutingyardMode;
|
|
31
|
-
private _rpn;
|
|
32
|
-
private _tokenConfig;
|
|
33
|
-
private _tokenConstant;
|
|
34
|
-
private _tokenKeys;
|
|
35
|
-
private _uniformize;
|
|
36
|
-
constructor(mode?: ShutingyardMode);
|
|
37
|
-
get rpn(): Token[];
|
|
38
|
-
get rpnToken(): string[];
|
|
39
|
-
/**
|
|
40
|
-
* Determin if the token is a defined operation
|
|
41
|
-
* Defined operations: + - * / ^ sin cos tan
|
|
42
|
-
* @param token
|
|
43
|
-
*/
|
|
44
|
-
tokenConfigInitialization(): tokenType;
|
|
45
|
-
/**
|
|
46
|
-
* Get the next token to analyse.
|
|
47
|
-
* @param expr (string) Expression to analyse
|
|
48
|
-
* @param start (number) CUrrent position in the expr string.
|
|
49
|
-
*/
|
|
50
|
-
NextToken(expr: string, start: number): [string, number, string];
|
|
51
|
-
normalize(expr: string): string;
|
|
52
|
-
/**
|
|
53
|
-
* Parse an expression using the shutting yard tree algorithms
|
|
54
|
-
* @param expr (string) Expression to analyse
|
|
55
|
-
* Returns a RPN list of items.
|
|
56
|
-
* @param uniformize
|
|
57
|
-
*/
|
|
58
|
-
parse(expr: string, uniformize?: boolean): Shutingyard;
|
|
59
|
-
}
|
|
1
|
+
export type tokenType = {
|
|
2
|
+
[key: string]: {
|
|
3
|
+
precedence: number;
|
|
4
|
+
associative: string;
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const tokenConstant: {
|
|
9
|
+
[Key: string]: number;
|
|
10
|
+
};
|
|
11
|
+
export declare enum ShutingyardType {
|
|
12
|
+
VARIABLE = "variable",
|
|
13
|
+
COEFFICIENT = "coefficient",
|
|
14
|
+
OPERATION = "operation",
|
|
15
|
+
CONSTANT = "constant",
|
|
16
|
+
FUNCTION = "function",
|
|
17
|
+
MONOM = "monom"
|
|
18
|
+
}
|
|
19
|
+
export declare enum ShutingyardMode {
|
|
20
|
+
EXPRESSION = "expression",
|
|
21
|
+
POLYNOM = "polynom",
|
|
22
|
+
SET = "set",
|
|
23
|
+
NUMERIC = "numeric"
|
|
24
|
+
}
|
|
25
|
+
export type Token = {
|
|
26
|
+
token: string;
|
|
27
|
+
tokenType: string;
|
|
28
|
+
};
|
|
29
|
+
export declare class Shutingyard {
|
|
30
|
+
readonly _mode: ShutingyardMode;
|
|
31
|
+
private _rpn;
|
|
32
|
+
private _tokenConfig;
|
|
33
|
+
private _tokenConstant;
|
|
34
|
+
private _tokenKeys;
|
|
35
|
+
private _uniformize;
|
|
36
|
+
constructor(mode?: ShutingyardMode);
|
|
37
|
+
get rpn(): Token[];
|
|
38
|
+
get rpnToken(): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Determin if the token is a defined operation
|
|
41
|
+
* Defined operations: + - * / ^ sin cos tan
|
|
42
|
+
* @param token
|
|
43
|
+
*/
|
|
44
|
+
tokenConfigInitialization(): tokenType;
|
|
45
|
+
/**
|
|
46
|
+
* Get the next token to analyse.
|
|
47
|
+
* @param expr (string) Expression to analyse
|
|
48
|
+
* @param start (number) CUrrent position in the expr string.
|
|
49
|
+
*/
|
|
50
|
+
NextToken(expr: string, start: number): [string, number, string];
|
|
51
|
+
normalize(expr: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Parse an expression using the shutting yard tree algorithms
|
|
54
|
+
* @param expr (string) Expression to analyse
|
|
55
|
+
* Returns a RPN list of items.
|
|
56
|
+
* @param uniformize
|
|
57
|
+
*/
|
|
58
|
+
parse(expr: string, uniformize?: boolean): Shutingyard;
|
|
59
|
+
}
|