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/dist/pi.js
CHANGED
|
@@ -214,7 +214,7 @@ class Equation {
|
|
|
214
214
|
if (this._sign !== '=' && F.sign() === -1) {
|
|
215
215
|
this._reverseSign();
|
|
216
216
|
}
|
|
217
|
-
return this;
|
|
217
|
+
return this.reorder();
|
|
218
218
|
};
|
|
219
219
|
/**
|
|
220
220
|
* divide an equation by a given value (transformed as a fraction)
|
|
@@ -2717,8 +2717,23 @@ class Polynom {
|
|
|
2717
2717
|
};
|
|
2718
2718
|
this.reorder = (letter = 'x') => {
|
|
2719
2719
|
// TODO: Must handle multiple setLetter reorder system
|
|
2720
|
+
let otherLetters = this.variables.filter(x => x !== letter);
|
|
2720
2721
|
this._monoms.sort(function (a, b) {
|
|
2721
|
-
|
|
2722
|
+
let da = a.degree(letter).value, db = b.degree(letter).value;
|
|
2723
|
+
// Values are different
|
|
2724
|
+
if (da !== db)
|
|
2725
|
+
return db - da;
|
|
2726
|
+
// if values are equals, check other letters.
|
|
2727
|
+
if (otherLetters.length > 0) {
|
|
2728
|
+
for (let L of otherLetters) {
|
|
2729
|
+
let da = a.degree(L).value, db = b.degree(L).value;
|
|
2730
|
+
// Values are different
|
|
2731
|
+
if (da !== db)
|
|
2732
|
+
return db - da;
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
return 0;
|
|
2736
|
+
// return b.degree(letter).clone().subtract(a.degree(letter)).value
|
|
2722
2737
|
});
|
|
2723
2738
|
return this;
|
|
2724
2739
|
};
|
|
@@ -3365,6 +3380,7 @@ class Polynom {
|
|
|
3365
3380
|
}
|
|
3366
3381
|
// Remove duplicates.
|
|
3367
3382
|
V = [...new Set(V)];
|
|
3383
|
+
V.sort();
|
|
3368
3384
|
return V;
|
|
3369
3385
|
}
|
|
3370
3386
|
get numberOfVars() {
|
|
@@ -6901,6 +6917,15 @@ class Numeric {
|
|
|
6901
6917
|
}
|
|
6902
6918
|
// Find the periodic if it exists.
|
|
6903
6919
|
}
|
|
6920
|
+
static decompose(value) {
|
|
6921
|
+
let dividers = Numeric.dividers(value), limit = Math.sqrt(value), arr = [], u, v;
|
|
6922
|
+
while (dividers.length > 0) {
|
|
6923
|
+
u = dividers.shift();
|
|
6924
|
+
v = dividers.length > 0 ? dividers.pop() : +u;
|
|
6925
|
+
arr.push([u, v]);
|
|
6926
|
+
}
|
|
6927
|
+
return arr;
|
|
6928
|
+
}
|
|
6904
6929
|
}
|
|
6905
6930
|
exports.Numeric = Numeric;
|
|
6906
6931
|
|