pimath 0.0.126 → 0.0.128
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/.idea/jsLibraryMappings.xml +6 -0
- package/{public/index.html → dist/demo/exercises.html} +2 -2
- package/dist/demo/matrices.html +39 -0
- package/dist/demo/playground.html +20 -0
- package/dist/demo.css +3 -0
- package/dist/pimath.js +4239 -7819
- package/dist/pimath.umd.cjs +15 -0
- package/index.html +15 -0
- package/package.json +16 -8
- package/public/demo/exercises.html +283 -0
- package/public/demo/matrices.html +39 -0
- package/public/demo/playground.html +20 -0
- package/src/demo/exercises.ts +0 -0
- package/src/demo/matrices.ts +61 -0
- package/src/demo/playground.ts +153 -0
- package/src/{index.ts → main.ts} +1 -1
- package/src/maths/algebra/polynom.ts +9 -16
- package/src/maths/algebra/rational.ts +8 -4
- package/src/maths/geometry/line.ts +22 -25
- package/src/maths/geometry/point.ts +43 -29
- package/src/maths/randomization/random.ts +7 -0
- package/src/maths/randomization/rndGeometryCircle.ts +50 -0
- package/src/maths/randomization/rndTypes.ts +10 -4
- package/tests/algebra/polynom.test.ts +10 -0
- package/tests/geometry/circle.test.ts +222 -1
- package/tests/numeric.test.ts +19 -3
- package/tsconfig.json +15 -4
- package/vite.config.js +23 -0
- package/webpack-production.config.js +22 -22
- package/webpack.config.js +22 -22
- package/dev/pimath.js +0 -7945
- package/dev/pimath.js.map +0 -1
- package/dist/pimath.js.map +0 -1
- package/dist/pimath.min.js +0 -2
- package/dist/pimath.min.js.map +0 -1
- package/esm/index.d.ts +0 -38
- package/esm/index.js +0 -44
- package/esm/index.js.map +0 -1
- package/esm/maths/algebra/equation.d.ts +0 -119
- package/esm/maths/algebra/equation.js +0 -797
- package/esm/maths/algebra/equation.js.map +0 -1
- package/esm/maths/algebra/linearSystem.d.ts +0 -39
- package/esm/maths/algebra/linearSystem.js +0 -279
- package/esm/maths/algebra/linearSystem.js.map +0 -1
- package/esm/maths/algebra/logicalset.d.ts +0 -28
- package/esm/maths/algebra/logicalset.js +0 -158
- package/esm/maths/algebra/logicalset.js.map +0 -1
- package/esm/maths/algebra/monom.d.ts +0 -206
- package/esm/maths/algebra/monom.js +0 -909
- package/esm/maths/algebra/monom.js.map +0 -1
- package/esm/maths/algebra/polynom.d.ts +0 -157
- package/esm/maths/algebra/polynom.js +0 -1305
- package/esm/maths/algebra/polynom.js.map +0 -1
- package/esm/maths/algebra/rational.d.ts +0 -46
- package/esm/maths/algebra/rational.js +0 -195
- package/esm/maths/algebra/rational.js.map +0 -1
- package/esm/maths/algebra/study/rationalStudy.d.ts +0 -28
- package/esm/maths/algebra/study/rationalStudy.js +0 -244
- package/esm/maths/algebra/study/rationalStudy.js.map +0 -1
- package/esm/maths/algebra/study.d.ts +0 -143
- package/esm/maths/algebra/study.js +0 -380
- package/esm/maths/algebra/study.js.map +0 -1
- package/esm/maths/coefficients/fraction.d.ts +0 -90
- package/esm/maths/coefficients/fraction.js +0 -517
- package/esm/maths/coefficients/fraction.js.map +0 -1
- package/esm/maths/coefficients/nthRoot.d.ts +0 -23
- package/esm/maths/coefficients/nthRoot.js +0 -137
- package/esm/maths/coefficients/nthRoot.js.map +0 -1
- package/esm/maths/geometry/circle.d.ts +0 -45
- package/esm/maths/geometry/circle.js +0 -324
- package/esm/maths/geometry/circle.js.map +0 -1
- package/esm/maths/geometry/line.d.ts +0 -99
- package/esm/maths/geometry/line.js +0 -485
- package/esm/maths/geometry/line.js.map +0 -1
- package/esm/maths/geometry/point.d.ts +0 -34
- package/esm/maths/geometry/point.js +0 -167
- package/esm/maths/geometry/point.js.map +0 -1
- package/esm/maths/geometry/triangle.d.ts +0 -91
- package/esm/maths/geometry/triangle.js +0 -276
- package/esm/maths/geometry/triangle.js.map +0 -1
- package/esm/maths/geometry/vector.d.ts +0 -41
- package/esm/maths/geometry/vector.js +0 -198
- package/esm/maths/geometry/vector.js.map +0 -1
- package/esm/maths/numeric.d.ts +0 -28
- package/esm/maths/numeric.js +0 -136
- package/esm/maths/numeric.js.map +0 -1
- package/esm/maths/numexp.d.ts +0 -19
- package/esm/maths/numexp.js +0 -186
- package/esm/maths/numexp.js.map +0 -1
- package/esm/maths/randomization/random.d.ts +0 -23
- package/esm/maths/randomization/random.js +0 -79
- package/esm/maths/randomization/random.js.map +0 -1
- package/esm/maths/randomization/randomCore.d.ts +0 -7
- package/esm/maths/randomization/randomCore.js +0 -22
- package/esm/maths/randomization/randomCore.js.map +0 -1
- package/esm/maths/randomization/rndFraction.d.ts +0 -12
- package/esm/maths/randomization/rndFraction.js +0 -44
- package/esm/maths/randomization/rndFraction.js.map +0 -1
- package/esm/maths/randomization/rndGeometryLine.d.ts +0 -12
- package/esm/maths/randomization/rndGeometryLine.js +0 -46
- package/esm/maths/randomization/rndGeometryLine.js.map +0 -1
- package/esm/maths/randomization/rndGeometryPoint.d.ts +0 -12
- package/esm/maths/randomization/rndGeometryPoint.js +0 -61
- package/esm/maths/randomization/rndGeometryPoint.js.map +0 -1
- package/esm/maths/randomization/rndHelpers.d.ts +0 -23
- package/esm/maths/randomization/rndHelpers.js +0 -98
- package/esm/maths/randomization/rndHelpers.js.map +0 -1
- package/esm/maths/randomization/rndMonom.d.ts +0 -12
- package/esm/maths/randomization/rndMonom.js +0 -53
- package/esm/maths/randomization/rndMonom.js.map +0 -1
- package/esm/maths/randomization/rndPolynom.d.ts +0 -13
- package/esm/maths/randomization/rndPolynom.js +0 -75
- package/esm/maths/randomization/rndPolynom.js.map +0 -1
- package/esm/maths/randomization/rndTypes.d.ts +0 -34
- package/esm/maths/randomization/rndTypes.js +0 -3
- package/esm/maths/randomization/rndTypes.js.map +0 -1
- package/esm/maths/shutingyard.d.ts +0 -59
- package/esm/maths/shutingyard.js +0 -443
- package/esm/maths/shutingyard.js.map +0 -1
- package/public/matrices.html +0 -100
- package/public/playground.html +0 -168
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { randomCoefficientConfig, randomGeometryLineConfig, randomGeometryPointConfig, randomMonomConfig, randomPolynomConfig } from "./rndTypes";
|
|
2
|
-
import { Polynom } from "../algebra/polynom";
|
|
3
|
-
import { Monom } from "../algebra/monom";
|
|
4
|
-
import { Fraction } from "../coefficients/fraction";
|
|
5
|
-
import { Line } from "../geometry/line";
|
|
6
|
-
import { Point } from "../geometry/point";
|
|
7
|
-
export * from "./rndTypes";
|
|
8
|
-
export declare namespace Random {
|
|
9
|
-
function polynom(config?: randomPolynomConfig): Polynom;
|
|
10
|
-
function monom(config?: randomMonomConfig): Monom;
|
|
11
|
-
function fraction(config?: randomCoefficientConfig): Fraction;
|
|
12
|
-
function number(from: number, to: number, exclude?: number[]): number;
|
|
13
|
-
function numberSym(max: number, allowZero?: boolean): number;
|
|
14
|
-
function prime(max: number): number;
|
|
15
|
-
function bool(percent?: number): boolean;
|
|
16
|
-
function array(arr: any[], number?: number): any[];
|
|
17
|
-
function item(arr: any[]): any;
|
|
18
|
-
function shuffle(arr: any[]): any[];
|
|
19
|
-
namespace Geometry {
|
|
20
|
-
function line(config?: randomGeometryLineConfig): Line;
|
|
21
|
-
function point(config?: randomGeometryPointConfig): Point;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Random = void 0;
|
|
18
|
-
const rndPolynom_1 = require("./rndPolynom");
|
|
19
|
-
const rndMonom_1 = require("./rndMonom");
|
|
20
|
-
const rndHelpers_1 = require("./rndHelpers");
|
|
21
|
-
const rndFraction_1 = require("./rndFraction");
|
|
22
|
-
const rndGeometryLine_1 = require("./rndGeometryLine");
|
|
23
|
-
const rndGeometryPoint_1 = require("./rndGeometryPoint");
|
|
24
|
-
__exportStar(require("./rndTypes"), exports);
|
|
25
|
-
var Random;
|
|
26
|
-
(function (Random) {
|
|
27
|
-
function polynom(config) {
|
|
28
|
-
return (new rndPolynom_1.rndPolynom(config)).generate();
|
|
29
|
-
}
|
|
30
|
-
Random.polynom = polynom;
|
|
31
|
-
function monom(config) {
|
|
32
|
-
return (new rndMonom_1.rndMonom(config)).generate();
|
|
33
|
-
}
|
|
34
|
-
Random.monom = monom;
|
|
35
|
-
function fraction(config) {
|
|
36
|
-
return (new rndFraction_1.rndFraction(config)).generate();
|
|
37
|
-
}
|
|
38
|
-
Random.fraction = fraction;
|
|
39
|
-
function number(from, to, exclude) {
|
|
40
|
-
return rndHelpers_1.rndHelpers.randomInt(from, to, exclude);
|
|
41
|
-
}
|
|
42
|
-
Random.number = number;
|
|
43
|
-
function numberSym(max, allowZero) {
|
|
44
|
-
return rndHelpers_1.rndHelpers.randomIntSym(max, allowZero);
|
|
45
|
-
}
|
|
46
|
-
Random.numberSym = numberSym;
|
|
47
|
-
function prime(max) {
|
|
48
|
-
return rndHelpers_1.rndHelpers.randomPrime(max);
|
|
49
|
-
}
|
|
50
|
-
Random.prime = prime;
|
|
51
|
-
function bool(percent) {
|
|
52
|
-
return rndHelpers_1.rndHelpers.randomBool(percent);
|
|
53
|
-
}
|
|
54
|
-
Random.bool = bool;
|
|
55
|
-
function array(arr, number) {
|
|
56
|
-
return rndHelpers_1.rndHelpers.randomArray(arr, number);
|
|
57
|
-
}
|
|
58
|
-
Random.array = array;
|
|
59
|
-
function item(arr) {
|
|
60
|
-
return rndHelpers_1.rndHelpers.randomItem(arr);
|
|
61
|
-
}
|
|
62
|
-
Random.item = item;
|
|
63
|
-
function shuffle(arr) {
|
|
64
|
-
return rndHelpers_1.rndHelpers.shuffleArray(arr);
|
|
65
|
-
}
|
|
66
|
-
Random.shuffle = shuffle;
|
|
67
|
-
let Geometry;
|
|
68
|
-
(function (Geometry) {
|
|
69
|
-
function line(config) {
|
|
70
|
-
return (new rndGeometryLine_1.rndGeometryLine(config).generate());
|
|
71
|
-
}
|
|
72
|
-
Geometry.line = line;
|
|
73
|
-
function point(config) {
|
|
74
|
-
return (new rndGeometryPoint_1.rndGeometryPoint(config).generate());
|
|
75
|
-
}
|
|
76
|
-
Geometry.point = point;
|
|
77
|
-
})(Geometry = Random.Geometry || (Random.Geometry = {}));
|
|
78
|
-
})(Random || (exports.Random = Random = {}));
|
|
79
|
-
//# sourceMappingURL=random.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../../src/maths/randomization/random.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6CAAwC;AACxC,yCAAoC;AACpC,6CAAwC;AAQxC,+CAA0C;AAK1C,uDAAkD;AAElD,yDAAoD;AAEpD,6CAA0B;AAE1B,IAAiB,MAAM,CAmDtB;AAnDD,WAAiB,MAAM;IACnB,SAAgB,OAAO,CAAC,MAA4B;QAChD,OAAO,CAAC,IAAI,uBAAU,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC9C,CAAC;IAFe,cAAO,UAEtB,CAAA;IAED,SAAgB,KAAK,CAAC,MAA0B;QAC5C,OAAO,CAAC,IAAI,mBAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC5C,CAAC;IAFe,YAAK,QAEpB,C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AAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;QACnD,CAAC;QAFe,aAAI,OAEnB,CAAA;QAED,SAAgB,KAAK,CAAC,MAAkC;YACpD,OAAO,CAAC,IAAI,mCAAgB,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;QACpD,CAAC;QAFe,cAAK,QAEpB,CAAA;IAEL,CAAC,EATgB,QAAQ,GAAR,eAAQ,KAAR,eAAQ,QASxB;AACL,CAAC,EAnDgB,MAAM,sBAAN,MAAM,QAmDtB"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomCore = void 0;
|
|
4
|
-
class randomCore {
|
|
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
|
-
}
|
|
21
|
-
exports.randomCore = randomCore;
|
|
22
|
-
//# sourceMappingURL=randomCore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"randomCore.js","sourceRoot":"","sources":["../../../src/maths/randomization/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,12 +0,0 @@
|
|
|
1
|
-
import { randomCore } from "./randomCore";
|
|
2
|
-
import { randomCoefficientConfig } from "./rndTypes";
|
|
3
|
-
import { Fraction } from "../coefficients/fraction";
|
|
4
|
-
/**
|
|
5
|
-
* Create a random monom based on a based configuration
|
|
6
|
-
*/
|
|
7
|
-
export declare class rndFraction extends randomCore {
|
|
8
|
-
protected _config: randomCoefficientConfig;
|
|
9
|
-
protected _defaultConfig: randomCoefficientConfig;
|
|
10
|
-
constructor(userConfig?: randomCoefficientConfig);
|
|
11
|
-
generate: () => Fraction;
|
|
12
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rndFraction = void 0;
|
|
4
|
-
const randomCore_1 = require("./randomCore");
|
|
5
|
-
const random_1 = require("./random");
|
|
6
|
-
const fraction_1 = require("../coefficients/fraction");
|
|
7
|
-
/**
|
|
8
|
-
* Create a random monom based on a based configuration
|
|
9
|
-
*/
|
|
10
|
-
class rndFraction extends randomCore_1.randomCore {
|
|
11
|
-
constructor(userConfig) {
|
|
12
|
-
super();
|
|
13
|
-
this.generate = () => {
|
|
14
|
-
let Q = new fraction_1.Fraction();
|
|
15
|
-
if (this._config.negative) {
|
|
16
|
-
Q.numerator = random_1.Random.numberSym(this._config.max, this._config.zero);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
Q.numerator = random_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
|
-
let securityCount = 0;
|
|
26
|
-
while (Q.isRelative() && securityCount < 10) {
|
|
27
|
-
Q.denominator = random_1.Random.number(1, this._config.max);
|
|
28
|
-
securityCount++;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return this._config.reduced ? Q.reduce() : Q;
|
|
32
|
-
};
|
|
33
|
-
this._defaultConfig = {
|
|
34
|
-
negative: true,
|
|
35
|
-
max: 10,
|
|
36
|
-
reduced: true,
|
|
37
|
-
zero: true,
|
|
38
|
-
natural: false
|
|
39
|
-
};
|
|
40
|
-
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.rndFraction = rndFraction;
|
|
44
|
-
//# sourceMappingURL=rndFraction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rndFraction.js","sourceRoot":"","sources":["../../../src/maths/randomization/rndFraction.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,qCAAgC;AAChC,uDAAkD;AAElD;;GAEG;AACH,MAAa,WAAY,SAAQ,uBAAU;IAIvC,YAAY,UAAoC;QAC5C,KAAK,EAAE,CAAC;QAaZ,aAAQ,GAAG,GAAa,EAAE;YACtB,IAAI,CAAC,GAAG,IAAI,mBAAQ,EAAE,CAAA;YAEtB,IAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAC;gBACrB,CAAC,CAAC,SAAS,GAAG,eAAM,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;aACtE;iBAAK;gBACF,CAAC,CAAC,SAAS,GAAG,eAAM,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,IAAI,aAAa,GAAG,CAAC,CAAA;gBACrB,OAAM,CAAC,CAAC,UAAU,EAAE,IAAI,aAAa,GAAC,EAAE,EAAE;oBACtC,CAAC,CAAC,WAAW,GAAG,eAAM,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;oBAClD,aAAa,EAAE,CAAA;iBAClB;aACJ;YAED,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAA,CAAC,CAAA,CAAC,CAAC,MAAM,EAAE,CAAA,CAAC,CAAA,CAAC,CAAA;QAC5C,CAAC,CAAA;QA9BG,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;CAsBJ;AAtCD,kCAsCC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { randomCore } from "./randomCore";
|
|
2
|
-
import { randomGeometryLineConfig } from "./random";
|
|
3
|
-
import { Line } from "../geometry/line";
|
|
4
|
-
/**
|
|
5
|
-
* Create a random monom based on a based configuration
|
|
6
|
-
*/
|
|
7
|
-
export declare class rndGeometryLine extends randomCore {
|
|
8
|
-
protected _config: randomGeometryLineConfig;
|
|
9
|
-
protected _defaultConfig: randomGeometryLineConfig;
|
|
10
|
-
constructor(userConfig?: randomGeometryLineConfig);
|
|
11
|
-
generate: () => Line;
|
|
12
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=rndGeometryLine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rndGeometryLine.js","sourceRoot":"","sources":["../../../src/maths/randomization/rndGeometryLine.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AACxC,qCAA0D;AAC1D,2CAAsC;AACtC,+CAA0C;AAC1C,6CAAwC;AAExC;;GAEG;AACH,MAAa,eAAgB,SAAQ,uBAAU;IAI3C,YAAY,UAAqC;QAC7C,KAAK,EAAE,CAAC;QAcZ,aAAQ,GAAG,GAAS,EAAE;YAClB,sBAAsB;YACtB,MAAM,CAAC,GAAG,IAAI,eAAM,CAChB,eAAM,CAAC,SAAS,CAAC,EAAE,CAAC,EACpB,eAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CACvB,CAAA;YAED,OAAO,CAAC,CAAC,MAAM,EAAE;gBACb,CAAC,CAAC,CAAC,GAAG,eAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;gBAC1B,CAAC,CAAC,CAAC,GAAG,eAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;aAC7B;YAED,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,EAAE;gBAC1B,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;oBAC3B,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;iBAChB;aACJ;iBAAM,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE;gBAClC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;oBAC3B,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;iBAChB;aACJ;YAED,OAAO,IAAI,WAAI,CAAC,IAAI,aAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACrE,CAAC,CAAA;QAnCG,IAAI,CAAC,cAAc,GAAG;YAClB,CAAC,EAAE;gBACC,CAAC,EAAE,eAAM,CAAC,SAAS,CAAC,EAAE,CAAC;gBACvB,CAAC,EAAE,eAAM,CAAC,SAAS,CAAC,EAAE,CAAC;aAC1B;SACJ,CAAA;QAED,uCAAuC;QACvC,aAAa;QACb,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IACpE,CAAC;CA0BJ;AA3CD,0CA2CC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=rndGeometryPoint.js.map
|
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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, exclude?: 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,98 +0,0 @@
|
|
|
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, exclude) {
|
|
22
|
-
if (b === undefined) {
|
|
23
|
-
if (a >= 0) {
|
|
24
|
-
return this.randomInt(0, a);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return this.randomInt(a, 0);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
// Same start and end values
|
|
31
|
-
if (a === b) {
|
|
32
|
-
return a;
|
|
33
|
-
}
|
|
34
|
-
// No exclusion
|
|
35
|
-
if (exclude === undefined) {
|
|
36
|
-
return Math.floor(Math.random() * (b - a + 1) + a);
|
|
37
|
-
}
|
|
38
|
-
// With exclusion
|
|
39
|
-
if (Math.abs(b - a) <= exclude.length) {
|
|
40
|
-
throw new Error('The number of excluded values is too high.');
|
|
41
|
-
}
|
|
42
|
-
let r = this.randomInt(a, b);
|
|
43
|
-
while (exclude.includes(r)) {
|
|
44
|
-
r = this.randomInt(a, b);
|
|
45
|
-
}
|
|
46
|
-
return r;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Random integer between -max and max value.
|
|
50
|
-
* @param max (number) : determine the limits.
|
|
51
|
-
* @param zero (bool) : determine if zero is allowed or not.
|
|
52
|
-
*/
|
|
53
|
-
static randomIntSym(max, zero) {
|
|
54
|
-
if (zero === false) {
|
|
55
|
-
return this.randomBool() ? this.randomInt(1, max) : -this.randomInt(1, max);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return this.randomInt(-max, max);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
static randomPrime(max) {
|
|
62
|
-
let primes = numeric_1.Numeric.primes();
|
|
63
|
-
if (max !== undefined) {
|
|
64
|
-
primes = primes.filter(x => x < max);
|
|
65
|
-
}
|
|
66
|
-
return this.randomItem(primes);
|
|
67
|
-
}
|
|
68
|
-
static randomArray(arr, number) {
|
|
69
|
-
if (number === undefined) {
|
|
70
|
-
number = 1;
|
|
71
|
-
}
|
|
72
|
-
// Return a clone array
|
|
73
|
-
if (arr.length <= 0) {
|
|
74
|
-
return Object.values(arr);
|
|
75
|
-
}
|
|
76
|
-
// Randomize the array and return the n first elements.
|
|
77
|
-
return rndHelpers.shuffleArray(arr).slice(0, number);
|
|
78
|
-
}
|
|
79
|
-
static randomItem(arr) {
|
|
80
|
-
if (arr.length === 0) {
|
|
81
|
-
return '';
|
|
82
|
-
}
|
|
83
|
-
return arr[this.randomInt(0, arr.length - 1)];
|
|
84
|
-
}
|
|
85
|
-
static shuffleArray(arr) {
|
|
86
|
-
// The Fisher-Yates algorithm
|
|
87
|
-
let shuffleArray = Object.values(arr);
|
|
88
|
-
for (let i = shuffleArray.length - 1; i > 0; i--) {
|
|
89
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
90
|
-
const temp = shuffleArray[i];
|
|
91
|
-
shuffleArray[i] = shuffleArray[j];
|
|
92
|
-
shuffleArray[j] = temp;
|
|
93
|
-
}
|
|
94
|
-
return shuffleArray;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.rndHelpers = rndHelpers;
|
|
98
|
-
//# sourceMappingURL=rndHelpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rndHelpers.js","sourceRoot":"","sources":["../../../src/maths/randomization/rndHelpers.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,wCAAmC;AAEnC,MAAa,UAAU;IAEnB;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,UAAkB,GAAG;QACnC,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,CAAS,EAAE,CAAU,EAAE,OAAkB;QACtD,IAAI,CAAC,KAAK,SAAS,EAAE;YACjB,IAAI,CAAC,IAAI,CAAC,EAAE;gBACR,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aAC/B;iBAAM;gBACH,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aAC/B;SACJ;QAED,4BAA4B;QAC5B,IAAI,CAAC,KAAK,CAAC,EAAE;YACT,OAAO,CAAC,CAAA;SACX;QAED,eAAe;QACf,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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 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=rndMonom.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rndMonom.js","sourceRoot":"","sources":["../../../src/maths/randomization/rndMonom.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,qCAAgC;AAChC,4CAAuC;AAEvC;;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,aAAK,EAAE,CAAA;YAEnB,2BAA2B;YAC3B,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE;gBAC5C,CAAC,CAAC,WAAW,GAAG,eAAM,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,eAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;aACzD;YAED,oCAAoC;Y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* 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,75 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=rndPolynom.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rndPolynom.js","sourceRoot":"","sources":["../../../src/maths/randomization/rndPolynom.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,yCA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