pimath 0.0.128 → 0.0.129

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.
Files changed (160) hide show
  1. package/dist/main.d.ts +39 -0
  2. package/dist/maths/algebra/equation.d.ts +120 -0
  3. package/dist/maths/algebra/linearSystem.d.ts +40 -0
  4. package/dist/maths/algebra/logicalset.d.ts +28 -0
  5. package/dist/maths/algebra/monom.d.ts +207 -0
  6. package/dist/maths/algebra/polynom.d.ts +155 -0
  7. package/dist/maths/algebra/rational.d.ts +44 -0
  8. package/dist/maths/algebra/study/rationalStudy.d.ts +14 -0
  9. package/dist/maths/algebra/study.d.ts +140 -0
  10. package/dist/maths/coefficients/fraction.d.ts +90 -0
  11. package/dist/maths/coefficients/nthRoot.d.ts +23 -0
  12. package/dist/maths/geometry/circle.d.ts +46 -0
  13. package/dist/maths/geometry/line.d.ts +102 -0
  14. package/dist/maths/geometry/point.d.ts +36 -0
  15. package/dist/maths/geometry/triangle.d.ts +92 -0
  16. package/dist/maths/geometry/vector.d.ts +38 -0
  17. package/dist/maths/numeric.d.ts +28 -0
  18. package/dist/maths/numexp.d.ts +19 -0
  19. package/dist/maths/randomization/random.d.ts +26 -0
  20. package/dist/maths/randomization/randomCore.d.ts +7 -0
  21. package/dist/maths/randomization/rndFraction.d.ts +13 -0
  22. package/dist/maths/randomization/rndGeometryCircle.d.ts +13 -0
  23. package/dist/maths/randomization/rndGeometryLine.d.ts +13 -0
  24. package/dist/maths/randomization/rndGeometryPoint.d.ts +13 -0
  25. package/dist/maths/randomization/rndHelpers.d.ts +23 -0
  26. package/dist/maths/randomization/rndMonom.d.ts +13 -0
  27. package/dist/maths/randomization/rndPolynom.d.ts +14 -0
  28. package/dist/maths/randomization/rndTypes.d.ts +40 -0
  29. package/dist/maths/shutingyard.d.ts +59 -0
  30. package/dist/pimath.js +85 -85
  31. package/package.json +10 -12
  32. package/.eslintrc.js +0 -24
  33. package/.idea/$CACHE_FILE$ +0 -6
  34. package/.idea/PI.iml +0 -14
  35. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  36. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  37. package/.idea/jsLibraryMappings.xml +0 -6
  38. package/.idea/misc.xml +0 -6
  39. package/.idea/modules.xml +0 -8
  40. package/.idea/php.xml +0 -19
  41. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +0 -192
  42. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]1/shelved.patch +0 -0
  43. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30__Default_Changelist_.xml +0 -4
  44. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +0 -2404
  45. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +0 -4
  46. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +0 -1362
  47. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +0 -4
  48. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +0 -90
  49. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +0 -4
  50. package/.idea/vcs.xml +0 -6
  51. package/dist/demo/exercises.html +0 -283
  52. package/dist/demo/matrices.html +0 -39
  53. package/dist/demo/playground.html +0 -20
  54. package/dist/demo.css +0 -3
  55. package/dist/pimath.umd.cjs +0 -15
  56. package/docs/.nojekyll +0 -1
  57. package/docs/assets/highlight.css +0 -78
  58. package/docs/assets/main.js +0 -59
  59. package/docs/assets/navigation.js +0 -1
  60. package/docs/assets/search.js +0 -1
  61. package/docs/assets/style.css +0 -1383
  62. package/docs/classes/Logicalset.Logicalset.html +0 -217
  63. package/docs/classes/Polynom.Rational.html +0 -397
  64. package/docs/classes/Vector-1.Vector.html +0 -490
  65. package/docs/classes/Vector.Point.html +0 -337
  66. package/docs/classes/algebra_equation.Equation.html +0 -790
  67. package/docs/classes/algebra_linearSystem.LinearSystem.html +0 -404
  68. package/docs/classes/algebra_monom.Monom.html +0 -962
  69. package/docs/classes/algebra_polynom.Polynom.html +0 -1275
  70. package/docs/classes/coefficients_fraction.Fraction.html +0 -934
  71. package/docs/classes/geometry_circle.Circle.html +0 -472
  72. package/docs/classes/geometry_line.Line.html +0 -774
  73. package/docs/classes/geometry_triangle.Triangle.html +0 -429
  74. package/docs/classes/numeric.Numeric.html +0 -265
  75. package/docs/classes/shutingyard.Shutingyard.html +0 -250
  76. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +0 -83
  77. package/docs/enums/geometry_line.LinePropriety.html +0 -97
  78. package/docs/enums/shutingyard.ShutingyardMode.html +0 -97
  79. package/docs/enums/shutingyard.ShutingyardType.html +0 -111
  80. package/docs/index.html +0 -63
  81. package/docs/interfaces/algebra_equation.ISolution.html +0 -105
  82. package/docs/interfaces/algebra_polynom.IEuclidian.html +0 -87
  83. package/docs/interfaces/geometry_triangle.remarquableLines.html +0 -163
  84. package/docs/modules/Logicalset.html +0 -65
  85. package/docs/modules/Polynom.html +0 -65
  86. package/docs/modules/Vector-1.html +0 -65
  87. package/docs/modules/Vector.html +0 -65
  88. package/docs/modules/algebra_equation.html +0 -69
  89. package/docs/modules/algebra_linearSystem.html +0 -61
  90. package/docs/modules/algebra_monom.html +0 -65
  91. package/docs/modules/algebra_polynom.html +0 -69
  92. package/docs/modules/coefficients_fraction.html +0 -65
  93. package/docs/modules/geometry_circle.html +0 -61
  94. package/docs/modules/geometry_line.html +0 -65
  95. package/docs/modules/geometry_triangle.html +0 -65
  96. package/docs/modules/numeric.html +0 -61
  97. package/docs/modules/shutingyard.html +0 -75
  98. package/docs/types/algebra_monom.literalType.html +0 -61
  99. package/docs/types/algebra_polynom.PolynomParsingType.html +0 -56
  100. package/docs/types/coefficients_fraction.FractionParsingType.html +0 -56
  101. package/docs/types/shutingyard.Token.html +0 -63
  102. package/docs/types/shutingyard.tokenType.html +0 -68
  103. package/docs/variables/shutingyard.tokenConstant.html +0 -61
  104. package/index.html +0 -15
  105. package/public/demo/exercises.html +0 -283
  106. package/public/demo/matrices.html +0 -39
  107. package/public/demo/playground.html +0 -20
  108. package/public/demo.css +0 -3
  109. package/src/demo/exercises.ts +0 -0
  110. package/src/demo/matrices.ts +0 -61
  111. package/src/demo/playground.ts +0 -153
  112. package/src/main.ts +0 -42
  113. package/src/maths/algebra/equation.ts +0 -897
  114. package/src/maths/algebra/linearSystem.ts +0 -370
  115. package/src/maths/algebra/logicalset.ts +0 -183
  116. package/src/maths/algebra/monom.ts +0 -1028
  117. package/src/maths/algebra/polynom.ts +0 -1537
  118. package/src/maths/algebra/rational.ts +0 -244
  119. package/src/maths/algebra/study/rationalStudy.ts +0 -287
  120. package/src/maths/algebra/study.ts +0 -506
  121. package/src/maths/coefficients/fraction.ts +0 -593
  122. package/src/maths/coefficients/nthRoot.ts +0 -148
  123. package/src/maths/geometry/circle.ts +0 -382
  124. package/src/maths/geometry/line.ts +0 -604
  125. package/src/maths/geometry/point.ts +0 -215
  126. package/src/maths/geometry/triangle.ts +0 -368
  127. package/src/maths/geometry/vector.ts +0 -242
  128. package/src/maths/numeric.ts +0 -162
  129. package/src/maths/numexp.ts +0 -184
  130. package/src/maths/randomization/random.ts +0 -80
  131. package/src/maths/randomization/randomCore.ts +0 -19
  132. package/src/maths/randomization/rndFraction.ts +0 -47
  133. package/src/maths/randomization/rndGeometryCircle.ts +0 -50
  134. package/src/maths/randomization/rndGeometryLine.ts +0 -53
  135. package/src/maths/randomization/rndGeometryPoint.ts +0 -69
  136. package/src/maths/randomization/rndHelpers.ts +0 -107
  137. package/src/maths/randomization/rndMonom.ts +0 -57
  138. package/src/maths/randomization/rndPolynom.ts +0 -90
  139. package/src/maths/randomization/rndTypes.ts +0 -43
  140. package/src/maths/shutingyard.ts +0 -496
  141. package/tests/algebra/equation.test.ts +0 -64
  142. package/tests/algebra/linear.test.ts +0 -58
  143. package/tests/algebra/monom.test.ts +0 -78
  144. package/tests/algebra/polynom.test.ts +0 -343
  145. package/tests/algebra/rationnal.test.ts +0 -64
  146. package/tests/algebra/study.test.ts +0 -48
  147. package/tests/coefficients/fraction.test.ts +0 -131
  148. package/tests/custom.test.ts +0 -33
  149. package/tests/geometry/circle.test.ts +0 -404
  150. package/tests/geometry/line.test.ts +0 -36
  151. package/tests/numeric.test.ts +0 -43
  152. package/tests/numexp.test.ts +0 -89
  153. package/tests/shutingyard.test.ts +0 -58
  154. package/tsconfig.json +0 -52
  155. package/tsconfig.testing.json +0 -28
  156. package/typedoc.katex.js +0 -11
  157. package/vite.config.js +0 -23
  158. package/webpack-production-min.config.js +0 -26
  159. package/webpack-production.config.js +0 -26
  160. package/webpack.config.js +0 -26
