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,46 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rndGeometryLine = void 0;
|
|
4
|
-
const randomCore_1 = require("./randomCore");
|
|
5
|
-
const random_1 = require("./random");
|
|
6
|
-
const line_1 = require("../geometry/line");
|
|
7
|
-
const vector_1 = require("../geometry/vector");
|
|
8
|
-
const point_1 = require("../geometry/point");
|
|
9
|
-
/**
|
|
10
|
-
* Create a random monom based on a based configuration
|
|
11
|
-
*/
|
|
12
|
-
class rndGeometryLine extends randomCore_1.randomCore {
|
|
13
|
-
constructor(userConfig) {
|
|
14
|
-
super();
|
|
15
|
-
this.generate = () => {
|
|
16
|
-
// The A point exists.
|
|
17
|
-
const d = new vector_1.Vector(random_1.Random.numberSym(10), random_1.Random.numberSym(10));
|
|
18
|
-
while (d.isNull) {
|
|
19
|
-
d.x = random_1.Random.numberSym(10);
|
|
20
|
-
d.y = random_1.Random.numberSym(10);
|
|
21
|
-
}
|
|
22
|
-
if (this._config.slope === 1) {
|
|
23
|
-
if (d.x.sign() !== d.y.sign()) {
|
|
24
|
-
d.y.opposed();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
else if (this._config.slope === -1) {
|
|
28
|
-
if (d.x.sign() !== d.y.sign()) {
|
|
29
|
-
d.y.opposed();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return new line_1.Line(new point_1.Point(this._config.A.x, this._config.A.y), d);
|
|
33
|
-
};
|
|
34
|
-
this._defaultConfig = {
|
|
35
|
-
A: {
|
|
36
|
-
x: random_1.Random.numberSym(10),
|
|
37
|
-
y: random_1.Random.numberSym(10)
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
// TODO: Strange that it raise an error
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.rndGeometryLine = rndGeometryLine;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rndGeometryLine = void 0;
|
|
4
|
+
const randomCore_1 = require("./randomCore");
|
|
5
|
+
const random_1 = require("./random");
|
|
6
|
+
const line_1 = require("../geometry/line");
|
|
7
|
+
const vector_1 = require("../geometry/vector");
|
|
8
|
+
const point_1 = require("../geometry/point");
|
|
9
|
+
/**
|
|
10
|
+
* Create a random monom based on a based configuration
|
|
11
|
+
*/
|
|
12
|
+
class rndGeometryLine extends randomCore_1.randomCore {
|
|
13
|
+
constructor(userConfig) {
|
|
14
|
+
super();
|
|
15
|
+
this.generate = () => {
|
|
16
|
+
// The A point exists.
|
|
17
|
+
const d = new vector_1.Vector(random_1.Random.numberSym(10), random_1.Random.numberSym(10));
|
|
18
|
+
while (d.isNull) {
|
|
19
|
+
d.x = random_1.Random.numberSym(10);
|
|
20
|
+
d.y = random_1.Random.numberSym(10);
|
|
21
|
+
}
|
|
22
|
+
if (this._config.slope === 1) {
|
|
23
|
+
if (d.x.sign() !== d.y.sign()) {
|
|
24
|
+
d.y.opposed();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else if (this._config.slope === -1) {
|
|
28
|
+
if (d.x.sign() !== d.y.sign()) {
|
|
29
|
+
d.y.opposed();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return new line_1.Line(new point_1.Point(this._config.A.x, this._config.A.y), d);
|
|
33
|
+
};
|
|
34
|
+
this._defaultConfig = {
|
|
35
|
+
A: {
|
|
36
|
+
x: random_1.Random.numberSym(10),
|
|
37
|
+
y: random_1.Random.numberSym(10)
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
// TODO: Strange that it raise an error
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.rndGeometryLine = rndGeometryLine;
|
|
46
46
|
//# sourceMappingURL=rndGeometryLine.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { randomCore } from "./randomCore";
|
|
2
|
-
import { randomGeometryPointConfig } from "./random";
|
|
3
|
-
import { Point } from "../geometry/point";
|
|
4
|
-
/**
|
|
5
|
-
* Create a random monom based on a based configuration
|
|
6
|
-
*/
|
|
7
|
-
export declare class rndGeometryPoint extends randomCore {
|
|
8
|
-
protected _config: randomGeometryPointConfig;
|
|
9
|
-
protected _defaultConfig: randomGeometryPointConfig;
|
|
10
|
-
constructor(userConfig?: randomGeometryPointConfig);
|
|
11
|
-
generate: () => Point;
|
|
12
|
-
}
|
|
1
|
+
import { randomCore } from "./randomCore";
|
|
2
|
+
import { randomGeometryPointConfig } from "./random";
|
|
3
|
+
import { Point } from "../geometry/point";
|
|
4
|
+
/**
|
|
5
|
+
* Create a random monom based on a based configuration
|
|
6
|
+
*/
|
|
7
|
+
export declare class rndGeometryPoint extends randomCore {
|
|
8
|
+
protected _config: randomGeometryPointConfig;
|
|
9
|
+
protected _defaultConfig: randomGeometryPointConfig;
|
|
10
|
+
constructor(userConfig?: randomGeometryPointConfig);
|
|
11
|
+
generate: () => Point;
|
|
12
|
+
}
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rndGeometryPoint = void 0;
|
|
4
|
-
const randomCore_1 = require("./randomCore");
|
|
5
|
-
const random_1 = require("./random");
|
|
6
|
-
const point_1 = require("../geometry/point");
|
|
7
|
-
const fraction_1 = require("../coefficients/fraction");
|
|
8
|
-
/**
|
|
9
|
-
* Create a random monom based on a based configuration
|
|
10
|
-
*/
|
|
11
|
-
class rndGeometryPoint extends randomCore_1.randomCore {
|
|
12
|
-
constructor(userConfig) {
|
|
13
|
-
super();
|
|
14
|
-
this.generate = () => {
|
|
15
|
-
let x, y, zeroX = this._config.axis === true || this._config.axis === 'x', zeroY = this._config.axis === true || this._config.axis === 'y';
|
|
16
|
-
x = this._config.fraction ?
|
|
17
|
-
random_1.Random.fraction({ max: this._config.max, zero: zeroX }) :
|
|
18
|
-
new fraction_1.Fraction(random_1.Random.numberSym(this._config.max, zeroX));
|
|
19
|
-
y = this._config.fraction ?
|
|
20
|
-
random_1.Random.fraction({ max: this._config.max, zero: zeroY }) :
|
|
21
|
-
new fraction_1.Fraction(random_1.Random.numberSym(this._config.max, zeroY));
|
|
22
|
-
if (+this._config.quadrant === 1) {
|
|
23
|
-
x.abs();
|
|
24
|
-
y.abs();
|
|
25
|
-
}
|
|
26
|
-
if (+this._config.quadrant === 2) {
|
|
27
|
-
if (x.isPositive()) {
|
|
28
|
-
x.opposed();
|
|
29
|
-
}
|
|
30
|
-
if (y.isNegative()) {
|
|
31
|
-
y.opposed();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (+this._config.quadrant === 3) {
|
|
35
|
-
if (x.isPositive()) {
|
|
36
|
-
x.opposed();
|
|
37
|
-
}
|
|
38
|
-
if (y.isPositive()) {
|
|
39
|
-
y.opposed();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (+this._config.quadrant === 4) {
|
|
43
|
-
if (x.isNegative()) {
|
|
44
|
-
x.opposed();
|
|
45
|
-
}
|
|
46
|
-
if (y.isPositive()) {
|
|
47
|
-
y.opposed();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return new point_1.Point(x, y);
|
|
51
|
-
};
|
|
52
|
-
this._defaultConfig = {
|
|
53
|
-
axis: true,
|
|
54
|
-
fraction: false,
|
|
55
|
-
max: 10
|
|
56
|
-
};
|
|
57
|
-
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.rndGeometryPoint = rndGeometryPoint;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rndGeometryPoint = void 0;
|
|
4
|
+
const randomCore_1 = require("./randomCore");
|
|
5
|
+
const random_1 = require("./random");
|
|
6
|
+
const point_1 = require("../geometry/point");
|
|
7
|
+
const fraction_1 = require("../coefficients/fraction");
|
|
8
|
+
/**
|
|
9
|
+
* Create a random monom based on a based configuration
|
|
10
|
+
*/
|
|
11
|
+
class rndGeometryPoint extends randomCore_1.randomCore {
|
|
12
|
+
constructor(userConfig) {
|
|
13
|
+
super();
|
|
14
|
+
this.generate = () => {
|
|
15
|
+
let x, y, zeroX = this._config.axis === true || this._config.axis === 'x', zeroY = this._config.axis === true || this._config.axis === 'y';
|
|
16
|
+
x = this._config.fraction ?
|
|
17
|
+
random_1.Random.fraction({ max: this._config.max, zero: zeroX }) :
|
|
18
|
+
new fraction_1.Fraction(random_1.Random.numberSym(this._config.max, zeroX));
|
|
19
|
+
y = this._config.fraction ?
|
|
20
|
+
random_1.Random.fraction({ max: this._config.max, zero: zeroY }) :
|
|
21
|
+
new fraction_1.Fraction(random_1.Random.numberSym(this._config.max, zeroY));
|
|
22
|
+
if (+this._config.quadrant === 1) {
|
|
23
|
+
x.abs();
|
|
24
|
+
y.abs();
|
|
25
|
+
}
|
|
26
|
+
if (+this._config.quadrant === 2) {
|
|
27
|
+
if (x.isPositive()) {
|
|
28
|
+
x.opposed();
|
|
29
|
+
}
|
|
30
|
+
if (y.isNegative()) {
|
|
31
|
+
y.opposed();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (+this._config.quadrant === 3) {
|
|
35
|
+
if (x.isPositive()) {
|
|
36
|
+
x.opposed();
|
|
37
|
+
}
|
|
38
|
+
if (y.isPositive()) {
|
|
39
|
+
y.opposed();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (+this._config.quadrant === 4) {
|
|
43
|
+
if (x.isNegative()) {
|
|
44
|
+
x.opposed();
|
|
45
|
+
}
|
|
46
|
+
if (y.isPositive()) {
|
|
47
|
+
y.opposed();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return new point_1.Point(x, y);
|
|
51
|
+
};
|
|
52
|
+
this._defaultConfig = {
|
|
53
|
+
axis: true,
|
|
54
|
+
fraction: false,
|
|
55
|
+
max: 10
|
|
56
|
+
};
|
|
57
|
+
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.rndGeometryPoint = rndGeometryPoint;
|
|
61
61
|
//# sourceMappingURL=rndGeometryPoint.js.map
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export declare class rndHelpers {
|
|
2
|
-
/**
|
|
3
|
-
* Random boolean with a percent ratio
|
|
4
|
-
* @param percent
|
|
5
|
-
*/
|
|
6
|
-
static randomBool(percent?: number): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Random integer between two values.
|
|
9
|
-
* @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
|
|
10
|
-
* @param b (number) : To this value. If this is ommited.
|
|
11
|
-
*/
|
|
12
|
-
static randomInt(a: number, b?: number): number;
|
|
13
|
-
/**
|
|
14
|
-
* Random integer between -max and max value.
|
|
15
|
-
* @param max (number) : determine the limits.
|
|
16
|
-
* @param zero (bool) : determine if zero is allowed or not.
|
|
17
|
-
*/
|
|
18
|
-
static randomIntSym(max: number, zero?: boolean): number;
|
|
19
|
-
static randomPrime(max: number): number;
|
|
20
|
-
static randomArray(arr: any[], number?: number): any[];
|
|
21
|
-
static randomItem(arr: any[]): any;
|
|
22
|
-
static shuffleArray(arr: any[]): any[];
|
|
23
|
-
}
|
|
1
|
+
export declare class rndHelpers {
|
|
2
|
+
/**
|
|
3
|
+
* Random boolean with a percent ratio
|
|
4
|
+
* @param percent
|
|
5
|
+
*/
|
|
6
|
+
static randomBool(percent?: number): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Random integer between two values.
|
|
9
|
+
* @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
|
|
10
|
+
* @param b (number) : To this value. If this is ommited.
|
|
11
|
+
*/
|
|
12
|
+
static randomInt(a: number, b?: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Random integer between -max and max value.
|
|
15
|
+
* @param max (number) : determine the limits.
|
|
16
|
+
* @param zero (bool) : determine if zero is allowed or not.
|
|
17
|
+
*/
|
|
18
|
+
static randomIntSym(max: number, zero?: boolean): number;
|
|
19
|
+
static randomPrime(max: number): number;
|
|
20
|
+
static randomArray(arr: any[], number?: number): any[];
|
|
21
|
+
static randomItem(arr: any[]): any;
|
|
22
|
+
static shuffleArray(arr: any[]): any[];
|
|
23
|
+
}
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rndHelpers = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Random helpers
|
|
6
|
-
*/
|
|
7
|
-
const numeric_1 = require("../numeric");
|
|
8
|
-
class rndHelpers {
|
|
9
|
-
/**
|
|
10
|
-
* Random boolean with a percent ratio
|
|
11
|
-
* @param percent
|
|
12
|
-
*/
|
|
13
|
-
static randomBool(percent = 0.5) {
|
|
14
|
-
return Math.random() < percent;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Random integer between two values.
|
|
18
|
-
* @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
|
|
19
|
-
* @param b (number) : To this value. If this is ommited.
|
|
20
|
-
*/
|
|
21
|
-
static randomInt(a, b) {
|
|
22
|
-
if (b === undefined) {
|
|
23
|
-
return this.randomInt(0, a);
|
|
24
|
-
}
|
|
25
|
-
return Math.floor(Math.random() * (b - a + 1) + a);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Random integer between -max and max value.
|
|
29
|
-
* @param max (number) : determine the limits.
|
|
30
|
-
* @param zero (bool) : determine if zero is allowed or not.
|
|
31
|
-
*/
|
|
32
|
-
static randomIntSym(max, zero) {
|
|
33
|
-
if (zero === false) {
|
|
34
|
-
return this.randomBool() ? this.randomInt(1, max) : -this.randomInt(1, max);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
return this.randomInt(-max, max);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
static randomPrime(max) {
|
|
41
|
-
let primes = numeric_1.Numeric.primes();
|
|
42
|
-
if (max !== undefined) {
|
|
43
|
-
primes = primes.filter(x => x < max);
|
|
44
|
-
}
|
|
45
|
-
return this.randomItem(primes);
|
|
46
|
-
}
|
|
47
|
-
static randomArray(arr, number) {
|
|
48
|
-
if (number === undefined) {
|
|
49
|
-
number = 1;
|
|
50
|
-
}
|
|
51
|
-
// Return a clone array
|
|
52
|
-
if (arr.length <= 0) {
|
|
53
|
-
return Object.values(arr);
|
|
54
|
-
}
|
|
55
|
-
// Randomize the array and return the n first elements.
|
|
56
|
-
return rndHelpers.shuffleArray(arr).slice(0, number);
|
|
57
|
-
}
|
|
58
|
-
static randomItem(arr) {
|
|
59
|
-
if (arr.length === 0) {
|
|
60
|
-
return '';
|
|
61
|
-
}
|
|
62
|
-
return this.randomArray(arr, 1)[0];
|
|
63
|
-
}
|
|
64
|
-
static shuffleArray(arr) {
|
|
65
|
-
// The Fisher-Yates algorithm
|
|
66
|
-
let shuffleArray = Object.values(arr);
|
|
67
|
-
for (let i = shuffleArray.length - 1; i > 0; i--) {
|
|
68
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
69
|
-
const temp = shuffleArray[i];
|
|
70
|
-
shuffleArray[i] = shuffleArray[j];
|
|
71
|
-
shuffleArray[j] = temp;
|
|
72
|
-
}
|
|
73
|
-
return shuffleArray;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.rndHelpers = rndHelpers;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rndHelpers = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Random helpers
|
|
6
|
+
*/
|
|
7
|
+
const numeric_1 = require("../numeric");
|
|
8
|
+
class rndHelpers {
|
|
9
|
+
/**
|
|
10
|
+
* Random boolean with a percent ratio
|
|
11
|
+
* @param percent
|
|
12
|
+
*/
|
|
13
|
+
static randomBool(percent = 0.5) {
|
|
14
|
+
return Math.random() < percent;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Random integer between two values.
|
|
18
|
+
* @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
|
|
19
|
+
* @param b (number) : To this value. If this is ommited.
|
|
20
|
+
*/
|
|
21
|
+
static randomInt(a, b) {
|
|
22
|
+
if (b === undefined) {
|
|
23
|
+
return this.randomInt(0, a);
|
|
24
|
+
}
|
|
25
|
+
return Math.floor(Math.random() * (b - a + 1) + a);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Random integer between -max and max value.
|
|
29
|
+
* @param max (number) : determine the limits.
|
|
30
|
+
* @param zero (bool) : determine if zero is allowed or not.
|
|
31
|
+
*/
|
|
32
|
+
static randomIntSym(max, zero) {
|
|
33
|
+
if (zero === false) {
|
|
34
|
+
return this.randomBool() ? this.randomInt(1, max) : -this.randomInt(1, max);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return this.randomInt(-max, max);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
static randomPrime(max) {
|
|
41
|
+
let primes = numeric_1.Numeric.primes();
|
|
42
|
+
if (max !== undefined) {
|
|
43
|
+
primes = primes.filter(x => x < max);
|
|
44
|
+
}
|
|
45
|
+
return this.randomItem(primes);
|
|
46
|
+
}
|
|
47
|
+
static randomArray(arr, number) {
|
|
48
|
+
if (number === undefined) {
|
|
49
|
+
number = 1;
|
|
50
|
+
}
|
|
51
|
+
// Return a clone array
|
|
52
|
+
if (arr.length <= 0) {
|
|
53
|
+
return Object.values(arr);
|
|
54
|
+
}
|
|
55
|
+
// Randomize the array and return the n first elements.
|
|
56
|
+
return rndHelpers.shuffleArray(arr).slice(0, number);
|
|
57
|
+
}
|
|
58
|
+
static randomItem(arr) {
|
|
59
|
+
if (arr.length === 0) {
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
return this.randomArray(arr, 1)[0];
|
|
63
|
+
}
|
|
64
|
+
static shuffleArray(arr) {
|
|
65
|
+
// The Fisher-Yates algorithm
|
|
66
|
+
let shuffleArray = Object.values(arr);
|
|
67
|
+
for (let i = shuffleArray.length - 1; i > 0; i--) {
|
|
68
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
69
|
+
const temp = shuffleArray[i];
|
|
70
|
+
shuffleArray[i] = shuffleArray[j];
|
|
71
|
+
shuffleArray[j] = temp;
|
|
72
|
+
}
|
|
73
|
+
return shuffleArray;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.rndHelpers = rndHelpers;
|
|
77
77
|
//# sourceMappingURL=rndHelpers.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { randomCore } from "./randomCore";
|
|
2
|
-
import { randomMonomConfig } from "./rndTypes";
|
|
3
|
-
import { Monom } from "../algebra/monom";
|
|
4
|
-
/**
|
|
5
|
-
* Create a random monom based on a based configuration
|
|
6
|
-
*/
|
|
7
|
-
export declare class rndMonom extends randomCore {
|
|
8
|
-
protected _config: randomMonomConfig;
|
|
9
|
-
protected _defaultConfig: randomMonomConfig;
|
|
10
|
-
constructor(userConfig?: randomMonomConfig);
|
|
11
|
-
generate: () => Monom;
|
|
12
|
-
}
|
|
1
|
+
import { randomCore } from "./randomCore";
|
|
2
|
+
import { randomMonomConfig } from "./rndTypes";
|
|
3
|
+
import { Monom } from "../algebra/monom";
|
|
4
|
+
/**
|
|
5
|
+
* Create a random monom based on a based configuration
|
|
6
|
+
*/
|
|
7
|
+
export declare class rndMonom extends randomCore {
|
|
8
|
+
protected _config: randomMonomConfig;
|
|
9
|
+
protected _defaultConfig: randomMonomConfig;
|
|
10
|
+
constructor(userConfig?: randomMonomConfig);
|
|
11
|
+
generate: () => Monom;
|
|
12
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rndMonom = void 0;
|
|
4
|
-
const randomCore_1 = require("./randomCore");
|
|
5
|
-
const random_1 = require("./random");
|
|
6
|
-
const monom_1 = require("../algebra/monom");
|
|
7
|
-
/**
|
|
8
|
-
* Create a random monom based on a based configuration
|
|
9
|
-
*/
|
|
10
|
-
class rndMonom extends randomCore_1.randomCore {
|
|
11
|
-
constructor(userConfig) {
|
|
12
|
-
super();
|
|
13
|
-
this.generate = () => {
|
|
14
|
-
// Create a monom instance
|
|
15
|
-
let M = new monom_1.Monom();
|
|
16
|
-
// Generate the coefficient
|
|
17
|
-
if (typeof this._config.fraction === "boolean") {
|
|
18
|
-
M.coefficient = random_1.Random.fraction({
|
|
19
|
-
zero: this._config.zero,
|
|
20
|
-
reduced: true,
|
|
21
|
-
natural: !this._config.fraction
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
M.coefficient = random_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 = random_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
|
-
};
|
|
43
|
-
this._defaultConfig = {
|
|
44
|
-
letters: 'x',
|
|
45
|
-
degree: 2,
|
|
46
|
-
fraction: true,
|
|
47
|
-
zero: false
|
|
48
|
-
};
|
|
49
|
-
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.rndMonom = rndMonom;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rndMonom = void 0;
|
|
4
|
+
const randomCore_1 = require("./randomCore");
|
|
5
|
+
const random_1 = require("./random");
|
|
6
|
+
const monom_1 = require("../algebra/monom");
|
|
7
|
+
/**
|
|
8
|
+
* Create a random monom based on a based configuration
|
|
9
|
+
*/
|
|
10
|
+
class rndMonom extends randomCore_1.randomCore {
|
|
11
|
+
constructor(userConfig) {
|
|
12
|
+
super();
|
|
13
|
+
this.generate = () => {
|
|
14
|
+
// Create a monom instance
|
|
15
|
+
let M = new monom_1.Monom();
|
|
16
|
+
// Generate the coefficient
|
|
17
|
+
if (typeof this._config.fraction === "boolean") {
|
|
18
|
+
M.coefficient = random_1.Random.fraction({
|
|
19
|
+
zero: this._config.zero,
|
|
20
|
+
reduced: true,
|
|
21
|
+
natural: !this._config.fraction
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
M.coefficient = random_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 = random_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
|
+
};
|
|
43
|
+
this._defaultConfig = {
|
|
44
|
+
letters: 'x',
|
|
45
|
+
degree: 2,
|
|
46
|
+
fraction: true,
|
|
47
|
+
zero: false
|
|
48
|
+
};
|
|
49
|
+
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.rndMonom = rndMonom;
|
|
53
53
|
//# sourceMappingURL=rndMonom.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { randomCore } from "./randomCore";
|
|
2
|
-
import { randomPolynomConfig } from "./rndTypes";
|
|
3
|
-
import { Polynom } from "../algebra/polynom";
|
|
4
|
-
/**
|
|
5
|
-
* Random polynoms
|
|
6
|
-
*/
|
|
7
|
-
export declare class rndPolynom extends randomCore {
|
|
8
|
-
protected _config: randomPolynomConfig;
|
|
9
|
-
protected _defaultConfig: randomPolynomConfig;
|
|
10
|
-
constructor(userConfig?: randomPolynomConfig);
|
|
11
|
-
generate: () => Polynom;
|
|
12
|
-
factorable: () => Polynom;
|
|
13
|
-
}
|
|
1
|
+
import { randomCore } from "./randomCore";
|
|
2
|
+
import { randomPolynomConfig } from "./rndTypes";
|
|
3
|
+
import { Polynom } from "../algebra/polynom";
|
|
4
|
+
/**
|
|
5
|
+
* Random polynoms
|
|
6
|
+
*/
|
|
7
|
+
export declare class rndPolynom extends randomCore {
|
|
8
|
+
protected _config: randomPolynomConfig;
|
|
9
|
+
protected _defaultConfig: randomPolynomConfig;
|
|
10
|
+
constructor(userConfig?: randomPolynomConfig);
|
|
11
|
+
generate: () => Polynom;
|
|
12
|
+
factorable: () => Polynom;
|
|
13
|
+
}
|