pimath 0.0.77 → 0.0.80

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/dist/pi.js CHANGED
@@ -2542,6 +2542,23 @@ class Polynom {
2542
2542
  };
2543
2543
  // ------------------------------------------
2544
2544
  // Compare functions
2545
+ this.isReduced = (polynomString) => {
2546
+ // The polynom must be developed to be reduced.
2547
+ if (!this.isDeveloped(polynomString)) {
2548
+ return false;
2549
+ }
2550
+ let P = new Polynom(polynomString);
2551
+ if (P.monoms.length > this.monoms.length) {
2552
+ return false;
2553
+ }
2554
+ // TODO: Not ur the reduced systme checking is working properly !
2555
+ for (let m of P.monoms) {
2556
+ if (!m.coefficient.isReduced()) {
2557
+ return false;
2558
+ }
2559
+ }
2560
+ return false;
2561
+ };
2545
2562
  this.isDeveloped = (polynomString) => {
2546
2563
  let P;
2547
2564
  // There is at least one parenthese - it is not developed.
@@ -3174,6 +3191,38 @@ class Polynom {
3174
3191
  }
3175
3192
  return tex;
3176
3193
  }
3194
+ get displayFactors() {
3195
+ this.factorize();
3196
+ if (this.factors.length <= 1) {
3197
+ return this.display;
3198
+ }
3199
+ // Build an array of texFactors with the number of similar items.
3200
+ let factorsCount = {};
3201
+ for (let f of this.factors) {
3202
+ if (factorsCount[f.display] !== undefined) {
3203
+ factorsCount[f.display].degree++;
3204
+ }
3205
+ else {
3206
+ factorsCount[f.display] = {
3207
+ degree: 1,
3208
+ factor: f
3209
+ };
3210
+ }
3211
+ }
3212
+ // First round to put the 'monom' first
3213
+ let simpleFactor = new Polynom().one();
3214
+ for (let item of Object.values(factorsCount).filter(item => item.factor.monoms.length === 1)) {
3215
+ simpleFactor.multiply(item.factor);
3216
+ }
3217
+ let display = simpleFactor.isOne() ? '' : simpleFactor.display;
3218
+ // Loop through all factors that contains at least 2 monoms.
3219
+ for (let item of Object.values(factorsCount).filter(item => item.factor.monoms.length > 1)) {
3220
+ if (item.factor.length > 1) {
3221
+ display += `( ${item.factor.display})${item.degree > 1 ? '^(' + item.degree + ')' : ''}`;
3222
+ }
3223
+ }
3224
+ return display;
3225
+ }
3177
3226
  get length() {
3178
3227
  // TODO: Must reduce the monoms list to remove the zero coefficient.
3179
3228
  return this._monoms.length;
@@ -4063,7 +4112,9 @@ class Fraction {
4063
4112
  else {
4064
4113
  // The given value is a float number
4065
4114
  // Get the number of decimals after the float sign
4066
- let p = (value.toString()).split('.')[1].length;
4115
+ let [unit, decimal] = (value.toString()).split('.');
4116
+ let p = decimal.length;
4117
+ // Detect if the decimal part is periodic or not...
4067
4118
  // Transform the float number in two integer
4068
4119
  if (denominatorOrPeriodic === undefined) {
4069
4120
  this._numerator = value * Math.pow(10, p);
@@ -6563,6 +6614,18 @@ class Numeric {
6563
6614
  }
6564
6615
  return value;
6565
6616
  }
6617
+ static periodic(value) {
6618
+ if (Number.isSafeInteger(value)) {
6619
+ return 0;
6620
+ }
6621
+ // Assume it's with decimal.
6622
+ let decimal = (value.toString()).split('.')[0];
6623
+ // The decimal part is limited
6624
+ if (decimal.length < 10) {
6625
+ return 0;
6626
+ }
6627
+ // Find the periodic if it exists.
6628
+ }
6566
6629
  }
6567
6630
  exports.Numeric = Numeric;
6568
6631
 
@@ -6629,7 +6692,7 @@ var Random;
6629
6692
  }
6630
6693
  Random.item = item;
6631
6694
  function shuffle(arr) {
6632
- rndHelpers_1.rndHelpers.shuffleArray(arr);
6695
+ return rndHelpers_1.rndHelpers.shuffleArray(arr);
6633
6696
  }
6634
6697
  Random.shuffle = shuffle;
6635
6698
  })(Random = exports.Random || (exports.Random = {}));