pimath 0.0.122 → 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.
- package/dev/pimath.js +7930 -7924
- package/dev/pimath.js.map +1 -1
- package/dist/pimath.js +17 -12
- package/dist/pimath.js.map +1 -1
- package/dist/pimath.min.js +1 -1
- package/dist/pimath.min.js.map +1 -1
- package/esm/maths/algebra/polynom.js +13 -8
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/numexp.d.ts +1 -1
- package/esm/maths/numexp.js.map +1 -1
- package/esm/maths/shutingyard.js +4 -4
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +1 -1
- package/src/maths/algebra/polynom.ts +16 -11
- package/src/maths/numexp.ts +1 -1
- package/src/maths/shutingyard.ts +6 -4
- package/tests/algebra/polynom.test.ts +8 -0
- package/tests/numexp.test.ts +2 -2
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]1/shelved.patch +0 -107
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_1.xml +0 -4
package/dist/pimath.js
CHANGED
|
@@ -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 (
|
|
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
|
-
|
|
2723
|
-
//
|
|
2724
|
-
//
|
|
2725
|
-
|
|
2726
|
-
//
|
|
2727
|
-
//
|
|
2728
|
-
|
|
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 = () => {
|
|
@@ -7595,21 +7600,21 @@ class Shutingyard {
|
|
|
7595
7600
|
if (crtToken.match(/[a-zA-Z]/g)) {
|
|
7596
7601
|
// Current element is a letter.
|
|
7597
7602
|
// if the next element is a letter, a number or an opening parentheses, add the multiplication sign.
|
|
7598
|
-
if (nextToken
|
|
7603
|
+
if (nextToken?.match(/[a-zA-Z\d(]/)) {
|
|
7599
7604
|
normalizedExpr += '*';
|
|
7600
7605
|
}
|
|
7601
7606
|
}
|
|
7602
7607
|
else if (crtToken.match(/\d/)) {
|
|
7603
7608
|
// Current element is a number.
|
|
7604
7609
|
// if the next element is a letter or a parentheses, add the multiplication sign.
|
|
7605
|
-
if (nextToken
|
|
7610
|
+
if (nextToken?.match(/[a-zA-Z(]/)) {
|
|
7606
7611
|
normalizedExpr += '*';
|
|
7607
7612
|
}
|
|
7608
7613
|
}
|
|
7609
7614
|
else if (crtToken === ')') {
|
|
7610
7615
|
// Current element is a closing parentheses.
|
|
7611
7616
|
// if the next element is a letter, a number or an opening parentheses, add the multiplication sign
|
|
7612
|
-
if (nextToken
|
|
7617
|
+
if (nextToken?.match(/[a-zA-Z\d(]/)) {
|
|
7613
7618
|
normalizedExpr += '*';
|
|
7614
7619
|
}
|
|
7615
7620
|
}
|
|
@@ -7617,7 +7622,7 @@ class Shutingyard {
|
|
|
7617
7622
|
i++;
|
|
7618
7623
|
}
|
|
7619
7624
|
// add the last token
|
|
7620
|
-
return normalizedExpr + nextToken;
|
|
7625
|
+
return normalizedExpr + (nextToken === undefined ? '' : nextToken);
|
|
7621
7626
|
}
|
|
7622
7627
|
// /**
|
|
7623
7628
|
// * Sanitize an expression by adding missing common operation (multiplication between parentheseses)
|