pimath 0.0.127 → 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 (212) hide show
  1. package/dist/main.d.ts +39 -0
  2. package/{esm → dist}/maths/algebra/equation.d.ts +11 -10
  3. package/{esm → dist}/maths/algebra/linearSystem.d.ts +5 -4
  4. package/{esm → dist}/maths/algebra/monom.d.ts +5 -4
  5. package/{esm → dist}/maths/algebra/polynom.d.ts +11 -13
  6. package/{esm → dist}/maths/algebra/rational.d.ts +7 -9
  7. package/dist/maths/algebra/study/rationalStudy.d.ts +14 -0
  8. package/{esm → dist}/maths/algebra/study.d.ts +4 -7
  9. package/{esm → dist}/maths/geometry/circle.d.ts +9 -8
  10. package/{esm → dist}/maths/geometry/line.d.ts +17 -14
  11. package/{esm → dist}/maths/geometry/point.d.ts +11 -9
  12. package/{esm → dist}/maths/geometry/triangle.d.ts +4 -3
  13. package/{esm → dist}/maths/geometry/vector.d.ts +7 -10
  14. package/{esm → dist}/maths/randomization/random.d.ts +10 -7
  15. package/{esm → dist}/maths/randomization/rndFraction.d.ts +4 -3
  16. package/dist/maths/randomization/rndGeometryCircle.d.ts +13 -0
  17. package/{esm → dist}/maths/randomization/rndGeometryLine.d.ts +4 -3
  18. package/{esm → dist}/maths/randomization/rndGeometryPoint.d.ts +4 -3
  19. package/{esm → dist}/maths/randomization/rndMonom.d.ts +5 -4
  20. package/{esm → dist}/maths/randomization/rndPolynom.d.ts +5 -4
  21. package/{esm → dist}/maths/randomization/rndTypes.d.ts +7 -1
  22. package/dist/pimath.js +4239 -7819
  23. package/package.json +13 -7
  24. package/.eslintrc.js +0 -24
  25. package/.idea/$CACHE_FILE$ +0 -6
  26. package/.idea/PI.iml +0 -14
  27. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  28. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  29. package/.idea/misc.xml +0 -6
  30. package/.idea/modules.xml +0 -8
  31. package/.idea/php.xml +0 -19
  32. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +0 -192
  33. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]1/shelved.patch +0 -0
  34. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30__Default_Changelist_.xml +0 -4
  35. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +0 -2404
  36. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +0 -4
  37. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +0 -1362
  38. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +0 -4
  39. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +0 -90
  40. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +0 -4
  41. package/.idea/vcs.xml +0 -6
  42. package/dev/pimath.js +0 -7945
  43. package/dev/pimath.js.map +0 -1
  44. package/dist/pimath.js.map +0 -1
  45. package/dist/pimath.min.js +0 -2
  46. package/dist/pimath.min.js.map +0 -1
  47. package/docs/.nojekyll +0 -1
  48. package/docs/assets/highlight.css +0 -78
  49. package/docs/assets/main.js +0 -59
  50. package/docs/assets/navigation.js +0 -1
  51. package/docs/assets/search.js +0 -1
  52. package/docs/assets/style.css +0 -1383
  53. package/docs/classes/Logicalset.Logicalset.html +0 -217
  54. package/docs/classes/Polynom.Rational.html +0 -397
  55. package/docs/classes/Vector-1.Vector.html +0 -490
  56. package/docs/classes/Vector.Point.html +0 -337
  57. package/docs/classes/algebra_equation.Equation.html +0 -790
  58. package/docs/classes/algebra_linearSystem.LinearSystem.html +0 -404
  59. package/docs/classes/algebra_monom.Monom.html +0 -962
  60. package/docs/classes/algebra_polynom.Polynom.html +0 -1275
  61. package/docs/classes/coefficients_fraction.Fraction.html +0 -934
  62. package/docs/classes/geometry_circle.Circle.html +0 -472
  63. package/docs/classes/geometry_line.Line.html +0 -774
  64. package/docs/classes/geometry_triangle.Triangle.html +0 -429
  65. package/docs/classes/numeric.Numeric.html +0 -265
  66. package/docs/classes/shutingyard.Shutingyard.html +0 -250
  67. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +0 -83
  68. package/docs/enums/geometry_line.LinePropriety.html +0 -97
  69. package/docs/enums/shutingyard.ShutingyardMode.html +0 -97
  70. package/docs/enums/shutingyard.ShutingyardType.html +0 -111
  71. package/docs/index.html +0 -63
  72. package/docs/interfaces/algebra_equation.ISolution.html +0 -105
  73. package/docs/interfaces/algebra_polynom.IEuclidian.html +0 -87
  74. package/docs/interfaces/geometry_triangle.remarquableLines.html +0 -163
  75. package/docs/modules/Logicalset.html +0 -65
  76. package/docs/modules/Polynom.html +0 -65
  77. package/docs/modules/Vector-1.html +0 -65
  78. package/docs/modules/Vector.html +0 -65
  79. package/docs/modules/algebra_equation.html +0 -69
  80. package/docs/modules/algebra_linearSystem.html +0 -61
  81. package/docs/modules/algebra_monom.html +0 -65
  82. package/docs/modules/algebra_polynom.html +0 -69
  83. package/docs/modules/coefficients_fraction.html +0 -65
  84. package/docs/modules/geometry_circle.html +0 -61
  85. package/docs/modules/geometry_line.html +0 -65
  86. package/docs/modules/geometry_triangle.html +0 -65
  87. package/docs/modules/numeric.html +0 -61
  88. package/docs/modules/shutingyard.html +0 -75
  89. package/docs/types/algebra_monom.literalType.html +0 -61
  90. package/docs/types/algebra_polynom.PolynomParsingType.html +0 -56
  91. package/docs/types/coefficients_fraction.FractionParsingType.html +0 -56
  92. package/docs/types/shutingyard.Token.html +0 -63
  93. package/docs/types/shutingyard.tokenType.html +0 -68
  94. package/docs/variables/shutingyard.tokenConstant.html +0 -61
  95. package/esm/index.d.ts +0 -38
  96. package/esm/index.js +0 -44
  97. package/esm/index.js.map +0 -1
  98. package/esm/maths/algebra/equation.js +0 -797
  99. package/esm/maths/algebra/equation.js.map +0 -1
  100. package/esm/maths/algebra/linearSystem.js +0 -279
  101. package/esm/maths/algebra/linearSystem.js.map +0 -1
  102. package/esm/maths/algebra/logicalset.js +0 -158
  103. package/esm/maths/algebra/logicalset.js.map +0 -1
  104. package/esm/maths/algebra/monom.js +0 -909
  105. package/esm/maths/algebra/monom.js.map +0 -1
  106. package/esm/maths/algebra/polynom.js +0 -1305
  107. package/esm/maths/algebra/polynom.js.map +0 -1
  108. package/esm/maths/algebra/rational.js +0 -195
  109. package/esm/maths/algebra/rational.js.map +0 -1
  110. package/esm/maths/algebra/study/rationalStudy.d.ts +0 -28
  111. package/esm/maths/algebra/study/rationalStudy.js +0 -244
  112. package/esm/maths/algebra/study/rationalStudy.js.map +0 -1
  113. package/esm/maths/algebra/study.js +0 -380
  114. package/esm/maths/algebra/study.js.map +0 -1
  115. package/esm/maths/coefficients/fraction.js +0 -517
  116. package/esm/maths/coefficients/fraction.js.map +0 -1
  117. package/esm/maths/coefficients/nthRoot.js +0 -137
  118. package/esm/maths/coefficients/nthRoot.js.map +0 -1
  119. package/esm/maths/geometry/circle.js +0 -324
  120. package/esm/maths/geometry/circle.js.map +0 -1
  121. package/esm/maths/geometry/line.js +0 -485
  122. package/esm/maths/geometry/line.js.map +0 -1
  123. package/esm/maths/geometry/point.js +0 -167
  124. package/esm/maths/geometry/point.js.map +0 -1
  125. package/esm/maths/geometry/triangle.js +0 -276
  126. package/esm/maths/geometry/triangle.js.map +0 -1
  127. package/esm/maths/geometry/vector.js +0 -198
  128. package/esm/maths/geometry/vector.js.map +0 -1
  129. package/esm/maths/numeric.js +0 -136
  130. package/esm/maths/numeric.js.map +0 -1
  131. package/esm/maths/numexp.js +0 -186
  132. package/esm/maths/numexp.js.map +0 -1
  133. package/esm/maths/randomization/random.js +0 -79
  134. package/esm/maths/randomization/random.js.map +0 -1
  135. package/esm/maths/randomization/randomCore.js +0 -22
  136. package/esm/maths/randomization/randomCore.js.map +0 -1
  137. package/esm/maths/randomization/rndFraction.js +0 -44
  138. package/esm/maths/randomization/rndFraction.js.map +0 -1
  139. package/esm/maths/randomization/rndGeometryLine.js +0 -46
  140. package/esm/maths/randomization/rndGeometryLine.js.map +0 -1
  141. package/esm/maths/randomization/rndGeometryPoint.js +0 -61
  142. package/esm/maths/randomization/rndGeometryPoint.js.map +0 -1
  143. package/esm/maths/randomization/rndHelpers.js +0 -98
  144. package/esm/maths/randomization/rndHelpers.js.map +0 -1
  145. package/esm/maths/randomization/rndMonom.js +0 -53
  146. package/esm/maths/randomization/rndMonom.js.map +0 -1
  147. package/esm/maths/randomization/rndPolynom.js +0 -75
  148. package/esm/maths/randomization/rndPolynom.js.map +0 -1
  149. package/esm/maths/randomization/rndTypes.js +0 -3
  150. package/esm/maths/randomization/rndTypes.js.map +0 -1
  151. package/esm/maths/shutingyard.js +0 -443
  152. package/esm/maths/shutingyard.js.map +0 -1
  153. package/public/demo.css +0 -3
  154. package/public/index.html +0 -283
  155. package/public/matrices.html +0 -100
  156. package/public/playground.html +0 -168
  157. package/src/index.ts +0 -42
  158. package/src/maths/algebra/equation.ts +0 -897
  159. package/src/maths/algebra/linearSystem.ts +0 -370
  160. package/src/maths/algebra/logicalset.ts +0 -183
  161. package/src/maths/algebra/monom.ts +0 -1028
  162. package/src/maths/algebra/polynom.ts +0 -1537
  163. package/src/maths/algebra/rational.ts +0 -240
  164. package/src/maths/algebra/study/rationalStudy.ts +0 -287
  165. package/src/maths/algebra/study.ts +0 -506
  166. package/src/maths/coefficients/fraction.ts +0 -593
  167. package/src/maths/coefficients/nthRoot.ts +0 -148
  168. package/src/maths/geometry/circle.ts +0 -382
  169. package/src/maths/geometry/line.ts +0 -604
  170. package/src/maths/geometry/point.ts +0 -215
  171. package/src/maths/geometry/triangle.ts +0 -368
  172. package/src/maths/geometry/vector.ts +0 -242
  173. package/src/maths/numeric.ts +0 -162
  174. package/src/maths/numexp.ts +0 -184
  175. package/src/maths/randomization/random.ts +0 -80
  176. package/src/maths/randomization/randomCore.ts +0 -19
  177. package/src/maths/randomization/rndFraction.ts +0 -47
  178. package/src/maths/randomization/rndGeometryCircle.ts +0 -50
  179. package/src/maths/randomization/rndGeometryLine.ts +0 -53
  180. package/src/maths/randomization/rndGeometryPoint.ts +0 -69
  181. package/src/maths/randomization/rndHelpers.ts +0 -107
  182. package/src/maths/randomization/rndMonom.ts +0 -57
  183. package/src/maths/randomization/rndPolynom.ts +0 -90
  184. package/src/maths/randomization/rndTypes.ts +0 -43
  185. package/src/maths/shutingyard.ts +0 -496
  186. package/tests/algebra/equation.test.ts +0 -64
  187. package/tests/algebra/linear.test.ts +0 -58
  188. package/tests/algebra/monom.test.ts +0 -78
  189. package/tests/algebra/polynom.test.ts +0 -343
  190. package/tests/algebra/rationnal.test.ts +0 -64
  191. package/tests/algebra/study.test.ts +0 -48
  192. package/tests/coefficients/fraction.test.ts +0 -131
  193. package/tests/custom.test.ts +0 -33
  194. package/tests/geometry/circle.test.ts +0 -404
  195. package/tests/geometry/line.test.ts +0 -36
  196. package/tests/numeric.test.ts +0 -43
  197. package/tests/numexp.test.ts +0 -89
  198. package/tests/shutingyard.test.ts +0 -58
  199. package/tsconfig.json +0 -41
  200. package/tsconfig.testing.json +0 -28
  201. package/typedoc.katex.js +0 -11
  202. package/webpack-production-min.config.js +0 -26
  203. package/webpack-production.config.js +0 -26
  204. package/webpack.config.js +0 -26
  205. package/{esm → dist}/maths/algebra/logicalset.d.ts +6 -6
  206. package/{esm → dist}/maths/coefficients/fraction.d.ts +0 -0
  207. package/{esm → dist}/maths/coefficients/nthRoot.d.ts +0 -0
  208. package/{esm → dist}/maths/numeric.d.ts +0 -0
  209. package/{esm → dist}/maths/numexp.d.ts +3 -3
  210. /package/{esm → dist}/maths/randomization/randomCore.d.ts +0 -0
  211. /package/{esm → dist}/maths/randomization/rndHelpers.d.ts +0 -0
  212. /package/{esm → dist}/maths/shutingyard.d.ts +0 -0
@@ -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
- }