pimath 0.0.68 → 0.0.71
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 +8 -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 +1 -1
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +1 -0
- package/esm/maths/coefficients/fraction.js +3 -0
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/expressions/expression.d.ts +6 -0
- package/esm/maths/expressions/expression.js +79 -1
- package/esm/maths/expressions/expression.js.map +1 -1
- package/esm/maths/expressions/expressionFactor.d.ts +8 -1
- package/esm/maths/expressions/expressionFactor.js +51 -4
- package/esm/maths/expressions/expressionFactor.js.map +1 -1
- package/esm/maths/expressions/expressionMember.d.ts +12 -1
- package/esm/maths/expressions/expressionMember.js +128 -19
- package/esm/maths/expressions/expressionMember.js.map +1 -1
- package/esm/maths/expressions/expressionParser.d.ts +2 -0
- package/esm/maths/expressions/expressionParser.js +74 -34
- package/esm/maths/expressions/expressionParser.js.map +1 -1
- package/esm/maths/expressions/factors/ExpFactor.d.ts +2 -2
- package/esm/maths/expressions/factors/ExpFactor.js +15 -3
- package/esm/maths/expressions/factors/ExpFactor.js.map +1 -1
- package/esm/maths/expressions/factors/ExpFactorConstant.d.ts +1 -0
- package/esm/maths/expressions/factors/ExpFactorConstant.js +3 -0
- package/esm/maths/expressions/factors/ExpFactorConstant.js.map +1 -1
- package/esm/maths/expressions/factors/ExpFactorExponential.d.ts +1 -0
- package/esm/maths/expressions/factors/ExpFactorExponential.js +4 -0
- package/esm/maths/expressions/factors/ExpFactorExponential.js.map +1 -1
- package/esm/maths/expressions/factors/ExpFactorNumber.d.ts +3 -2
- package/esm/maths/expressions/factors/ExpFactorNumber.js +23 -0
- package/esm/maths/expressions/factors/ExpFactorNumber.js.map +1 -1
- package/esm/maths/expressions/factors/ExpFactorPower.d.ts +5 -1
- package/esm/maths/expressions/factors/ExpFactorPower.js +15 -2
- package/esm/maths/expressions/factors/ExpFactorPower.js.map +1 -1
- package/esm/maths/expressions/factors/ExpFactorTrigo.d.ts +1 -0
- package/esm/maths/expressions/factors/ExpFactorTrigo.js +8 -0
- package/esm/maths/expressions/factors/ExpFactorTrigo.js.map +1 -1
- package/esm/maths/expressions/factors/ExpFactorVariable.d.ts +1 -0
- package/esm/maths/expressions/factors/ExpFactorVariable.js +3 -0
- package/esm/maths/expressions/factors/ExpFactorVariable.js.map +1 -1
- package/esm/maths/expressions/polynomexp.bkp.js +0 -1
- package/esm/maths/expressions/polynomexp.bkp.js.map +1 -1
- package/esm/maths/shutingyard.js +3 -0
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +1 -1
- package/src/maths/algebra/equation.ts +1 -1
- package/src/maths/algebra/polynom.ts +1 -1
- package/src/maths/coefficients/fraction.ts +4 -0
- package/src/maths/expressions/expression.ts +115 -20
- package/src/maths/expressions/expressionFactor.ts +59 -7
- package/src/maths/expressions/expressionMember.ts +141 -22
- package/src/maths/expressions/expressionParser.ts +79 -33
- package/src/maths/expressions/factors/ExpFactor.ts +19 -6
- package/src/maths/expressions/factors/ExpFactorConstant.ts +4 -0
- package/src/maths/expressions/factors/ExpFactorExponential.ts +7 -0
- package/src/maths/expressions/factors/ExpFactorNumber.ts +32 -4
- package/src/maths/expressions/factors/ExpFactorPower.ts +21 -3
- package/src/maths/expressions/factors/ExpFactorTrigo.ts +10 -1
- package/src/maths/expressions/factors/ExpFactorVariable.ts +5 -0
- package/src/maths/expressions/polynomexp.bkp.ts +0 -1
- package/src/maths/shutingyard.ts +4 -1
- package/tests/expressions/expressions.test.ts +24 -3
- package/tests/geometry/circle.test.ts +6 -0
- package/esm/maths/expressions/factors/ExpFactorSin.d.ts +0 -7
- package/esm/maths/expressions/factors/ExpFactorSin.js +0 -22
- package/esm/maths/expressions/factors/ExpFactorSin.js.map +0 -1
package/src/maths/shutingyard.ts
CHANGED
|
@@ -189,6 +189,8 @@ export class Shutingyard {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
normalize(expr: string): string {
|
|
192
|
+
if(expr.length===1){return expr}
|
|
193
|
+
|
|
192
194
|
// Get the list of function token.
|
|
193
195
|
let fnToken: string[] = [],
|
|
194
196
|
kToken: string[] = []
|
|
@@ -207,6 +209,8 @@ export class Shutingyard {
|
|
|
207
209
|
kToken.sort((a, b) => b.length - a.length)
|
|
208
210
|
|
|
209
211
|
|
|
212
|
+
|
|
213
|
+
|
|
210
214
|
let normalizedExpr: string = "",
|
|
211
215
|
i = 0,
|
|
212
216
|
crtToken,
|
|
@@ -370,7 +374,6 @@ export class Shutingyard {
|
|
|
370
374
|
// Normalize the input if required.
|
|
371
375
|
if (this._uniformize) expr = this.normalize(expr)
|
|
372
376
|
|
|
373
|
-
|
|
374
377
|
let securityLoopLvl1 = 50,
|
|
375
378
|
securityLoopLvl2_default = 50,
|
|
376
379
|
securityLoopLvl2;
|
|
@@ -17,10 +17,31 @@ describe('Expressions tests', () => { // the tests container
|
|
|
17
17
|
// let a = new ExpressionParser('3x^(2/3)+5').expression
|
|
18
18
|
// let a = new ExpressionParser('3x(x+4)').expression
|
|
19
19
|
// let a = new ExpressionParser('sin(cos(3picos(3pi)-5))+sqrt(e-sin(3pi/2))').expression
|
|
20
|
-
let a = new ExpressionParser('3
|
|
21
|
-
console.log(
|
|
22
|
-
|
|
20
|
+
// let a = new ExpressionParser('3-nthrt(x-3,5)').expression
|
|
21
|
+
// console.log(a.isPolynom())
|
|
22
|
+
// let b = new ExpressionParser('3/2x^2-5x+7').expression
|
|
23
|
+
// console.log(b.tex, b.isPolynom())
|
|
24
|
+
// console.log(b.members[0].member.coefficient().tex)
|
|
25
|
+
// console.log(b.members[0].member.litteral().tex)
|
|
26
|
+
// console.log(b.structure())
|
|
27
|
+
//
|
|
23
28
|
|
|
29
|
+
// let c = new ExpressionParser('3/2x^2+5/3x-7').expression
|
|
30
|
+
// console.log(c.tex)
|
|
31
|
+
// console.log(c.display)
|
|
32
|
+
|
|
33
|
+
// let d = new ExpressionParser('sqrt(16)*sqrt(15^4)+9/15').expression
|
|
34
|
+
let d = new ExpressionParser('nthrt(16,4)').expression
|
|
35
|
+
console.log(d.tex)
|
|
36
|
+
console.log(d.members[0].member.reduce().tex)
|
|
37
|
+
console.log(d.structure())
|
|
38
|
+
// console.log(d.display)
|
|
39
|
+
|
|
40
|
+
// console.log(d.structure())
|
|
41
|
+
// console.log(c.display)
|
|
42
|
+
// console.log(c.members[0].member.literal().factors.length)
|
|
43
|
+
// console.log(c.members[0].member.reduce().tex);
|
|
44
|
+
// console.log(c.members[1].member.reduce().tex);
|
|
24
45
|
})
|
|
25
46
|
|
|
26
47
|
it('should make some operations', ()=>{
|
|
@@ -60,4 +60,10 @@ describe('Circle', function () {
|
|
|
60
60
|
|
|
61
61
|
expect(pts.map(x=>x.x.display + ',' + x.y.display)).to.have.all.members([ '3,0', '3,-8', '7,-4', '-1,-4' ])
|
|
62
62
|
});
|
|
63
|
+
|
|
64
|
+
it('should calculate the circle from center and radius', function(){
|
|
65
|
+
let circle = new Circle("x^2+6x+y^2-8y+12=0")
|
|
66
|
+
|
|
67
|
+
console.log(circle.tex)
|
|
68
|
+
})
|
|
63
69
|
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ExpressionFactor } from "../expressionFactor";
|
|
2
|
-
import { Expression } from "../expression";
|
|
3
|
-
export declare class ExpFactorSin extends ExpressionFactor {
|
|
4
|
-
derivative(variable: string): Expression;
|
|
5
|
-
integrate(variable: string): Expression;
|
|
6
|
-
makeTeX(): string;
|
|
7
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExpFactorSin = void 0;
|
|
4
|
-
const expressionFactor_1 = require("../expressionFactor");
|
|
5
|
-
class ExpFactorSin extends expressionFactor_1.ExpressionFactor {
|
|
6
|
-
derivative(variable) {
|
|
7
|
-
return undefined;
|
|
8
|
-
}
|
|
9
|
-
integrate(variable) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
makeTeX() {
|
|
13
|
-
let tex = "\\sin";
|
|
14
|
-
if (this.root > 1) {
|
|
15
|
-
tex += `^{ ${this.root} }`;
|
|
16
|
-
}
|
|
17
|
-
tex += `\\left( ${this.argument.tex} \\right)`;
|
|
18
|
-
return this.texRoot(tex);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.ExpFactorSin = ExpFactorSin;
|
|
22
|
-
//# sourceMappingURL=ExpFactorSin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExpFactorSin.js","sourceRoot":"","sources":["../../../../src/maths/expressions/factors/ExpFactorSin.ts"],"names":[],"mappings":";;;AAAA,0DAAqD;AAGrD,MAAa,YAAa,SAAQ,mCAAgB;IAE9C,UAAU,CAAC,QAAgB;QACvB,OAAO,SAAS,CAAA;IACpB,CAAC;IAED,SAAS,CAAC,QAAgB;QACtB,OAAO,SAAS,CAAA;IACpB,CAAC;IAED,OAAO;QACH,IAAI,GAAG,GAAG,OAAO,CAAA;QACjB,IAAG,IAAI,CAAC,IAAI,GAAC,CAAC,EAAC;YACX,GAAG,IAAI,MAAM,IAAI,CAAC,IAAI,IAAI,CAAA;SAC7B;QAED,GAAG,IAAG,WAAW,IAAI,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAA;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACJ;AAnBD,oCAmBC"}
|