@@ -1,47 +0,0 @@
1
- import {randomCore} from "./randomCore";
2
- import {randomCoefficientConfig, randomMonomConfig, randomPolynomConfig} from "./rndTypes";
3
- import {Random} from "./random";
4
- import {Fraction} from "../coefficients/fraction";
5
-
6
- /**
7
- * Create a random monom based on a based configuration
8
- */
9
- export class rndFraction extends randomCore {
10
- declare protected _config: randomCoefficientConfig
11
- declare protected _defaultConfig: randomCoefficientConfig
12
-
13
- constructor(userConfig?: randomCoefficientConfig) {
14
- super();
15
-
16
- this._defaultConfig = {
17
- negative: true,
18
- max: 10,
19
- reduced: true,
20
- zero: true,
21
- natural: false
22
- }
23
-
24
- this._config = this.mergeConfig(userConfig, this._defaultConfig)
25
- }
26
-
27
- generate = (): Fraction => {
28
- let Q = new Fraction()
29
-
30
- if(this._config.negative){
31
- Q.numerator = Random.numberSym(this._config.max, this._config.zero)
32
- }else {
33
- Q.numerator = Random.number(this._config.zero ? 0 : 1, this._config.max)
34
- }
35
- if(this._config.natural){
36
- Q.denominator = 1
37
- }else {
38
- let securityCount = 0
39
- while(Q.isRelative() && securityCount<10) {
40
- Q.denominator = Random.number(1, this._config.max)
41
- securityCount++
42
- }
43
- }
44
-
45
- return this._config.reduced?Q.reduce():Q
46
- }
47
- }
@@ -1,50 +0,0 @@
1
- import {randomCore} from "./randomCore";
2
- import {Random, randomGeometryCircleConfig} from "./random";
3
- import {Circle} from "../geometry/circle";
4
-
5
- /**
6
- * Create a random monom based on a based configuration
7
- */
8
- export class rndGeometryCircle extends randomCore {
9
- declare protected _config: randomGeometryCircleConfig
10
- declare protected _defaultConfig: randomGeometryCircleConfig
11
-
12
- generate = (): Circle => {
13
- const center = Random.Geometry.point(this._config.center)
14
-
15
- let rv, r
16
- if (this._config.pointsOnCircle === 8) {
17
- rv = Random.number(1, 3),
18
- r = rv ** 2 + (rv + 1) ** 2
19
- } else {
20
- r = Random.number(1, 20)
21
- }
22
-
23
- const c = new Circle(center, r, true)
24
-
25
-
26
- // let pts = c.getPointsOnCircle(true)
27
- //
28
- // pts = Random.shuffle(pts)
29
- // let ptt = pts.shift(),
30
- // pt1 = pts.shift(),
31
- // pt2
32
- //
33
- // for (let pt of pts) {
34
- // if (!pt1.x.isEqual(pt.x) && !pt1.y.isEqual(pt.y) && !A.isEqual(new Point().middleOf(pt1, pt))) {
35
- // pt2 = pt.clone()
36
- // break
37
- // }
38
- // }
39
-
40
- return c
41
-
42
- }
43
-
44
- constructor(userConfig?: randomGeometryCircleConfig) {
45
- super();
46
-
47
- this._defaultConfig = {}
48
- this._config = this.mergeConfig(userConfig, this._defaultConfig)
49
- }
50
- }
@@ -1,53 +0,0 @@
1
- import {randomCore} from "./randomCore";
2
- import {Random, randomGeometryLineConfig} from "./random";
3
- import {Line} from "../geometry/line";
4
- import {Vector} from "../geometry/vector";
5
- import {Point} from "../geometry/point";
6
-
7
- /**
8
- * Create a random monom based on a based configuration
9
- */
10
- export class rndGeometryLine extends randomCore {
11
- declare protected _config: randomGeometryLineConfig
12
- declare protected _defaultConfig: randomGeometryLineConfig
13
-
14
- constructor(userConfig?: randomGeometryLineConfig) {
15
- super();
16
-
17
- this._defaultConfig = {
18
- A: {
19
- x: Random.numberSym(10),
20
- y: Random.numberSym(10)
21
- },
22
- }
23
-
24
- // TODO: Strange that it raise an error
25
- // @ts-ignore
26
- this._config = this.mergeConfig(userConfig, this._defaultConfig)
27
- }
28
-
29
- generate = (): Line => {
30
- // The A point exists.
31
- const d = new Vector(
32
- Random.numberSym(10),
33
- Random.numberSym(10)
34
- )
35
-
36
- while (d.isNull) {
37
- d.x = Random.numberSym(10)
38
- d.y = Random.numberSym(10)
39
- }
40
-
41
- if (this._config.slope === 1) {
42
- if (d.x.sign() !== d.y.sign()) {
43
- d.y.opposed()
44
- }
45
- } else if (this._config.slope === -1) {
46
- if (d.x.sign() !== d.y.sign()) {
47
- d.y.opposed()
48
- }
49
- }
50
-
51
- return new Line(new Point(this._config.A.x, this._config.A.y), d)
52
- }
53
- }
@@ -1,69 +0,0 @@
1
- import {randomCore} from "./randomCore";
2
- import {Random, randomGeometryPointConfig} from "./random";
3
- import {Point} from "../geometry/point";
4
- import {Fraction} from "../coefficients/fraction";
5
-
6
- /**
7
- * Create a random monom based on a based configuration
8
- */
9
- export class rndGeometryPoint extends randomCore {
10
- declare protected _config: randomGeometryPointConfig
11
- declare protected _defaultConfig: randomGeometryPointConfig
12
-
13
- constructor(userConfig?: randomGeometryPointConfig) {
14
- super();
15
-
16
- this._defaultConfig = {
17
- axis: true,
18
- fraction: false,
19
- max: 10
20
- }
21
-
22
- this._config = this.mergeConfig(userConfig, this._defaultConfig)
23
- }
24
-
25
- generate = (): Point => {
26
- let x: Fraction, y: Fraction,
27
- zeroX = this._config.axis === true || this._config.axis === 'x',
28
- zeroY = this._config.axis === true || this._config.axis === 'y'
29
-
30
- x = this._config.fraction ?
31
- Random.fraction({max: this._config.max, zero: zeroX}) :
32
- new Fraction(Random.numberSym(this._config.max, zeroX))
33
-
34
- y = this._config.fraction ?
35
- Random.fraction({max: this._config.max, zero: zeroY}) :
36
- new Fraction(Random.numberSym(this._config.max, zeroY))
37
-
38
- if (+this._config.quadrant === 1) {
39
- x.abs()
40
- y.abs()
41
- }
42
- if (+this._config.quadrant === 2) {
43
- if (x.isPositive()) {
44
- x.opposed()
45
- }
46
- if (y.isNegative()) {
47
- y.opposed()
48
- }
49
- }
50
- if (+this._config.quadrant === 3) {
51
- if (x.isPositive()) {
52
- x.opposed()
53
- }
54
- if (y.isPositive()) {
55
- y.opposed()
56
- }
57
- }
58
- if (+this._config.quadrant === 4) {
59
- if (x.isNegative()) {
60
- x.opposed()
61
- }
62
- if (y.isPositive()) {
63
- y.opposed()
64
- }
65
- }
66
-
67
- return new Point(x, y)
68
- }
69
- }
@@ -1,107 +0,0 @@
1
- /**
2
- * Random helpers
3
- */
4
- import {Numeric} from "../numeric";
5
-
6
- export class rndHelpers {
7
-
8
- /**
9
- * Random boolean with a percent ratio
10
- * @param percent
11
- */
12
- static randomBool(percent: number = 0.5): boolean {
13
- return Math.random() < percent;
14
- }
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: number, b?: number, exclude?: number[]): number {
22
- if (b === undefined) {
23
- if (a >= 0) {
24
- return this.randomInt(0, a);
25
- } else {
26
- return this.randomInt(a, 0);
27
- }
28
- }
29
-
30
- // Same start and end values
31
- if (a === b) {
32
- return a
33
- }
34
-
35
- // No exclusion
36
- if (exclude === undefined) {
37
- return Math.floor(Math.random() * (b - a + 1) + a);
38
- }
39
-
40
- // With exclusion
41
- if (Math.abs(b - a) <= exclude.length) {
42
- throw new Error('The number of excluded values is too high.')
43
- }
44
-
45
- let r = this.randomInt(a, b)
46
- while (exclude.includes(r)) {
47
- r = this.randomInt(a, b)
48
- }
49
- return r
50
- }
51
-
52
- /**
53
- * Random integer between -max and max value.
54
- * @param max (number) : determine the limits.
55
- * @param zero (bool) : determine if zero is allowed or not.
56
- */
57
- static randomIntSym(max: number, zero?: boolean): number {
58
- if (zero === false) {
59
- return this.randomBool() ? this.randomInt(1, max) : -this.randomInt(1, max);
60
- } else {
61
- return this.randomInt(-max, max);
62
- }
63
- }
64
-
65
- static randomPrime(max: number): number {
66
- let primes = Numeric.primes()
67
- if (max !== undefined) {
68
- primes = primes.filter(x => x < max)
69
- }
70
- return this.randomItem(primes)
71
- }
72
-
73
- static randomArray(arr: any[], number?: number): any[] {
74
- if (number === undefined) {
75
- number = 1
76
- }
77
-
78
- // Return a clone array
79
- if (arr.length <= 0) {
80
- return Object.values(arr)
81
- }
82
-
83
- // Randomize the array and return the n first elements.
84
- return rndHelpers.shuffleArray(arr).slice(0, number);
85
- }
86
-
87
- static randomItem(arr: any[]): any {
88
- if (arr.length === 0) {
89
- return ''
90
- }
91
- return arr[this.randomInt(0, arr.length - 1)]
92
- }
93
-
94
- static shuffleArray(arr: any[]): any[] {
95
- // The Fisher-Yates algorithm
96
- let shuffleArray = Object.values(arr)
97
- for (let i = shuffleArray.length - 1; i > 0; i--) {
98
- const j = Math.floor(Math.random() * (i + 1));
99
- const temp = shuffleArray[i];
100
- shuffleArray[i] = shuffleArray[j];
101
- shuffleArray[j] = temp;
102
- }
103
-
104
- return shuffleArray;
105
- }
106
-
107
- }
@@ -1,57 +0,0 @@
1
- import {randomCore} from "./randomCore";
2
- import {randomMonomConfig} from "./rndTypes";
3
- import {Random} from "./random";
4
- import {Monom} from "../algebra/monom";
5
-
6
- /**
7
- * Create a random monom based on a based configuration
8
- */
9
- export class rndMonom extends randomCore {
10
- declare protected _config: randomMonomConfig
11
- declare protected _defaultConfig: randomMonomConfig
12
-
13
- constructor(userConfig?: randomMonomConfig) {
14
- super();
15
-
16
- this._defaultConfig = {
17
- letters: 'x',
18
- degree: 2,
19
- fraction: true,
20
- zero: false
21
- }
22
-
23
- this._config = this.mergeConfig(userConfig, this._defaultConfig)
24
- }
25
-
26
- generate = (): Monom => {
27
- // Create a monom instance
28
- let M = new Monom()
29
-
30
- // Generate the coefficient
31
- if (typeof this._config.fraction === "boolean") {
32
- M.coefficient = Random.fraction({
33
- zero: this._config.zero,
34
- reduced: true,
35
- natural: !this._config.fraction
36
- })
37
- } else {
38
- M.coefficient = Random.fraction(this._config.fraction)
39
- }
40
-
41
- // Calculate the degree of the monom
42
- if (this._config.letters.length > 1) {
43
- // Initialise each items...
44
- for (let L of this._config.letters.split('')) {
45
- M.setLetter(L, 0);
46
- }
47
- for (let i = 0; i < this._config.degree; i++) {
48
- const L = Random.item(this._config.letters.split(""))
49
- M.setLetter(L, M.degree(L).clone().add(1))
50
- }
51
- } else {
52
- M.setLetter(this._config.letters, this._config.degree)
53
- }
54
-
55
- return M
56
- }
57
- }
@@ -1,90 +0,0 @@
1
- import {randomCore} from "./randomCore";
2
- import {randomPolynomConfig} from "./rndTypes";
3
- import {rndMonom} from "./rndMonom";
4
- import {Random} from "./random";
5
- import {Polynom} from "../algebra/polynom";
6
- import {Monom} from "../algebra/monom";
7
-
8
- /**
9
- * Random polynoms
10
- */
11
- export class rndPolynom extends randomCore {
12
- declare protected _config: randomPolynomConfig
13
- declare protected _defaultConfig: randomPolynomConfig
14
-
15
- constructor(userConfig?: randomPolynomConfig) {
16
- super();
17
-
18
- // Default config for a random polynom
19
- this._defaultConfig = {
20
- letters: 'x',
21
- degree: 2,
22
- fraction: false,
23
- zero: false,
24
- unit: false,
25
- factorable: false,
26
- allowNullMonom: true,
27
- numberOfMonoms: 0,
28
- positive: true
29
- }
30
-
31
- // Merge config with initialiser
32
- this._config = this.mergeConfig(userConfig, this._defaultConfig)
33
- }
34
-
35
- generate = (): Polynom => {
36
- if(this._config.factorable && this._config.degree>1){
37
- return this.factorable()
38
- }
39
-
40
- // Create the polynom
41
- let P = new Polynom().empty(),
42
- M: Monom
43
-
44
- for (let i = this._config.degree; i >= 0; i--) {
45
- // Create monom of corresponding degree.
46
- M = new rndMonom({
47
- letters: this._config.letters,
48
- degree: i,
49
- fraction: this._config.fraction,
50
- zero: (i === this._config.degree) ? false : this._config.allowNullMonom
51
- }).generate()
52
-
53
- // If degree is the greatest and unit is true, set the monom value to one.
54
- if (this._config.unit && this._config.degree === i) {
55
- M.coefficient.one()
56
- }
57
-
58
- // Add to the polynom
59
- P.add(M)
60
- }
61
-
62
- // Make sure the first monom is positive.
63
- if(this._config.positive && P.monomByDegree().coefficient.isNegative()){
64
- P.monomByDegree().coefficient.opposed()
65
- }
66
-
67
- // If the number of monoms is greater than the allowed value, remove some of them... except the first one !
68
- if (this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < P.length) {
69
- // Get the greatest degree monom
70
- let M = P.monomByDegree().clone()
71
- P.monoms = Random.array(P.monoms.slice(1), this._config.numberOfMonoms-1)
72
- P.add(M).reorder().reduce()
73
- }
74
- return P
75
- }
76
-
77
- factorable = (): Polynom => {
78
- let P = new Polynom().one()
79
-
80
- let _factorableConfig = {...this._config}
81
- _factorableConfig.degree = 1
82
- _factorableConfig.factorable = false
83
-
84
- for(let i=0; i<this._config.degree;i++){
85
- P.multiply(Random.polynom(_factorableConfig))
86
- }
87
-
88
- return P
89
- }
90
- }
@@ -1,43 +0,0 @@
1
- import {Fraction} from "../coefficients/fraction";
2
-
3
- export type randomCoefficientConfig = {
4
- negative?: boolean,
5
- max?: number,
6
- reduced?: boolean,
7
- zero?: boolean,
8
- natural?: boolean
9
- }
10
-
11
- export type randomMonomConfig = {
12
- letters?: string,
13
- degree?: number,
14
- fraction?: boolean | randomCoefficientConfig,
15
- zero?: boolean
16
- }
17
-
18
- export type randomPolynomConfig = randomMonomConfig & {
19
- unit?: boolean,
20
- factorable?: boolean,
21
- allowNullMonom?: boolean,
22
- numberOfMonoms?: number,
23
- positive?: boolean
24
- }
25
-
26
- export type randomGeometryLineConfig = {
27
- A: { x: number | Fraction, y: number | Fraction },
28
- slope?: Fraction | string | number,
29
- }
30
-
31
-
32
- export type randomGeometryPointConfig = {
33
- quadrant?: number,
34
- axis?: string | boolean,
35
- fraction?: boolean,
36
- max?: number
37
- }
38
-
39
- export type randomGeometryCircleConfig = {
40
- center?: randomGeometryPointConfig,
41
- radius?: number,
42
- pointsOnCircle?: number
43
- }