pimath 0.0.121 → 0.0.122
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/.eslintrc.js +23 -23
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +90 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]1/shelved.patch +107 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +4 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_1.xml +4 -0
- package/LICENSE.md +1 -1
- package/dev/pimath.js +7924 -7924
- package/dist/pimath.js +10 -9
- package/dist/pimath.js.map +1 -1
- package/dist/pimath.min.js +1 -1
- package/dist/pimath.min.js.map +1 -1
- package/docs/assets/main.js +58 -58
- package/docs/assets/style.css +1367 -1367
- package/docs/classes/Logicalset.Logicalset.html +220 -220
- package/docs/classes/Polynom.Rational.html +390 -390
- package/docs/classes/Vector-1.Vector.html +493 -493
- package/docs/classes/Vector.Point.html +340 -340
- package/docs/classes/algebra_equation.Equation.html +795 -795
- package/docs/classes/algebra_linearSystem.LinearSystem.html +407 -407
- package/docs/classes/algebra_monom.Monom.html +966 -966
- package/docs/classes/algebra_polynom.Polynom.html +1280 -1280
- package/docs/classes/coefficients_fraction.Fraction.html +938 -938
- package/docs/classes/geometry_circle.Circle.html +475 -475
- package/docs/classes/geometry_line.Line.html +778 -778
- package/docs/classes/geometry_triangle.Triangle.html +428 -428
- package/docs/classes/numeric.Numeric.html +268 -268
- package/docs/classes/shutingyard.Shutingyard.html +258 -258
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +88 -88
- package/docs/enums/geometry_line.LinePropriety.html +101 -101
- package/docs/enums/shutingyard.ShutingyardMode.html +105 -105
- package/docs/enums/shutingyard.ShutingyardType.html +119 -119
- package/docs/index.html +62 -62
- package/docs/interfaces/algebra_equation.ISolution.html +110 -110
- package/docs/interfaces/algebra_polynom.IEuclidian.html +92 -92
- package/docs/interfaces/geometry_triangle.remarquableLines.html +149 -149
- package/docs/modules/Logicalset.html +68 -68
- package/docs/modules/Polynom.html +68 -68
- package/docs/modules/Vector-1.html +68 -68
- package/docs/modules/Vector.html +68 -68
- package/docs/modules/algebra_equation.html +74 -74
- package/docs/modules/algebra_linearSystem.html +64 -64
- package/docs/modules/algebra_monom.html +69 -69
- package/docs/modules/algebra_polynom.html +74 -74
- package/docs/modules/coefficients_fraction.html +69 -69
- package/docs/modules/geometry_circle.html +64 -64
- package/docs/modules/geometry_line.html +69 -69
- package/docs/modules/geometry_triangle.html +69 -69
- package/docs/modules/numeric.html +64 -64
- package/docs/modules/shutingyard.html +83 -83
- package/docs/types/algebra_monom.literalType.html +65 -65
- package/docs/types/algebra_polynom.PolynomParsingType.html +61 -61
- package/docs/types/coefficients_fraction.FractionParsingType.html +60 -60
- package/docs/types/shutingyard.Token.html +71 -71
- package/docs/types/shutingyard.tokenType.html +76 -76
- package/docs/variables/shutingyard.tokenConstant.html +69 -69
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/maths/algebra/study.d.ts +1 -0
- package/esm/maths/algebra/study.js +9 -8
- package/esm/maths/algebra/study.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -1
- package/src/maths/algebra/study.ts +11 -9
- package/tests/numexp.test.ts +12 -0
package/.eslintrc.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es6": true
|
|
5
|
-
},
|
|
6
|
-
"extends": [
|
|
7
|
-
"eslint:recommended",
|
|
8
|
-
"plugin:@typescript-eslint/eslint-recommended"
|
|
9
|
-
],
|
|
10
|
-
"globals": {
|
|
11
|
-
"Atomics": "readonly",
|
|
12
|
-
"SharedArrayBuffer": "readonly"
|
|
13
|
-
},
|
|
14
|
-
"parser": "@typescript-eslint/parser",
|
|
15
|
-
"parserOptions": {
|
|
16
|
-
"ecmaVersion": 2018,
|
|
17
|
-
"sourceType": "module"
|
|
18
|
-
},
|
|
19
|
-
"plugins": [
|
|
20
|
-
"@typescript-eslint"
|
|
21
|
-
],
|
|
22
|
-
"rules": {
|
|
23
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": true,
|
|
4
|
+
"es6": true
|
|
5
|
+
},
|
|
6
|
+
"extends": [
|
|
7
|
+
"eslint:recommended",
|
|
8
|
+
"plugin:@typescript-eslint/eslint-recommended"
|
|
9
|
+
],
|
|
10
|
+
"globals": {
|
|
11
|
+
"Atomics": "readonly",
|
|
12
|
+
"SharedArrayBuffer": "readonly"
|
|
13
|
+
},
|
|
14
|
+
"parser": "@typescript-eslint/parser",
|
|
15
|
+
"parserOptions": {
|
|
16
|
+
"ecmaVersion": 2018,
|
|
17
|
+
"sourceType": "module"
|
|
18
|
+
},
|
|
19
|
+
"plugins": [
|
|
20
|
+
"@typescript-eslint"
|
|
21
|
+
],
|
|
22
|
+
"rules": {
|
|
23
|
+
}
|
|
24
24
|
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Index: src/maths/expressions/numexp.ts
|
|
2
|
+
IDEA additional info:
|
|
3
|
+
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
4
|
+
<+>import {Shutingyard, ShutingyardMode, ShutingyardType, tokenConstant} from \"../shutingyard\";\r\nimport {Fraction} from \"../coefficients/fraction\";\r\n\r\nexport class NumExp {\r\n private _rpn: { token: string, tokenType: string }[]\r\n private _expression: string\r\n private _isValid: boolean\r\n\r\n constructor(value: string, uniformize?:boolean) {\r\n this._expression = value\r\n try {\r\n this._rpn = new Shutingyard(ShutingyardMode.NUMERIC).parse(value, uniformize || uniformize===undefined).rpn\r\n }catch(e){\r\n this._rpn = null\r\n this._isValid = false\r\n }\r\n }\r\n\r\n get rpn(): { token: string; tokenType: string }[] {\r\n return this._rpn;\r\n }\r\n\r\n get isValid(): boolean {\r\n if(this._isValid===undefined){\r\n try {\r\n const v = this.evaluate({x: 0})\r\n }catch{\r\n this._isValid = false\r\n }\r\n }\r\n return this._isValid\r\n }\r\n\r\n set isValid(value: boolean){\r\n this._isValid = value\r\n }\r\n\r\n get expression(): string {\r\n return this._expression;\r\n }\r\n\r\n private _extractDecimalPart(value: number): string {\r\n let decimal = value.toString()\r\n\r\n if (!decimal.includes('.')) {\r\n return ''\r\n }\r\n\r\n decimal = decimal.split('.')[1]\r\n\r\n return decimal.substring(0, decimal.length - 2)\r\n }\r\n\r\n private _numberCorrection(value: number): number {\r\n // Must modify the number if it's like:\r\n // a: 3.0000000000000003\r\n // b: 3.9999999999999994\r\n // remove the last character\r\n // check if around n last characters are either 0 or 9\r\n // if it is, 'round' the number.\r\n\r\n const epsilon = 0.00000000000001,\r\n number_of_digits = 6\r\n\r\n const decimal = this._extractDecimalPart(value)\r\n if(decimal===''){return value}\r\n\r\n const n9 = decimal.match(/9+$/g)\r\n const n0 = decimal.match(/0+$/g)\r\n\r\n if (n9 && n9[0].length >= number_of_digits) {\r\n // New tested values.\r\n const mod = this._extractDecimalPart(value + epsilon),\r\n mod0 = mod.match(/0+$/g)\r\n\r\n if(mod0 && mod0[0].length>= number_of_digits){\r\n // The value can be changed. Remove all zeros!\r\n return +((value+epsilon).toString().split(mod0[0])[0])\r\n }\r\n }\r\n\r\n if (n0 && n0[0].length >= number_of_digits) {\r\n // New tested values.\r\n const mod = this._extractDecimalPart(value - epsilon),\r\n mod9 = mod.match(/9+$/g)\r\n\r\n if(mod9 && mod9[0].length>= number_of_digits){\r\n // The value can be changed. Remove all nines!\r\n return +(value.toString().split(n0[0])[0])\r\n }\r\n }\r\n\r\n return value\r\n }\r\n\r\n private _addToStack(stack:number[], value: number): void {\r\n stack.push(this._numberCorrection(value))\r\n }\r\n\r\n evaluate(values: { [Key: string]: number }): number {\r\n const stack: number[] = []\r\n\r\n if(this._rpn===null){\r\n this._isValid = false\r\n return 0\r\n }\r\n\r\n this.isValid = true\r\n\r\n for (const element of this._rpn) {\r\n if (element.tokenType === ShutingyardType.COEFFICIENT) {\r\n // May be a numeric value or a Fraction.\r\n if (!isNaN(+element.token)) {\r\n this._addToStack(stack, +element.token)\r\n } else {\r\n this._addToStack(stack, new Fraction(element.token).value)\r\n }\r\n } else if (element.tokenType === ShutingyardType.VARIABLE) {\r\n if (values[element.token] !== undefined) {\r\n this._addToStack(stack, +values[element.token])\r\n }\r\n } else if (element.tokenType === ShutingyardType.CONSTANT) {\r\n this._addToStack(stack, tokenConstant[element.token])\r\n } else if (element.tokenType === ShutingyardType.OPERATION) {\r\n if (element.token === '*') {\r\n const b = stack.pop(),\r\n a = stack.pop()\r\n if(a === undefined || b === undefined){this.isValid = false}\r\n this._addToStack(stack, a * b)\r\n } else if (element.token === '/') {\r\n const b = stack.pop(),\r\n a = stack.pop()\r\n if(a === undefined || b === undefined){this.isValid = false}\r\n this._addToStack(stack, a / b)\r\n } else if (element.token === '+') {\r\n const b = stack.pop(),\r\n a = stack.pop()\r\n if(a === undefined || b === undefined){this.isValid = false}\r\n this._addToStack(stack, (+a) + (+b))\r\n } else if (element.token === '-') {\r\n const b = stack.pop(),\r\n a = stack.pop() || 0\r\n if(b === undefined){this.isValid = false}\r\n this._addToStack(stack, a - b)\r\n } else if (element.token === '^') {\r\n const b = stack.pop(),\r\n a = stack.pop()\r\n if(a === undefined || b === undefined){this.isValid = false}\r\n this._addToStack(stack, Math.pow(a, b))\r\n }\r\n } else if (element.tokenType === ShutingyardType.FUNCTION) {\r\n const a = stack.pop()\r\n if(a === undefined){this.isValid = false}\r\n if (element.token === 'sin') {\r\n this._addToStack(stack, Math.sin(a))\r\n } else if (element.token === 'cos') {\r\n this._addToStack(stack, Math.cos(a))\r\n } else if (element.token === 'tan') {\r\n this._addToStack(stack, Math.tan(a))\r\n } else if(element.token === 'sqrt') {\r\n this._addToStack(stack, Math.sqrt(a))\r\n }else if(element.token ==='nthrt') {\r\n // TODO: support nthrt in num. exp.\r\n let b = stack.pop()\r\n if(a%2===0 && b<0){\r\n this._addToStack(stack, NaN)\r\n }else {\r\n this._addToStack(stack, (b < 0 ? -1 : 1) * Math.pow(Math.abs(b), 1 / a))\r\n }\r\n } else if(element.token === 'ln'){\r\n this._addToStack(stack, Math.log(a))\r\n } else if(element.token === 'log') {\r\n this._addToStack(stack, Math.log10(a))\r\n }\r\n }\r\n }\r\n\r\n if (stack.length === 1) {\r\n return stack[0]\r\n } else {\r\n throw `There was a problem parsing: ${this._expression}`\r\n }\r\n }\r\n}\r\n
|
|
5
|
+
===================================================================
|
|
6
|
+
diff --git a/src/maths/expressions/numexp.ts b/src/maths/expressions/numexp.ts
|
|
7
|
+
--- a/src/maths/expressions/numexp.ts
|
|
8
|
+
+++ b/src/maths/expressions/numexp.ts
|
|
9
|
+
@@ -51,46 +51,47 @@
|
|
10
|
+
return decimal.substring(0, decimal.length - 2)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
- private _numberCorrection(value: number): number {
|
|
14
|
+
+ private _numberCorrection(value: number, number_of_digits=6): number {
|
|
15
|
+
+ return +value.toFixed(number_of_digits);
|
|
16
|
+
// Must modify the number if it's like:
|
|
17
|
+
// a: 3.0000000000000003
|
|
18
|
+
// b: 3.9999999999999994
|
|
19
|
+
// remove the last character
|
|
20
|
+
// check if around n last characters are either 0 or 9
|
|
21
|
+
// if it is, 'round' the number.
|
|
22
|
+
-
|
|
23
|
+
- const epsilon = 0.00000000000001,
|
|
24
|
+
- number_of_digits = 6
|
|
25
|
+
-
|
|
26
|
+
- const decimal = this._extractDecimalPart(value)
|
|
27
|
+
- if(decimal===''){return value}
|
|
28
|
+
-
|
|
29
|
+
- const n9 = decimal.match(/9+$/g)
|
|
30
|
+
- const n0 = decimal.match(/0+$/g)
|
|
31
|
+
-
|
|
32
|
+
- if (n9 && n9[0].length >= number_of_digits) {
|
|
33
|
+
- // New tested values.
|
|
34
|
+
- const mod = this._extractDecimalPart(value + epsilon),
|
|
35
|
+
- mod0 = mod.match(/0+$/g)
|
|
36
|
+
-
|
|
37
|
+
- if(mod0 && mod0[0].length>= number_of_digits){
|
|
38
|
+
- // The value can be changed. Remove all zeros!
|
|
39
|
+
- return +((value+epsilon).toString().split(mod0[0])[0])
|
|
40
|
+
- }
|
|
41
|
+
- }
|
|
42
|
+
-
|
|
43
|
+
- if (n0 && n0[0].length >= number_of_digits) {
|
|
44
|
+
- // New tested values.
|
|
45
|
+
- const mod = this._extractDecimalPart(value - epsilon),
|
|
46
|
+
- mod9 = mod.match(/9+$/g)
|
|
47
|
+
-
|
|
48
|
+
- if(mod9 && mod9[0].length>= number_of_digits){
|
|
49
|
+
- // The value can be changed. Remove all nines!
|
|
50
|
+
- return +(value.toString().split(n0[0])[0])
|
|
51
|
+
- }
|
|
52
|
+
- }
|
|
53
|
+
-
|
|
54
|
+
- return value
|
|
55
|
+
+ //
|
|
56
|
+
+ // const epsilon = 0.00000000000001,
|
|
57
|
+
+ // number_of_digits = 6
|
|
58
|
+
+ //
|
|
59
|
+
+ // const decimal = this._extractDecimalPart(value)
|
|
60
|
+
+ // if(decimal===''){return value}
|
|
61
|
+
+ //
|
|
62
|
+
+ // const n9 = decimal.match(/9+$/g)
|
|
63
|
+
+ // const n0 = decimal.match(/0+$/g)
|
|
64
|
+
+ //
|
|
65
|
+
+ // if (n9 && n9[0].length >= number_of_digits) {
|
|
66
|
+
+ // // New tested values.
|
|
67
|
+
+ // const mod = this._extractDecimalPart(value + epsilon),
|
|
68
|
+
+ // mod0 = mod.match(/0+$/g)
|
|
69
|
+
+ //
|
|
70
|
+
+ // if(mod0 && mod0[0].length>= number_of_digits){
|
|
71
|
+
+ // // The value can be changed. Remove all zeros!
|
|
72
|
+
+ // return +((value+epsilon).toString().split(mod0[0])[0])
|
|
73
|
+
+ // }
|
|
74
|
+
+ // }
|
|
75
|
+
+ //
|
|
76
|
+
+ // if (n0 && n0[0].length >= number_of_digits) {
|
|
77
|
+
+ // // New tested values.
|
|
78
|
+
+ // const mod = this._extractDecimalPart(value - epsilon),
|
|
79
|
+
+ // mod9 = mod.match(/9+$/g)
|
|
80
|
+
+ //
|
|
81
|
+
+ // if(mod9 && mod9[0].length>= number_of_digits){
|
|
82
|
+
+ // // The value can be changed. Remove all nines!
|
|
83
|
+
+ // return +(value.toString().split(n0[0])[0])
|
|
84
|
+
+ // }
|
|
85
|
+
+ // }
|
|
86
|
+
+ //
|
|
87
|
+
+ // return value
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private _addToStack(stack:number[], value: number): void {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Index: src/index.ts
|
|
2
|
+
IDEA additional info:
|
|
3
|
+
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
4
|
+
<+>import {Numeric} from \"./maths/numeric\";\r\nimport {NumExp} from \"./maths/expressions/numexp\";\r\nimport {Shutingyard} from \"./maths/shutingyard\";\r\nimport {Random} from \"./maths/randomization/random\";\r\nimport {Fraction} from \"./maths/coefficients/fraction\";\r\nimport {NthRoot} from \"./maths/coefficients/nthRoot\";\r\nimport {Monom} from \"./maths/algebra/monom\";\r\nimport {Polynom} from \"./maths/algebra/polynom\";\r\nimport {Equation} from \"./maths/algebra/equation\";\r\nimport {LinearSystem} from \"./maths/algebra/linearSystem\";\r\nimport {Rational} from \"./maths/algebra/rational\";\r\nimport {Logicalset} from \"./maths/algebra/logicalset\";\r\nimport {PolynomExpFactor, PolynomExpProduct} from \"./maths/expressions/polynomexp\";\r\nimport {Vector} from \"./maths/geometry/vector\";\r\nimport {Line} from \"./maths/geometry/line\";\r\nimport {Triangle} from \"./maths/geometry/triangle\";\r\nimport {Circle} from \"./maths/geometry/circle\";\r\nimport {Point} from \"./maths/geometry/point\";\r\n\r\n// Expose as global\r\nexport const PiMath = {\r\n ShutingYard: Shutingyard,\r\n Numeric: Numeric,\r\n NumExp: NumExp,\r\n Fraction: Fraction,\r\n Root: NthRoot,\r\n Monom: Monom,\r\n Polynom: Polynom,\r\n Equation: Equation,\r\n LinearSystem: LinearSystem,\r\n Rational: Rational,\r\n Logicalset: Logicalset,\r\n Random: Random,\r\n PolynomExpFactor: PolynomExpFactor,\r\n PolynomExpProduct: PolynomExpProduct,\r\n Geometry: {\r\n Vector: Vector,\r\n Point: Point,\r\n Line: Line,\r\n Triangle: Triangle,\r\n Circle: Circle\r\n }\r\n};\r\n\r\n(<any>window).Pi = PiMath\r\n
|
|
5
|
+
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
6
|
+
<+>UTF-8
|
|
7
|
+
===================================================================
|
|
8
|
+
diff --git a/src/index.ts b/src/index.ts
|
|
9
|
+
--- a/src/index.ts
|
|
10
|
+
+++ b/src/index.ts
|
|
11
|
+
@@ -42,4 +42,5 @@
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
-(<any>window).Pi = PiMath
|
|
16
|
+
+// rename window.Pi to window.PiMath
|
|
17
|
+
+(<any>window).PiMath = PiMath
|
|
18
|
+
Index: tests/numexp.test.ts
|
|
19
|
+
IDEA additional info:
|
|
20
|
+
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
21
|
+
<+>import {expect} from 'chai';\r\nimport {NumExp} from \"../src/maths/expressions/numexp\";\r\nimport {Numeric} from \"../src/maths/numeric\";\r\n\r\ndescribe('Numerical expression', () => { // the tests container\r\n it('RPN for numerical expression', () => {\r\n const RPN = new NumExp('3*x+5').rpn\r\n expect(RPN.map(x => x.token)).to.have.all.members(['3', 'x', '*', '5', '+'])\r\n\r\n const RPN2 = new NumExp('-3*x^2-5').rpn\r\n expect(RPN2.map(x => x.token)).to.have.all.members(['3', 'x', '2', '^', '*', '-', '5', '-'])\r\n })\r\n\r\n it('Evaluate for numerical expression', () => {\r\n const expr = new NumExp('3*x+5')\r\n expect(expr.evaluate({x: 5})).to.be.equal(20)\r\n\r\n const expr2 = new NumExp('-3*x^2-5')\r\n expect(expr2.evaluate({x: -2})).to.be.equal(-17)\r\n })\r\n\r\n it('Evaluation simple mathematical functions', () => {\r\n const expr = new NumExp('sqrt(x)')\r\n expect(expr.evaluate({x: 9})).to.be.equal(3)\r\n })\r\n\r\n it('should detect invalid rpn parsing', function () {\r\n const exprValid = new NumExp('3*sin(x)'),\r\n exprInvalid = new NumExp('3*sin')\r\n\r\n expect(exprValid.isValid).to.be.true\r\n expect(exprInvalid.isValid).to.be.false\r\n });\r\n\r\n it('souldd detect invalid expression withouth crahsing', function() {\r\n const exprPourrie = new NumExp('3xsi'),\r\n exprOk = new NumExp('3xsin(x)')\r\n\r\n expect(exprPourrie.isValid).to.be.false\r\n expect(exprOk.isValid).to.be.true\r\n })\r\n\r\n it('should parse without mult sign', function () {\r\n\r\n let a = 1 / 5\r\n\r\n const expr = new NumExp('3x-5', true)\r\n expect(expr.isValid).to.be.true\r\n expect(expr.evaluate({x: 2})).to.be.equal(1)\r\n\r\n const expr2 = new NumExp('3*x-5', true)\r\n expect(expr2.isValid).to.be.true\r\n expect(expr2.evaluate({x: 2})).to.be.equal(1)\r\n });\r\n\r\n it('should calculate sqrt from exp', function(){\r\n // let a = new NumExp('x^(1/3)')\r\n // console.log(a.evaluate({x: 8}))\r\n\r\n let k = new NumExp('nthrt(x,3)')\r\n expect(k.evaluate({x: -8})).to.be.equal(-2)\r\n expect(k.evaluate({x: 27})).to.be.equal(3)\r\n\r\n let p = new NumExp('nthrt(x,4)')\r\n expect(p.evaluate({x: 16})).to.be.equal(2)\r\n expect(p.evaluate({x: -16})).to.be.NaN\r\n })\r\n});\r\n
|
|
22
|
+
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
23
|
+
<+>UTF-8
|
|
24
|
+
===================================================================
|
|
25
|
+
diff --git a/tests/numexp.test.ts b/tests/numexp.test.ts
|
|
26
|
+
--- a/tests/numexp.test.ts
|
|
27
|
+
+++ b/tests/numexp.test.ts
|
|
28
|
+
@@ -65,4 +65,16 @@
|
|
29
|
+
expect(p.evaluate({x: 16})).to.be.equal(2)
|
|
30
|
+
expect(p.evaluate({x: -16})).to.be.NaN
|
|
31
|
+
})
|
|
32
|
+
+
|
|
33
|
+
+ it('should work with constant', function () {
|
|
34
|
+
+
|
|
35
|
+
+ let k = new NumExp('2pi*x')
|
|
36
|
+
+ expect(k.evaluate({x: 1})).to.be.equal(6.283186)
|
|
37
|
+
+ });
|
|
38
|
+
+
|
|
39
|
+
+ it('should work with constant but without variables', function () {
|
|
40
|
+
+
|
|
41
|
+
+ let k = new NumExp('2pi')
|
|
42
|
+
+ expect(k.evaluate()).to.be.equal(6.283186)
|
|
43
|
+
+ });
|
|
44
|
+
});
|
|
45
|
+
Index: tests/algebra/linear.test.ts
|
|
46
|
+
IDEA additional info:
|
|
47
|
+
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
48
|
+
<+>import {describe} from \"mocha\";\r\nimport {expect} from \"chai\";\r\nimport {LinearSystem} from \"../../src/maths/algebra/linearSystem\";\r\nimport {Polynom} from \"../../src/maths/algebra/polynom\";\r\nimport exp = require(\"constants\");\r\n\r\ndescribe('Linear systems tests', () => {\r\n it('should solve a 2x2 equations', () => {\r\n let LS = new LinearSystem(\r\n '4x+5y=11',\r\n '7y-24=3x'\r\n )\r\n LS.solve(true)\r\n\r\n expect(LS.solution).to.be.equal('\\\\left(-1;3\\\\right)')\r\n })\r\n it('should solve a 3x3 equations', () => {\r\n let LS = new LinearSystem(\r\n '2x+7y-z=-3',\r\n '-3x+2y+3z=12',\r\n '-5x-3y+2z=5'\r\n )\r\n\r\n LS.solve()\r\n console.log(LS.solution)\r\n })\r\n\r\n it('should solve a 3x3 equations II ', () => {\r\n let LS = new LinearSystem(\r\n '-x+y-z=-6',\r\n '3x+2y+z=14',\r\n '5x+y+3z=7'\r\n )\r\n\r\n LS.solve()\r\n console.log(LS.solution)\r\n })\r\n\r\n it('should calculate the reduction', function () {\r\n let E1 = new Polynom('6x+21y-3z'),\r\n E2 = new Polynom('-6x+21y-3z')\r\n\r\n // Start from hre\r\n console.log('------------')\r\n console.log(E1.tex, E2.tex)\r\n\r\n console.log(E1.monoms.map(x => x.tex))\r\n console.log(E2.monoms.map(x => x.tex))\r\n E1.add(E2);\r\n\r\n console.log(E1.tex)\r\n });\r\n\r\n it('should use a reduced linear reducation', function () {\r\n let LS = new LinearSystem(\r\n '3x-6y+3=0',\r\n 'x+12y-6=0'\r\n )\r\n LS.solve(true)\r\n\r\n const tex = LS.stepTex('x')\r\n\r\n expect(+LS.resolutionSteps['x'][0].operations[0][0]).to.be.equal(2)\r\n expect(+LS.resolutionSteps['x'][0].operations[1][0]).to.be.equal(1)\r\n });\r\n})\r\n
|
|
49
|
+
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
50
|
+
<+>UTF-8
|
|
51
|
+
===================================================================
|
|
52
|
+
diff --git a/tests/algebra/linear.test.ts b/tests/algebra/linear.test.ts
|
|
53
|
+
--- a/tests/algebra/linear.test.ts
|
|
54
|
+
+++ b/tests/algebra/linear.test.ts
|
|
55
|
+
@@ -63,4 +63,34 @@
|
|
56
|
+
expect(+LS.resolutionSteps['x'][0].operations[0][0]).to.be.equal(2)
|
|
57
|
+
expect(+LS.resolutionSteps['x'][0].operations[1][0]).to.be.equal(1)
|
|
58
|
+
});
|
|
59
|
+
+
|
|
60
|
+
+ it('should calculate what i need', function (){
|
|
61
|
+
+ let LS = new LinearSystem(
|
|
62
|
+
+ '15x-8y+16=0',
|
|
63
|
+
+ '5x+12y-24=0'
|
|
64
|
+
+ )
|
|
65
|
+
+ LS.solve()
|
|
66
|
+
+ console.log(LS.solution)
|
|
67
|
+
+
|
|
68
|
+
+ let LS2 = new LinearSystem(
|
|
69
|
+
+ '15x-8y+16=0',
|
|
70
|
+
+ '3x-4y-6=0'
|
|
71
|
+
+ )
|
|
72
|
+
+ LS2.solve()
|
|
73
|
+
+ console.log(LS2.solution)
|
|
74
|
+
+
|
|
75
|
+
+ let LS3 = new LinearSystem(
|
|
76
|
+
+ '5x+12y-24=0',
|
|
77
|
+
+ '3x-4y-6=0'
|
|
78
|
+
+ )
|
|
79
|
+
+ LS3.solve()
|
|
80
|
+
+ console.log(LS3.solution)
|
|
81
|
+
+
|
|
82
|
+
+ let LS4 = new LinearSystem(
|
|
83
|
+
+ '70x+25y-50=0',
|
|
84
|
+
+ '63x-54y-11=0'
|
|
85
|
+
+ )
|
|
86
|
+
+ LS4.solve()
|
|
87
|
+
+ console.log(LS4.solution)
|
|
88
|
+
+ })
|
|
89
|
+
})
|
|
90
|
+
Index: LICENSE.md
|
|
91
|
+
IDEA additional info:
|
|
92
|
+
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
93
|
+
<+>MIT License\r\n\r\nCopyright (c) 2020 Basil Gass\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n
|
|
94
|
+
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
95
|
+
<+>UTF-8
|
|
96
|
+
===================================================================
|
|
97
|
+
diff --git a/LICENSE.md b/LICENSE.md
|
|
98
|
+
--- a/LICENSE.md
|
|
99
|
+
+++ b/LICENSE.md
|
|
100
|
+
@@ -1,6 +1,6 @@
|
|
101
|
+
MIT License
|
|
102
|
+
|
|
103
|
+
-Copyright (c) 2020 Basil Gass
|
|
104
|
+
+Copyright (c) 2023 Basil Gass
|
|
105
|
+
|
|
106
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
107
|
+
of this software and associated documentation files (the "Software"), to deal
|
package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<changelist name="Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]" date="1690205520775" recycled="false" toDelete="true">
|
|
2
|
+
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch" />
|
|
3
|
+
<option name="DESCRIPTION" value="Uncommitted changes before Update at 24.07.2023 15:31 [Default Changelist]" />
|
|
4
|
+
</changelist>
|
package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_1.xml
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<changelist name="Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]1" date="1690205596619" recycled="true" deleted="true">
|
|
2
|
+
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]1/shelved.patch" />
|
|
3
|
+
<option name="DESCRIPTION" value="Uncommitted changes before Update at 24.07.2023 15:31 [Default Changelist]" />
|
|
4
|
+
</changelist>
|