pimath 0.0.121 → 0.0.123

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 (73) hide show
  1. package/.eslintrc.js +23 -23
  2. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +90 -0
  3. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +4 -0
  4. package/LICENSE.md +1 -1
  5. package/dev/pimath.js +27 -21
  6. package/dev/pimath.js.map +1 -1
  7. package/dist/pimath.js +27 -21
  8. package/dist/pimath.js.map +1 -1
  9. package/dist/pimath.min.js +1 -1
  10. package/dist/pimath.min.js.map +1 -1
  11. package/docs/assets/main.js +58 -58
  12. package/docs/assets/style.css +1367 -1367
  13. package/docs/classes/Logicalset.Logicalset.html +220 -220
  14. package/docs/classes/Polynom.Rational.html +390 -390
  15. package/docs/classes/Vector-1.Vector.html +493 -493
  16. package/docs/classes/Vector.Point.html +340 -340
  17. package/docs/classes/algebra_equation.Equation.html +795 -795
  18. package/docs/classes/algebra_linearSystem.LinearSystem.html +407 -407
  19. package/docs/classes/algebra_monom.Monom.html +966 -966
  20. package/docs/classes/algebra_polynom.Polynom.html +1280 -1280
  21. package/docs/classes/coefficients_fraction.Fraction.html +938 -938
  22. package/docs/classes/geometry_circle.Circle.html +475 -475
  23. package/docs/classes/geometry_line.Line.html +778 -778
  24. package/docs/classes/geometry_triangle.Triangle.html +428 -428
  25. package/docs/classes/numeric.Numeric.html +268 -268
  26. package/docs/classes/shutingyard.Shutingyard.html +258 -258
  27. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +88 -88
  28. package/docs/enums/geometry_line.LinePropriety.html +101 -101
  29. package/docs/enums/shutingyard.ShutingyardMode.html +105 -105
  30. package/docs/enums/shutingyard.ShutingyardType.html +119 -119
  31. package/docs/index.html +62 -62
  32. package/docs/interfaces/algebra_equation.ISolution.html +110 -110
  33. package/docs/interfaces/algebra_polynom.IEuclidian.html +92 -92
  34. package/docs/interfaces/geometry_triangle.remarquableLines.html +149 -149
  35. package/docs/modules/Logicalset.html +68 -68
  36. package/docs/modules/Polynom.html +68 -68
  37. package/docs/modules/Vector-1.html +68 -68
  38. package/docs/modules/Vector.html +68 -68
  39. package/docs/modules/algebra_equation.html +74 -74
  40. package/docs/modules/algebra_linearSystem.html +64 -64
  41. package/docs/modules/algebra_monom.html +69 -69
  42. package/docs/modules/algebra_polynom.html +74 -74
  43. package/docs/modules/coefficients_fraction.html +69 -69
  44. package/docs/modules/geometry_circle.html +64 -64
  45. package/docs/modules/geometry_line.html +69 -69
  46. package/docs/modules/geometry_triangle.html +69 -69
  47. package/docs/modules/numeric.html +64 -64
  48. package/docs/modules/shutingyard.html +83 -83
  49. package/docs/types/algebra_monom.literalType.html +65 -65
  50. package/docs/types/algebra_polynom.PolynomParsingType.html +61 -61
  51. package/docs/types/coefficients_fraction.FractionParsingType.html +60 -60
  52. package/docs/types/shutingyard.Token.html +71 -71
  53. package/docs/types/shutingyard.tokenType.html +76 -76
  54. package/docs/variables/shutingyard.tokenConstant.html +69 -69
  55. package/esm/index.js +1 -1
  56. package/esm/index.js.map +1 -1
  57. package/esm/maths/algebra/polynom.js +13 -8
  58. package/esm/maths/algebra/polynom.js.map +1 -1
  59. package/esm/maths/algebra/study.d.ts +1 -0
  60. package/esm/maths/algebra/study.js +9 -8
  61. package/esm/maths/algebra/study.js.map +1 -1
  62. package/esm/maths/numexp.d.ts +1 -1
  63. package/esm/maths/numexp.js.map +1 -1
  64. package/esm/maths/shutingyard.js +4 -4
  65. package/esm/maths/shutingyard.js.map +1 -1
  66. package/package.json +5 -5
  67. package/src/index.ts +1 -1
  68. package/src/maths/algebra/polynom.ts +16 -11
  69. package/src/maths/algebra/study.ts +11 -9
  70. package/src/maths/numexp.ts +1 -1
  71. package/src/maths/shutingyard.ts +6 -4
  72. package/tests/algebra/polynom.test.ts +8 -0
  73. package/tests/numexp.test.ts +12 -0
