pimath 0.0.32 → 0.0.35
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 +6537 -1
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +2 -0
- package/dist/pi.min.js.map +1 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/algebra.Equation.html +9 -9
- package/docs/classes/algebra.LinearSystem.html +1 -1
- package/docs/classes/algebra.Logicalset.html +2 -2
- package/docs/classes/algebra.Monom.html +37 -37
- package/docs/classes/algebra.Polynom.html +10 -10
- package/docs/classes/algebra.PolynomExpFactor.html +1 -1
- package/docs/classes/algebra.PolynomExpProduct.html +1 -1
- package/docs/classes/algebra.Rational.html +2 -2
- package/docs/classes/coefficients.Fraction.html +4 -4
- package/docs/classes/coefficients.Nthroot.html +1 -1
- package/docs/classes/geometry.Circle.html +2 -2
- package/docs/classes/geometry.Line.html +2 -2
- package/docs/classes/geometry.Point.html +1 -1
- package/docs/classes/geometry.Triangle.html +5 -5
- package/docs/classes/geometry.Vector.html +1 -1
- package/docs/classes/numeric.Numeric.html +5 -5
- package/docs/classes/shutingyard.Shutingyard.html +4 -4
- package/docs/enums/geometry.LinePropriety.html +1 -0
- package/docs/enums/shutingyard.ShutingyardMode.html +1 -1
- package/docs/enums/shutingyard.ShutingyardType.html +1 -1
- package/docs/interfaces/geometry.remarquableLines.html +1 -1
- package/docs/modules/algebra.html +1 -1
- package/docs/modules/coefficients.html +1 -1
- package/docs/modules/geometry.html +1 -1
- package/docs/modules/random.Random.html +1 -1
- package/docs/modules/random.html +1 -1
- package/docs/modules/shutingyard.html +1 -1
- package/esm/main.d.ts +30 -1
- package/esm/main.js +4 -1
- package/esm/main.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +62 -17
- package/esm/maths/algebra/equation.js +597 -502
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/index.js +5 -1
- package/esm/maths/algebra/index.js.map +1 -1
- package/esm/maths/algebra/linearSystem.js +154 -101
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.d.ts +11 -0
- package/esm/maths/algebra/logicalset.js +18 -6
- package/esm/maths/algebra/logicalset.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +144 -0
- package/esm/maths/algebra/monom.js +626 -398
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +49 -0
- package/esm/maths/algebra/polynom.js +995 -712
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.d.ts +12 -0
- package/esm/maths/algebra/rational.js +97 -82
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +18 -0
- package/esm/maths/coefficients/fraction.js +390 -332
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/index.js +5 -1
- package/esm/maths/coefficients/index.js.map +1 -1
- package/esm/maths/coefficients/nthroot.d.ts +3 -0
- package/esm/maths/coefficients/nthroot.js +48 -33
- package/esm/maths/coefficients/nthroot.js.map +1 -1
- package/esm/maths/expressions/numexp.js +11 -3
- package/esm/maths/expressions/numexp.js.map +1 -1
- package/esm/maths/expressions/polynomexp.bkp.js +93 -93
- package/esm/maths/expressions/polynomexp.bkp.js.map +1 -1
- package/esm/maths/expressions/polynomexp.js +22 -9
- package/esm/maths/expressions/polynomexp.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +18 -6
- package/esm/maths/geometry/circle.js +139 -42
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/index.js +5 -1
- package/esm/maths/geometry/index.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +9 -2
- package/esm/maths/geometry/line.js +245 -188
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +12 -0
- package/esm/maths/geometry/point.js +121 -73
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +23 -1
- package/esm/maths/geometry/triangle.js +197 -158
- package/esm/maths/geometry/triangle.js.map +1 -1
- package/esm/maths/geometry/vector.d.ts +5 -1
- package/esm/maths/geometry/vector.js +139 -115
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/numeric.d.ts +17 -0
- package/esm/maths/numeric.js +40 -0
- package/esm/maths/numeric.js.map +1 -1
- package/esm/maths/random/index.js +5 -1
- package/esm/maths/random/index.js.map +1 -1
- package/esm/maths/random/randomCore.js +15 -15
- package/esm/maths/random/randomCore.js.map +1 -1
- package/esm/maths/random/rndFraction.d.ts +3 -0
- package/esm/maths/random/rndFraction.js +19 -16
- package/esm/maths/random/rndFraction.js.map +1 -1
- package/esm/maths/random/rndHelpers.d.ts +17 -0
- package/esm/maths/random/rndHelpers.js +20 -0
- package/esm/maths/random/rndHelpers.js.map +1 -1
- package/esm/maths/random/rndMonom.d.ts +3 -0
- package/esm/maths/random/rndMonom.js +33 -26
- package/esm/maths/random/rndMonom.js.map +1 -1
- package/esm/maths/random/rndPolynom.d.ts +3 -0
- package/esm/maths/random/rndPolynom.js +49 -37
- package/esm/maths/random/rndPolynom.js.map +1 -1
- package/esm/maths/shutingyard.d.ts +21 -0
- package/esm/maths/shutingyard.js +86 -9
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +2 -2
- package/public/index.html +47 -0
- package/src/main.ts +2 -2
- package/src/maths/algebra/equation.ts +142 -128
- package/src/maths/algebra/monom.ts +6 -2
- package/src/maths/algebra/polynom.ts +2 -7
- package/src/maths/geometry/circle.ts +168 -75
- package/src/maths/geometry/index.ts +1 -1
- package/src/maths/geometry/line.ts +1 -1
- package/src/maths/geometry/point.ts +25 -2
- package/src/maths/geometry/triangle.ts +1 -1
- package/src/maths/geometry/vector.ts +1 -1
- package/src/maths/numeric.ts +15 -0
- package/tests/algebra/polynom.test.ts +7 -0
- package/tests/geometry/circle.test.ts +33 -0
- package/tsconfig.json +2 -2
- package/webpack-production-min.config.js +26 -0
- package/webpack-production.config.js +1 -1
- package/dev/pi.js +0 -5392
- package/dev/pi.js.map +0 -1
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.randomCore = void 0;
|
|
4
4
|
class randomCore {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
5
|
+
constructor() {
|
|
6
|
+
this.mergeConfig = (config, defaultConfig) => {
|
|
7
|
+
if (config !== undefined) {
|
|
8
|
+
return { ...defaultConfig, ...config };
|
|
9
|
+
}
|
|
10
|
+
return defaultConfig;
|
|
11
|
+
};
|
|
12
|
+
this.generate = () => {
|
|
13
|
+
return undefined;
|
|
14
|
+
};
|
|
15
|
+
this.config = (config) => {
|
|
16
|
+
this._config = this.mergeConfig(config, this._defaultConfig);
|
|
17
|
+
return this;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
20
|
}
|
|
21
21
|
exports.randomCore = randomCore;
|
|
22
22
|
//# sourceMappingURL=randomCore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randomCore.js","sourceRoot":"","sources":["../../../src/maths/random/randomCore.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAU;
|
|
1
|
+
{"version":3,"file":"randomCore.js","sourceRoot":"","sources":["../../../src/maths/random/randomCore.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAU;IAAvB;QAGI,gBAAW,GAAG,CAAC,MAAc,EAAE,aAAqB,EAAU,EAAE;YAC5D,IAAI,MAAM,KAAK,SAAS,EAAE;gBACtB,OAAO,EAAC,GAAG,aAAa,EAAE,GAAG,MAAM,EAAC,CAAA;aACvC;YACD,OAAO,aAAa,CAAA;QACxB,CAAC,CAAA;QAED,aAAQ,GAAG,GAAY,EAAE;YACrB,OAAO,SAAS,CAAA;QACpB,CAAC,CAAA;QAED,WAAM,GAAG,CAAC,MAAc,EAAc,EAAE;YACpC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;YAC5D,OAAO,IAAI,CAAA;QACf,CAAC,CAAA;IACL,CAAC;CAAA;AAlBD,gCAkBC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { randomCore } from "./randomCore";
|
|
2
2
|
import { randomCoefficientConfig } from "./rndTypes";
|
|
3
3
|
import { Fraction } from "../coefficients";
|
|
4
|
+
/**
|
|
5
|
+
* Create a random monom based on a based configuration
|
|
6
|
+
*/
|
|
4
7
|
export declare class rndFraction extends randomCore {
|
|
5
8
|
protected _config: randomCoefficientConfig;
|
|
6
9
|
protected _defaultConfig: randomCoefficientConfig;
|
|
@@ -4,9 +4,28 @@ exports.rndFraction = void 0;
|
|
|
4
4
|
const randomCore_1 = require("./randomCore");
|
|
5
5
|
const coefficients_1 = require("../coefficients");
|
|
6
6
|
const index_1 = require("./index");
|
|
7
|
+
/**
|
|
8
|
+
* Create a random monom based on a based configuration
|
|
9
|
+
*/
|
|
7
10
|
class rndFraction extends randomCore_1.randomCore {
|
|
8
11
|
constructor(userConfig) {
|
|
9
12
|
super();
|
|
13
|
+
this.generate = () => {
|
|
14
|
+
let Q = new coefficients_1.Fraction();
|
|
15
|
+
if (this._config.negative) {
|
|
16
|
+
Q.numerator = index_1.Random.numberSym(this._config.max, this._config.zero);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
Q.numerator = index_1.Random.number(this._config.zero ? 0 : 1, this._config.max);
|
|
20
|
+
}
|
|
21
|
+
if (this._config.natural) {
|
|
22
|
+
Q.denominator = 1;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
Q.denominator = index_1.Random.number(1, this._config.max);
|
|
26
|
+
}
|
|
27
|
+
return this._config.reduced ? Q.reduce() : Q;
|
|
28
|
+
};
|
|
10
29
|
this._defaultConfig = {
|
|
11
30
|
negative: true,
|
|
12
31
|
max: 10,
|
|
@@ -16,22 +35,6 @@ class rndFraction extends randomCore_1.randomCore {
|
|
|
16
35
|
};
|
|
17
36
|
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
18
37
|
}
|
|
19
|
-
generate = () => {
|
|
20
|
-
let Q = new coefficients_1.Fraction();
|
|
21
|
-
if (this._config.negative) {
|
|
22
|
-
Q.numerator = index_1.Random.numberSym(this._config.max, this._config.zero);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
Q.numerator = index_1.Random.number(this._config.zero ? 0 : 1, this._config.max);
|
|
26
|
-
}
|
|
27
|
-
if (this._config.natural) {
|
|
28
|
-
Q.denominator = 1;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
Q.denominator = index_1.Random.number(1, this._config.max);
|
|
32
|
-
}
|
|
33
|
-
return this._config.reduced ? Q.reduce() : Q;
|
|
34
|
-
};
|
|
35
38
|
}
|
|
36
39
|
exports.rndFraction = rndFraction;
|
|
37
40
|
//# sourceMappingURL=rndFraction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rndFraction.js","sourceRoot":"","sources":["../../../src/maths/random/rndFraction.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,kDAAyC;AACzC,mCAA+B;
|
|
1
|
+
{"version":3,"file":"rndFraction.js","sourceRoot":"","sources":["../../../src/maths/random/rndFraction.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,kDAAyC;AACzC,mCAA+B;AAE/B;;GAEG;AACH,MAAa,WAAY,SAAQ,uBAAU;IAIvC,YAAY,UAAoC;QAC5C,KAAK,EAAE,CAAC;QAaZ,aAAQ,GAAG,GAAa,EAAE;YACtB,IAAI,CAAC,GAAG,IAAI,uBAAQ,EAAE,CAAA;YAEtB,IAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAC;gBACrB,CAAC,CAAC,SAAS,GAAG,cAAM,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;aACtE;iBAAK;gBACF,CAAC,CAAC,SAAS,GAAG,cAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;aAC3E;YACD,IAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAC;gBACpB,CAAC,CAAC,WAAW,GAAG,CAAC,CAAA;aACpB;iBAAK;gBACF,CAAC,CAAC,WAAW,GAAG,cAAM,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;aACrD;YAED,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAA,CAAC,CAAA,CAAC,CAAC,MAAM,EAAE,CAAA,CAAC,CAAA,CAAC,CAAA;QAC5C,CAAC,CAAA;QA1BG,IAAI,CAAC,cAAc,GAAG;YAClB,QAAQ,EAAE,IAAI;YACd,GAAG,EAAE,EAAE;YACP,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,KAAK;SACjB,CAAA;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IACpE,CAAC;CAkBJ;AAlCD,kCAkCC"}
|
|
@@ -1,6 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Random helpers
|
|
3
|
+
*/
|
|
1
4
|
export declare class rndHelpers {
|
|
5
|
+
/**
|
|
6
|
+
* Random boolean with a percent ratio
|
|
7
|
+
* @param percent
|
|
8
|
+
*/
|
|
2
9
|
static randomBool(percent?: number): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Random integer between two values.
|
|
12
|
+
* @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
|
|
13
|
+
* @param b (number) : To this value. If this is ommited.
|
|
14
|
+
*/
|
|
3
15
|
static randomInt(a: number, b?: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Random integer between -max and max value.
|
|
18
|
+
* @param max (number) : determine the limits.
|
|
19
|
+
* @param zero (bool) : determine if zero is allowed or not.
|
|
20
|
+
*/
|
|
4
21
|
static randomIntSym(max: number, zero?: boolean): number;
|
|
5
22
|
static randomArray(arr: any[], number?: number): any[];
|
|
6
23
|
static randomItem(arr: any[]): any;
|
|
@@ -1,16 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rndHelpers = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Random helpers
|
|
6
|
+
*/
|
|
4
7
|
class rndHelpers {
|
|
8
|
+
/**
|
|
9
|
+
* Random boolean with a percent ratio
|
|
10
|
+
* @param percent
|
|
11
|
+
*/
|
|
5
12
|
static randomBool(percent = 0.5) {
|
|
6
13
|
return Math.random() < percent;
|
|
7
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Random integer between two values.
|
|
17
|
+
* @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
|
|
18
|
+
* @param b (number) : To this value. If this is ommited.
|
|
19
|
+
*/
|
|
8
20
|
static randomInt(a, b) {
|
|
9
21
|
if (b === undefined) {
|
|
10
22
|
return this.randomInt(0, a);
|
|
11
23
|
}
|
|
12
24
|
return Math.floor(Math.random() * (b - a + 1) + a);
|
|
13
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Random integer between -max and max value.
|
|
28
|
+
* @param max (number) : determine the limits.
|
|
29
|
+
* @param zero (bool) : determine if zero is allowed or not.
|
|
30
|
+
*/
|
|
14
31
|
static randomIntSym(max, zero) {
|
|
15
32
|
if (zero === false) {
|
|
16
33
|
return this.randomBool() ? this.randomInt(1, max) : -this.randomInt(1, max);
|
|
@@ -23,9 +40,11 @@ class rndHelpers {
|
|
|
23
40
|
if (number === undefined) {
|
|
24
41
|
number = 1;
|
|
25
42
|
}
|
|
43
|
+
// Return a clone array
|
|
26
44
|
if (arr.length <= 0) {
|
|
27
45
|
return Object.values(arr);
|
|
28
46
|
}
|
|
47
|
+
// Randomize the array and return the n first elements.
|
|
29
48
|
return rndHelpers.shuffleArray(arr).slice(0, number);
|
|
30
49
|
}
|
|
31
50
|
static randomItem(arr) {
|
|
@@ -35,6 +54,7 @@ class rndHelpers {
|
|
|
35
54
|
return this.randomArray(arr, 1)[0];
|
|
36
55
|
}
|
|
37
56
|
static shuffleArray(arr) {
|
|
57
|
+
// The Fisher-Yates algorithm
|
|
38
58
|
let shuffleArray = Object.values(arr);
|
|
39
59
|
for (let i = shuffleArray.length - 1; i > 0; i--) {
|
|
40
60
|
const j = Math.floor(Math.random() * (i + 1));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rndHelpers.js","sourceRoot":"","sources":["../../../src/maths/random/rndHelpers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"rndHelpers.js","sourceRoot":"","sources":["../../../src/maths/random/rndHelpers.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,UAAU;IAEnB;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,UAAe,GAAG;QAChC,OAAO,IAAI,CAAC,MAAM,EAAE,GAAC,OAAO,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,CAAQ,EAAE,CAAS;QAChC,IAAG,CAAC,KAAG,SAAS,EAAC;YAAC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;SAAC;QAE9C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC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,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC9C,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;YAC7B,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;YAClC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;SAC1B;QAED,OAAO,YAAY,CAAC;IACxB,CAAC;CAEJ;AA9DD,gCA8DC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { randomCore } from "./randomCore";
|
|
2
2
|
import { randomMonomConfig } from "./rndTypes";
|
|
3
3
|
import { Monom } from "../algebra";
|
|
4
|
+
/**
|
|
5
|
+
* Create a random monom based on a based configuration
|
|
6
|
+
*/
|
|
4
7
|
export declare class rndMonom extends randomCore {
|
|
5
8
|
protected _config: randomMonomConfig;
|
|
6
9
|
protected _defaultConfig: randomMonomConfig;
|
|
@@ -4,9 +4,42 @@ exports.rndMonom = void 0;
|
|
|
4
4
|
const randomCore_1 = require("./randomCore");
|
|
5
5
|
const index_1 = require("./index");
|
|
6
6
|
const algebra_1 = require("../algebra");
|
|
7
|
+
/**
|
|
8
|
+
* Create a random monom based on a based configuration
|
|
9
|
+
*/
|
|
7
10
|
class rndMonom extends randomCore_1.randomCore {
|
|
8
11
|
constructor(userConfig) {
|
|
9
12
|
super();
|
|
13
|
+
this.generate = () => {
|
|
14
|
+
// Create a monom instance
|
|
15
|
+
let M = new algebra_1.Monom();
|
|
16
|
+
// Generate the coefficient
|
|
17
|
+
if (typeof this._config.fraction === "boolean") {
|
|
18
|
+
M.coefficient = index_1.Random.fraction({
|
|
19
|
+
zero: this._config.zero,
|
|
20
|
+
reduced: true,
|
|
21
|
+
natural: !this._config.fraction
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
M.coefficient = index_1.Random.fraction(this._config.fraction);
|
|
26
|
+
}
|
|
27
|
+
// Calculate the degree of the monom
|
|
28
|
+
if (this._config.letters.length > 1) {
|
|
29
|
+
// Initialise each items...
|
|
30
|
+
for (let L of this._config.letters.split('')) {
|
|
31
|
+
M.setLetter(L, 0);
|
|
32
|
+
}
|
|
33
|
+
for (let i = 0; i < this._config.degree; i++) {
|
|
34
|
+
const L = index_1.Random.item(this._config.letters.split(""));
|
|
35
|
+
M.setLetter(L, M.degree(L).clone().add(1));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
M.setLetter(this._config.letters, this._config.degree);
|
|
40
|
+
}
|
|
41
|
+
return M;
|
|
42
|
+
};
|
|
10
43
|
this._defaultConfig = {
|
|
11
44
|
letters: 'x',
|
|
12
45
|
degree: 2,
|
|
@@ -15,32 +48,6 @@ class rndMonom extends randomCore_1.randomCore {
|
|
|
15
48
|
};
|
|
16
49
|
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
17
50
|
}
|
|
18
|
-
generate = () => {
|
|
19
|
-
let M = new algebra_1.Monom();
|
|
20
|
-
if (typeof this._config.fraction === "boolean") {
|
|
21
|
-
M.coefficient = index_1.Random.fraction({
|
|
22
|
-
zero: this._config.zero,
|
|
23
|
-
reduced: true,
|
|
24
|
-
natural: !this._config.fraction
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
M.coefficient = index_1.Random.fraction(this._config.fraction);
|
|
29
|
-
}
|
|
30
|
-
if (this._config.letters.length > 1) {
|
|
31
|
-
for (let L of this._config.letters.split('')) {
|
|
32
|
-
M.setLetter(L, 0);
|
|
33
|
-
}
|
|
34
|
-
for (let i = 0; i < this._config.degree; i++) {
|
|
35
|
-
const L = index_1.Random.item(this._config.letters.split(""));
|
|
36
|
-
M.setLetter(L, M.degree(L).clone().add(1));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
M.setLetter(this._config.letters, this._config.degree);
|
|
41
|
-
}
|
|
42
|
-
return M;
|
|
43
|
-
};
|
|
44
51
|
}
|
|
45
52
|
exports.rndMonom = rndMonom;
|
|
46
53
|
//# sourceMappingURL=rndMonom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rndMonom.js","sourceRoot":"","sources":["../../../src/maths/random/rndMonom.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,mCAA+B;AAC/B,wCAAiC;
|
|
1
|
+
{"version":3,"file":"rndMonom.js","sourceRoot":"","sources":["../../../src/maths/random/rndMonom.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,mCAA+B;AAC/B,wCAAiC;AAEjC;;GAEG;AACH,MAAa,QAAS,SAAQ,uBAAU;IAIpC,YAAY,UAA8B;QACtC,KAAK,EAAE,CAAC;QAYZ,aAAQ,GAAG,GAAU,EAAE;YACnB,0BAA0B;YAC1B,IAAI,CAAC,GAAG,IAAI,eAAK,EAAE,CAAA;YAEnB,2BAA2B;YAC3B,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE;gBAC5C,CAAC,CAAC,WAAW,GAAG,cAAM,CAAC,QAAQ,CAAC;oBAC5B,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;oBACvB,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ;iBAClC,CAAC,CAAA;aACL;iBAAM;gBACH,CAAC,CAAC,WAAW,GAAG,cAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;aACzD;YAED,oCAAoC;YACpC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gBACjC,2BAA2B;gBAC3B,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;oBAC1C,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;iBACrB;gBACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC1C,MAAM,CAAC,GAAG,cAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;oBACrD,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;iBAC7C;aACJ;iBAAM;gBACH,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;aACzD;YAED,OAAO,CAAC,CAAA;QACZ,CAAC,CAAA;QAxCG,IAAI,CAAC,cAAc,GAAG;YAClB,OAAO,EAAE,GAAG;YACZ,MAAM,EAAE,CAAC;YACT,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,KAAK;SACd,CAAA;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IACpE,CAAC;CAiCJ;AAhDD,4BAgDC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { randomCore } from "./randomCore";
|
|
2
2
|
import { randomPolynomConfig } from "./rndTypes";
|
|
3
3
|
import { Polynom } from "../algebra";
|
|
4
|
+
/**
|
|
5
|
+
* Random polynoms
|
|
6
|
+
*/
|
|
4
7
|
export declare class rndPolynom extends randomCore {
|
|
5
8
|
protected _config: randomPolynomConfig;
|
|
6
9
|
protected _defaultConfig: randomPolynomConfig;
|
|
@@ -5,9 +5,57 @@ const randomCore_1 = require("./randomCore");
|
|
|
5
5
|
const rndMonom_1 = require("./rndMonom");
|
|
6
6
|
const index_1 = require("./index");
|
|
7
7
|
const algebra_1 = require("../algebra");
|
|
8
|
+
/**
|
|
9
|
+
* Random polynoms
|
|
10
|
+
*/
|
|
8
11
|
class rndPolynom extends randomCore_1.randomCore {
|
|
9
12
|
constructor(userConfig) {
|
|
10
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 algebra_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 = index_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 algebra_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(index_1.Random.polynom(_factorableConfig));
|
|
55
|
+
}
|
|
56
|
+
return P;
|
|
57
|
+
};
|
|
58
|
+
// Default config for a random polynom
|
|
11
59
|
this._defaultConfig = {
|
|
12
60
|
letters: 'x',
|
|
13
61
|
degree: 2,
|
|
@@ -19,45 +67,9 @@ class rndPolynom extends randomCore_1.randomCore {
|
|
|
19
67
|
numberOfMonoms: 0,
|
|
20
68
|
positive: true
|
|
21
69
|
};
|
|
70
|
+
// Merge config with initialiser
|
|
22
71
|
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
23
72
|
}
|
|
24
|
-
generate = () => {
|
|
25
|
-
if (this._config.factorable && this._config.degree > 1) {
|
|
26
|
-
return this.factorable();
|
|
27
|
-
}
|
|
28
|
-
let P = new algebra_1.Polynom().empty(), M;
|
|
29
|
-
for (let i = this._config.degree; i >= 0; i--) {
|
|
30
|
-
M = new rndMonom_1.rndMonom({
|
|
31
|
-
letters: this._config.letters,
|
|
32
|
-
degree: i,
|
|
33
|
-
fraction: this._config.fraction,
|
|
34
|
-
zero: (i === this._config.degree) ? false : this._config.allowNullMonom
|
|
35
|
-
}).generate();
|
|
36
|
-
if (this._config.unit && this._config.degree === i) {
|
|
37
|
-
M.coefficient.one();
|
|
38
|
-
}
|
|
39
|
-
P.add(M);
|
|
40
|
-
}
|
|
41
|
-
if (this._config.positive && P.monomByDegree().coefficient.isNegative()) {
|
|
42
|
-
P.monomByDegree().coefficient.opposed();
|
|
43
|
-
}
|
|
44
|
-
if (this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < P.length) {
|
|
45
|
-
let M = P.monomByDegree().clone();
|
|
46
|
-
P.monoms = index_1.Random.array(P.monoms.slice(1), this._config.numberOfMonoms - 1);
|
|
47
|
-
P.add(M).reorder().reduce();
|
|
48
|
-
}
|
|
49
|
-
return P;
|
|
50
|
-
};
|
|
51
|
-
factorable = () => {
|
|
52
|
-
let P = new algebra_1.Polynom().one();
|
|
53
|
-
let _factorableConfig = { ...this._config };
|
|
54
|
-
_factorableConfig.degree = 1;
|
|
55
|
-
_factorableConfig.factorable = false;
|
|
56
|
-
for (let i = 0; i < this._config.degree; i++) {
|
|
57
|
-
P.multiply(index_1.Random.polynom(_factorableConfig));
|
|
58
|
-
}
|
|
59
|
-
return P;
|
|
60
|
-
};
|
|
61
73
|
}
|
|
62
74
|
exports.rndPolynom = rndPolynom;
|
|
63
75
|
//# sourceMappingURL=rndPolynom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rndPolynom.js","sourceRoot":"","sources":["../../../src/maths/random/rndPolynom.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,yCAAoC;AACpC,mCAA+B;AAC/B,wCAAmC;
|
|
1
|
+
{"version":3,"file":"rndPolynom.js","sourceRoot":"","sources":["../../../src/maths/random/rndPolynom.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,yCAAoC;AACpC,mCAA+B;AAC/B,wCAAmC;AAGnC;;GAEG;AACH,MAAa,UAAW,SAAQ,uBAAU;IAItC,YAAY,UAAgC;QACxC,KAAK,EAAE,CAAC;QAmBZ,aAAQ,GAAG,GAAY,EAAE;YACrB,IAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAC,CAAC,EAAC;gBAChD,OAAO,IAAI,CAAC,UAAU,EAAE,CAAA;aAC3B;YAED,qBAAqB;YACrB,IAAI,CAAC,GAAG,IAAI,iBAAO,EAAE,CAAC,KAAK,EAAE,EACzB,CAAQ,CAAA;YAEZ,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;gBAC3C,wCAAwC;gBACxC,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AAC,MAAM,EAAE,CAAA;aAC9B;YACD,OAAO,CAAC,CAAA;QACZ,CAAC,CAAA;QAED,eAAU,GAAG,GAAY,EAAE;YACvB,IAAI,CAAC,GAAG,IAAI,iBAAO,EAAE,CAAC,GAAG,EAAE,CAAA;YAE3B,IAAI,iBAAiB,GAAG,EAAC,GAAG,IAAI,CAAC,OAAO,EAAC,CAAA;YACzC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAA;YAC5B,iBAAiB,CAAC,UAAU,GAAG,KAAK,CAAA;YAEpC,KAAI,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;gBACnC,CAAC,CAAC,QAAQ,CAAC,cAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAA;aAChD;YAED,OAAO,CAAC,CAAA;QACZ,CAAC,CAAA;QAvEG,sCAAsC;QACtC,IAAI,CAAC,cAAc,GAAG;YAClB,OAAO,EAAE,GAAG;YACZ,MAAM,EAAE,CAAC;YACT,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,KAAK;YACX,UAAU,EAAE,KAAK;YACjB,cAAc,EAAE,IAAI;YACpB,cAAc,EAAE,CAAC;YACjB,QAAQ,EAAE,IAAI;SACjB,CAAA;QAED,gCAAgC;QAChC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IACpE,CAAC;CAyDJ;AA/ED,gCA+EC"}
|
|
@@ -33,9 +33,30 @@ export declare class Shutingyard {
|
|
|
33
33
|
private _uniformize;
|
|
34
34
|
private _tokenKeys;
|
|
35
35
|
constructor(mode?: ShutingyardMode);
|
|
36
|
+
/**
|
|
37
|
+
* Determin if the token is a defined operation
|
|
38
|
+
* Defined operations: + - * / ^ sin cos tan
|
|
39
|
+
* @param token
|
|
40
|
+
*/
|
|
36
41
|
tokenConfigInitialization(): tokenType;
|
|
42
|
+
/**
|
|
43
|
+
* Get the next token to analyse.
|
|
44
|
+
* @param expr (string) Expression to analyse
|
|
45
|
+
* @param start (number) CUrrent position in the expr string.
|
|
46
|
+
*/
|
|
37
47
|
NextToken(expr: string, start: number): [string, number, string];
|
|
48
|
+
/**
|
|
49
|
+
* Sanitize an expression by adding missing common operation (multiplication between parentheseses)
|
|
50
|
+
* @param expr
|
|
51
|
+
* @constructor
|
|
52
|
+
*/
|
|
38
53
|
Uniformizer(expr: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Parse an expression using the shutting yard tree algorithms
|
|
56
|
+
* @param expr (string) Expression to analyse
|
|
57
|
+
* Returns a RPN list of items.
|
|
58
|
+
* @param operators
|
|
59
|
+
*/
|
|
39
60
|
parse(expr: string, operators?: string[]): Shutingyard;
|
|
40
61
|
get rpn(): Token[];
|
|
41
62
|
}
|