pimath 0.0.102 → 0.0.103
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/dev/pi.js +27 -2
- package/dev/pi.js.map +1 -1
- package/dist/pi.js +27 -2
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/esm/maths/algebra/equation.js +1 -1
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/polynom.js +17 -1
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/numeric.d.ts +1 -0
- package/esm/maths/numeric.js +9 -0
- package/esm/maths/numeric.js.map +1 -1
- package/package.json +1 -1
- package/src/maths/algebra/equation.ts +1 -1
- package/src/maths/algebra/polynom.ts +22 -2
- package/src/maths/numeric.ts +16 -0
- package/tests/algebra/polynom.test.ts +7 -0
- package/tests/numeric.test.ts +7 -0
package/dev/pi.js
CHANGED
|
@@ -219,7 +219,7 @@ class Equation {
|
|
|
219
219
|
if (this._sign !== '=' && F.sign() === -1) {
|
|
220
220
|
this._reverseSign();
|
|
221
221
|
}
|
|
222
|
-
return this;
|
|
222
|
+
return this.reorder();
|
|
223
223
|
};
|
|
224
224
|
/**
|
|
225
225
|
* divide an equation by a given value (transformed as a fraction)
|
|
@@ -2734,8 +2734,23 @@ class Polynom {
|
|
|
2734
2734
|
};
|
|
2735
2735
|
this.reorder = (letter = 'x') => {
|
|
2736
2736
|
// TODO: Must handle multiple setLetter reorder system
|
|
2737
|
+
let otherLetters = this.variables.filter(x => x !== letter);
|
|
2737
2738
|
this._monoms.sort(function (a, b) {
|
|
2738
|
-
|
|
2739
|
+
let da = a.degree(letter).value, db = b.degree(letter).value;
|
|
2740
|
+
// Values are different
|
|
2741
|
+
if (da !== db)
|
|
2742
|
+
return db - da;
|
|
2743
|
+
// if values are equals, check other letters.
|
|
2744
|
+
if (otherLetters.length > 0) {
|
|
2745
|
+
for (let L of otherLetters) {
|
|
2746
|
+
let da = a.degree(L).value, db = b.degree(L).value;
|
|
2747
|
+
// Values are different
|
|
2748
|
+
if (da !== db)
|
|
2749
|
+
return db - da;
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
return 0;
|
|
2753
|
+
// return b.degree(letter).clone().subtract(a.degree(letter)).value
|
|
2739
2754
|
});
|
|
2740
2755
|
return this;
|
|
2741
2756
|
};
|
|
@@ -3382,6 +3397,7 @@ class Polynom {
|
|
|
3382
3397
|
}
|
|
3383
3398
|
// Remove duplicates.
|
|
3384
3399
|
V = [...new Set(V)];
|
|
3400
|
+
V.sort();
|
|
3385
3401
|
return V;
|
|
3386
3402
|
}
|
|
3387
3403
|
get numberOfVars() {
|
|
@@ -6957,6 +6973,15 @@ class Numeric {
|
|
|
6957
6973
|
}
|
|
6958
6974
|
// Find the periodic if it exists.
|
|
6959
6975
|
}
|
|
6976
|
+
static decompose(value) {
|
|
6977
|
+
let dividers = Numeric.dividers(value), limit = Math.sqrt(value), arr = [], u, v;
|
|
6978
|
+
while (dividers.length > 0) {
|
|
6979
|
+
u = dividers.shift();
|
|
6980
|
+
v = dividers.length > 0 ? dividers.pop() : +u;
|
|
6981
|
+
arr.push([u, v]);
|
|
6982
|
+
}
|
|
6983
|
+
return arr;
|
|
6984
|
+
}
|
|
6960
6985
|
}
|
|
6961
6986
|
exports.Numeric = Numeric;
|
|
6962
6987
|
|