package/dist/pimath.js CHANGED
@@ -48,7 +48,7 @@ exports.l = {
48
48
  Circle: circle_1.Circle
49
49
  }
50
50
  };
51
- window.PiMath = exports.l;
51
+ window.Pi = exports.l;
52
52
 
53
53
 
54
54
  /***/ }),
@@ -2702,8 +2702,10 @@ class Polynom {
2702
2702
  };
2703
2703
  this.isDeveloped = (polynomString) => {
2704
2704
  let P;
2705
+ // Start by removing the parenthis after a "power"
2706
+ let pString = polynomString.replaceAll(/\^\(([-0-9/]+)\)/g, '$1');
2705
2707
  // There is at least one parenthese - it is not developed.
2706
- if (polynomString.split('(').length + polynomString.split(')').length > 0) {
2708
+ if (pString.includes('(') || pString.includes(')')) {
2707
2709
  return false;
2708
2710
  }
2709
2711
  // Try to build the polynom
@@ -2719,13 +2721,16 @@ class Polynom {
2719
2721
  return false;
2720
2722
  }
2721
2723
  // Check that everything is completely developed. Actually, there are no parentheses... so it is fully developed
2722
- // maybe it wasn't reduced and not ordered...
2723
- // compare polynom string.
2724
- // normalize the string
2725
- let polynomStringNormalized = polynomString.replaceAll('[*\s]', '');
2726
- // Determine if it's the exact same string.
2727
- // TODO: Maybe it's enough to just make this test !
2728
- return polynomStringNormalized === P.reduce().reorder().display;
2724
+ return true;
2725
+ // // maybe it wasn't reduced and not ordered...
2726
+ // // compare polynom string.
2727
+ //
2728
+ // // normalize the string
2729
+ // let polynomStringNormalized = polynomString.replaceAll('[*\s]', '')
2730
+ //
2731
+ // // Determine if it's the exact same string.
2732
+ // // TODO: Maybe it's enough to just make this test !a
2733
+ // return polynomStringNormalized === P.reduce().reorder().display
2729
2734
  };
2730
2735
  // -------------------------------------
2731
2736
  this.reduce = () => {
@@ -3937,13 +3942,13 @@ class Study {
3937
3942
  return code;
3938
3943
  };
3939
3944
  this._makeTexFromTableOfSigns = (tos) => {
3940
- let factors = tos.factors.map(x => `\\(${x.tex}\\)/1`), factorsFx = `\\(${this._name}(x)\\)/1.2`, zeroes = tos.zeroes;
3945
+ let factors = tos.factors.map(x => `\\(${x.tex}\\)/1`), factorsFx = `\\(${this._config.name}(${this._config.variable})\\)/1.2`, zeroes = tos.zeroes;
3941
3946
  // Add the last lines "label"
3942
3947
  if (tos.type === TABLE_OF_SIGNS.GROWS) {
3943
- factorsFx = `\\(${this._name}'(x)\\)/1.2,\\(f(x)\\)/2`;
3948
+ factorsFx = `\\(${this._config.name}'(${this._config.variable})\\)/1.2,\\(f(x${this._config.variable})\\)/2`;
3944
3949
  }
3945
3950
  else if (tos.type === TABLE_OF_SIGNS.VARIATIONS) {
3946
- factorsFx = `\\(${this._name}''(x)\\)/1.2,\\(f(x)\\)/2`;
3951
+ factorsFx = `\\(${this._config.name}''(${this._config.variable})\\)/1.2,\\(f(${this._config.variable})\\)/2`;
3947
3952
  }
3948
3953
  // Create the tikzPicture header
3949
3954
  let tex = `\\begin{tikzpicture}
@@ -3968,6 +3973,7 @@ class Study {
3968
3973
  this.fx = fx;
3969
3974
  this._config = {
3970
3975
  name: 'f',
3976
+ variable: 'x',
3971
3977
  domain: true,
3972
3978
  asymptotes: true,
3973
3979
  signs: true,
@@ -3978,9 +3984,10 @@ class Study {
3978
3984
  if (typeof config === 'string') {
3979
3985
  const d = config.split(',');
3980
3986
  this._config = {};
3981
- let n = d.filter(x => x.includes('(x)'));
3987
+ let n = d.filter(x => x.includes('(') && x.includes(')'));
3982
3988
  if (n.length === 1) {
3983
- this._config.name = n[0].split('(x)')[0];
3989
+ this._config.name = n[0].split('(')[0];
3990
+ this._config.variable = n[0].split('(')[1].split(')')[0];
3984
3991
  }
3985
3992
  this._config.domain = d.includes('d');
3986
3993
  this._config.asymptotes = d.includes('a');
@@ -3992,15 +3999,14 @@ class Study {
3992
3999
  this._config = config;
3993
4000
  }
3994
4001
  }
3995
- this._name = this._config?.name ?? 'f';
3996
4002
  this.makeStudy();
3997
4003
  return this;
3998
4004
  }
3999
4005
  get name() {
4000
- return this._name;
4006
+ return this._config.name;
4001
4007
  }
4002
4008
  set name(value) {
4003
- this._name = value;
4009
+ this._config.name = value;
4004
4010
  }
4005
4011
  get config() {
4006
4012
  return this._config;
@@ -7594,21 +7600,21 @@ class Shutingyard {
7594
7600
  if (crtToken.match(/[a-zA-Z]/g)) {
7595
7601
  // Current element is a letter.
7596
7602
  // if the next element is a letter, a number or an opening parentheses, add the multiplication sign.
7597
- if (nextToken.match(/[a-zA-Z\d(]/)) {
7603
+ if (nextToken?.match(/[a-zA-Z\d(]/)) {
7598
7604
  normalizedExpr += '*';
7599
7605
  }
7600
7606
  }
7601
7607
  else if (crtToken.match(/\d/)) {
7602
7608
  // Current element is a number.
7603
7609
  // if the next element is a letter or a parentheses, add the multiplication sign.
7604
- if (nextToken.match(/[a-zA-Z(]/)) {
7610
+ if (nextToken?.match(/[a-zA-Z(]/)) {
7605
7611
  normalizedExpr += '*';
7606
7612
  }
7607
7613
  }
7608
7614
  else if (crtToken === ')') {
7609
7615
  // Current element is a closing parentheses.
7610
7616
  // if the next element is a letter, a number or an opening parentheses, add the multiplication sign
7611
- if (nextToken.match(/[a-zA-Z\d(]/)) {
7617
+ if (nextToken?.match(/[a-zA-Z\d(]/)) {
7612
7618
  normalizedExpr += '*';
7613
7619
  }
7614
7620
  }
@@ -7616,7 +7622,7 @@ class Shutingyard {
7616
7622
  i++;
7617
7623
  }
7618
7624
  // add the last token
7619
- return normalizedExpr + nextToken;
7625
+ return normalizedExpr + (nextToken === undefined ? '' : nextToken);
7620
7626
  }
7621
7627
  // /**
7622
7628
  // * Sanitize an expression by adding missing common operation (multiplication between parentheseses)