pimath 0.1.35 → 0.1.37
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/pimath.js
CHANGED
|
@@ -929,7 +929,7 @@ class p {
|
|
|
929
929
|
* @param inputStr
|
|
930
930
|
*/
|
|
931
931
|
parse(e) {
|
|
932
|
-
return this.#t = new a(), this.#e = {}, typeof e == "string" ? this.#r(e) : typeof e == "number" ? this.#t = new a(e) : e instanceof a ? this.#t = e.clone() : e instanceof p && (this.#t = e.#t.clone(), this.#i(e)), this;
|
|
932
|
+
return this.#t = new a(), this.#e = {}, typeof e == "string" ? isNaN(Number(e)) ? this.#r(e) : this.#t = new a(Number(e)) : typeof e == "number" ? this.#t = new a(e) : e instanceof a ? this.#t = e.clone() : e instanceof p && (this.#t = e.#t.clone(), this.#i(e)), this;
|
|
933
933
|
}
|
|
934
934
|
/**
|
|
935
935
|
* Clone the current Monom.
|
|
@@ -941,6 +941,27 @@ class p {
|
|
|
941
941
|
e.setLetter(t, this.#e[t].clone());
|
|
942
942
|
return e;
|
|
943
943
|
};
|
|
944
|
+
/**
|
|
945
|
+
* Get the tex output of the monom
|
|
946
|
+
*/
|
|
947
|
+
get tex() {
|
|
948
|
+
let e = "";
|
|
949
|
+
const t = Object.keys(this.#e).sort();
|
|
950
|
+
for (const i of t)
|
|
951
|
+
this.#e[i].isNotZero() && (e += i, this.#e[i].isNotEqual(1) && (e += `^{ ${this.#e[i].tfrac.tex} }`));
|
|
952
|
+
return e === "" ? this.#t.value != 0 ? this.#t.frac.tex : "0" : this.#t.value === 1 ? e : this.#t.value === -1 ? `-${e}` : this.#t.value === 0 ? "0" : `${this.#t.frac.tex}${e}`;
|
|
953
|
+
}
|
|
954
|
+
// Display getter
|
|
955
|
+
/**
|
|
956
|
+
* This display getter is to be used in the polynom display getter
|
|
957
|
+
*/
|
|
958
|
+
get display() {
|
|
959
|
+
let e = "";
|
|
960
|
+
const t = Object.keys(this.#e).sort();
|
|
961
|
+
for (const i of t)
|
|
962
|
+
this.#e[i].isNotZero() && (e += i, this.#e[i].isNotEqual(1) && (e += `^(${this.#e[i].display})`));
|
|
963
|
+
return e === "" ? this.#t.value != 0 ? this.#t.display : "" : this.#t.value === 1 ? e : this.#t.value === -1 ? `-${e}` : this.#t.value === 0 ? "0" : `${this.#t.display}${e}`;
|
|
964
|
+
}
|
|
944
965
|
static gcd = (...e) => {
|
|
945
966
|
for (const r of e)
|
|
946
967
|
if (r.containsRationalPower())
|
|
@@ -1007,17 +1028,6 @@ class p {
|
|
|
1007
1028
|
} else
|
|
1008
1029
|
return new p().zero();
|
|
1009
1030
|
};
|
|
1010
|
-
// Display getter
|
|
1011
|
-
/**
|
|
1012
|
-
* This display getter is to be used in the polynom display getter
|
|
1013
|
-
*/
|
|
1014
|
-
get display() {
|
|
1015
|
-
let e = "";
|
|
1016
|
-
const t = Object.keys(this.#e).sort();
|
|
1017
|
-
for (const i of t)
|
|
1018
|
-
this.#e[i].isNotZero() && (e += i, this.#e[i].isNotEqual(1) && (e += `^(${this.#e[i].display})`));
|
|
1019
|
-
return e === "" ? this.#t.value != 0 ? this.#t.display : "" : this.#t.value === 1 ? e : this.#t.value === -1 ? `-${e}` : this.#t.value === 0 ? "0" : `${this.#t.display}${e}`;
|
|
1020
|
-
}
|
|
1021
1031
|
/**
|
|
1022
1032
|
* Divide the current monoms by multiple monoms
|
|
1023
1033
|
* @param M (Monom[])
|
|
@@ -1284,16 +1294,6 @@ class p {
|
|
|
1284
1294
|
}
|
|
1285
1295
|
return this;
|
|
1286
1296
|
};
|
|
1287
|
-
/**
|
|
1288
|
-
* Get the tex output of the monom
|
|
1289
|
-
*/
|
|
1290
|
-
get tex() {
|
|
1291
|
-
let e = "";
|
|
1292
|
-
const t = Object.keys(this.#e).sort();
|
|
1293
|
-
for (const i of t)
|
|
1294
|
-
this.#e[i].isNotZero() && (e += i, this.#e[i].isNotEqual(1) && (e += `^{ ${this.#e[i].tfrac.tex} }`));
|
|
1295
|
-
return e === "" ? this.#t.value != 0 ? this.#t.frac.tex : "0" : this.#t.value === 1 ? e : this.#t.value === -1 ? `-${e}` : this.#t.value === 0 ? "0" : `${this.#t.frac.tex}${e}`;
|
|
1296
|
-
}
|
|
1297
1297
|
// Getter helpers.
|
|
1298
1298
|
/**
|
|
1299
1299
|
* Get the variables letters
|
|
@@ -1336,21 +1336,6 @@ class p {
|
|
|
1336
1336
|
}
|
|
1337
1337
|
return t;
|
|
1338
1338
|
};
|
|
1339
|
-
_getLiteralDividers(e, t) {
|
|
1340
|
-
const i = [];
|
|
1341
|
-
for (let s = 0; s <= this.literal[t].value; s++)
|
|
1342
|
-
if (e.length === 0) {
|
|
1343
|
-
const r = {};
|
|
1344
|
-
r[t] = new a(s), i.push(r);
|
|
1345
|
-
} else
|
|
1346
|
-
for (const r of e) {
|
|
1347
|
-
const o = {};
|
|
1348
|
-
for (const h in r)
|
|
1349
|
-
o[h] = r[h];
|
|
1350
|
-
o[t] = new a(s), i.push(o);
|
|
1351
|
-
}
|
|
1352
|
-
return i;
|
|
1353
|
-
}
|
|
1354
1339
|
#r = (e) => {
|
|
1355
1340
|
const i = new _().parse(e).rpn, s = [];
|
|
1356
1341
|
if (i.length === 0)
|
|
@@ -1387,6 +1372,21 @@ class p {
|
|
|
1387
1372
|
}
|
|
1388
1373
|
}
|
|
1389
1374
|
};
|
|
1375
|
+
_getLiteralDividers(e, t) {
|
|
1376
|
+
const i = [];
|
|
1377
|
+
for (let s = 0; s <= this.literal[t].value; s++)
|
|
1378
|
+
if (e.length === 0) {
|
|
1379
|
+
const r = {};
|
|
1380
|
+
r[t] = new a(s), i.push(r);
|
|
1381
|
+
} else
|
|
1382
|
+
for (const r of e) {
|
|
1383
|
+
const o = {};
|
|
1384
|
+
for (const h in r)
|
|
1385
|
+
o[h] = r[h];
|
|
1386
|
+
o[t] = new a(s), i.push(o);
|
|
1387
|
+
}
|
|
1388
|
+
return i;
|
|
1389
|
+
}
|
|
1390
1390
|
}
|
|
1391
1391
|
function le(n, e = !0) {
|
|
1392
1392
|
return e ? `\\left( ${n} \\right)` : `(${n})`;
|
|
@@ -1918,7 +1918,7 @@ class u {
|
|
|
1918
1918
|
if (t.length === 0) {
|
|
1919
1919
|
if (e !== "" && !isNaN(Number(e))) {
|
|
1920
1920
|
this.empty();
|
|
1921
|
-
const i = new p(e);
|
|
1921
|
+
const i = new p(Number(e));
|
|
1922
1922
|
return this.add(i), this;
|
|
1923
1923
|
}
|
|
1924
1924
|
return this.#w(e);
|