pimath 0.0.12 → 0.0.16
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/.idea/codeStyles/codeStyleConfig.xml +1 -1
- package/dev/index.html +9 -7
- package/dev/pi.js +364 -229
- package/dev/pi.js.map +1 -1
- package/dist/pi.js +1 -1
- package/dist/pi.js.map +1 -1
- package/docs/assets/highlight.css +7 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/algebra.Algebra.Equation.html +26 -0
- package/docs/classes/algebra.Algebra.LinearSystem.html +1 -0
- package/docs/classes/algebra.Algebra.LogicalSet.html +3 -0
- package/docs/classes/algebra.Algebra.Monom.html +111 -0
- package/docs/classes/algebra.Algebra.Polynom.html +36 -0
- package/docs/classes/algebra.Algebra.Rational.html +2 -0
- package/docs/classes/algebra.Equation.html +28 -0
- package/docs/classes/algebra.LinearSystem.html +1 -0
- package/docs/classes/algebra.Logicalset.html +5 -0
- package/docs/classes/algebra.Monom.html +111 -0
- package/docs/classes/algebra.Polynom.html +43 -0
- package/docs/classes/algebra.Rational.html +4 -0
- package/docs/classes/coefficients.Fraction.html +15 -0
- package/docs/classes/coefficients.Nthroot.html +1 -0
- package/docs/classes/geometry.Circle.html +1 -0
- package/docs/classes/geometry.Geometry.Circle.html +1 -0
- package/docs/classes/geometry.Geometry.Line.html +1 -0
- package/docs/classes/geometry.Geometry.Point.html +1 -0
- package/docs/classes/geometry.Geometry.Triangle.html +9 -0
- package/docs/classes/geometry.Geometry.Vector.html +1 -0
- package/docs/classes/geometry.Line.html +1 -0
- package/docs/classes/geometry.Point.html +1 -0
- package/docs/classes/geometry.Triangle.html +17 -0
- package/docs/classes/geometry.Vector.html +1 -0
- package/docs/classes/{Numeric.html → numeric.Numeric.html} +5 -5
- package/docs/classes/shutingyard.Shutingyard.html +19 -0
- package/docs/index.html +2 -2
- package/docs/interfaces/geometry.remarquableLines.html +1 -0
- package/docs/modules/algebra.Algebra.html +1 -0
- package/docs/modules/algebra.html +1 -0
- package/docs/modules/coefficients.html +1 -0
- package/docs/modules/geometry.Geometry.html +1 -0
- package/docs/modules/geometry.html +1 -0
- package/docs/modules/numeric.html +1 -0
- package/docs/modules/random.Random.html +1 -0
- package/docs/modules/random.html +1 -0
- package/docs/modules/shutingyard.html +1 -0
- package/docs/modules.html +1 -1
- package/esm/main.js +1 -1
- package/esm/main.js.map +1 -1
- package/esm/maths/algebra/equation.js +2 -2
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +1 -1
- package/esm/maths/algebra/linearSystem.js +2 -2
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.js.map +1 -1
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +3 -1
- package/esm/maths/algebra/polynom.js +5 -2
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +1 -2
- package/esm/maths/random/index.d.ts +13 -0
- package/esm/maths/random/index.js +28 -0
- package/esm/maths/random/index.js.map +1 -0
- package/esm/maths/random/rndMonom.js +1 -1
- package/esm/maths/random/rndMonom.js.map +1 -1
- package/esm/maths/random/rndPolynom.d.ts +1 -1
- package/esm/maths/random/rndPolynom.js +12 -3
- package/esm/maths/random/rndPolynom.js.map +1 -1
- package/package.json +1 -1
- package/src/main.ts +1 -1
- package/src/maths/algebra/equation.ts +20 -5
- package/src/maths/algebra/index.ts +1 -1
- package/src/maths/algebra/linearSystem.ts +265 -265
- package/src/maths/algebra/logicalset.ts +162 -150
- package/src/maths/algebra/monom.ts +631 -629
- package/src/maths/algebra/polynom.ts +1144 -1141
- package/src/maths/algebra/rational.ts +110 -99
- package/src/maths/geometry/index.ts +1 -1
- package/src/maths/geometry/triangle.ts +1 -1
- package/src/maths/random/{random.ts → index.ts} +4 -17
- package/src/maths/random/rndMonom.ts +1 -1
- package/src/maths/random/rndPolynom.ts +16 -5
- package/tests/algebra/monom.test.ts +1 -1
- package/tsconfig.json +9 -2
- package/docs/classes/Circle.html +0 -1
- package/docs/classes/Equation.html +0 -19
- package/docs/classes/Fraction.html +0 -15
- package/docs/classes/Line.html +0 -1
- package/docs/classes/LinearSystem.html +0 -1
- package/docs/classes/Logicalset.html +0 -5
- package/docs/classes/Monom.html +0 -111
- package/docs/classes/Nthroot.html +0 -1
- package/docs/classes/Point.html +0 -1
- package/docs/classes/Polynom.html +0 -43
- package/docs/classes/Rational.html +0 -4
- package/docs/classes/Shutingyard.html +0 -19
- package/docs/classes/Triangle.html +0 -17
- package/docs/classes/Vector.html +0 -1
- package/docs/modules/Random.html +0 -1
- package/src/docs.ts +0 -7
|
@@ -8,164 +8,176 @@ import {Shutingyard} from '../shutingyard';
|
|
|
8
8
|
/**
|
|
9
9
|
* Polynom class can handle polynoms, reorder, resolve, ...
|
|
10
10
|
*/
|
|
11
|
-
export class Logicalset {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get isLogicalset() {
|
|
26
|
-
return true;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
private parse = (value: string): Logicalset => {
|
|
30
|
-
// TODO: Must format the value string to convert some items...
|
|
31
|
-
|
|
32
|
-
// Parse the updated value to the shutingyard algorithm
|
|
33
|
-
this._rpn = new Shutingyard('set').parse(value).rpn;
|
|
34
|
-
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
evaluate(tokenSets: { [key: string]: any[] }, reference?: any[]): any[] {
|
|
39
|
-
let varStack: (Set<unknown>)[] = []
|
|
40
|
-
|
|
41
|
-
let referenceSet: Set<unknown>
|
|
42
|
-
if (reference === undefined) {
|
|
43
|
-
referenceSet = new Set()
|
|
44
|
-
for (let key in tokenSets) {
|
|
45
|
-
referenceSet = new Set([...referenceSet, ...tokenSets[key]])
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
referenceSet = new Set(reference)
|
|
11
|
+
export class Logicalset {
|
|
12
|
+
private _rawString: string;
|
|
13
|
+
private _rpn: { token: string, tokenType: string }[]
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param {string} value (optional) Default polynom to parse on class creation
|
|
18
|
+
*/
|
|
19
|
+
constructor(value: string) {
|
|
20
|
+
this._rawString = value
|
|
21
|
+
this.parse(value)
|
|
22
|
+
return this;
|
|
49
23
|
}
|
|
50
24
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
25
|
+
get isLogicalset() {
|
|
26
|
+
return true;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
private parse = (value: string): Logicalset => {
|
|
30
|
+
// TODO: Must format the value string to convert some items...
|
|
31
|
+
|
|
32
|
+
// Parse the updated value to the shutingyard algorithm
|
|
33
|
+
this._rpn = new Shutingyard('set').parse(value).rpn;
|
|
34
|
+
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
59
37
|
|
|
38
|
+
evaluate(tokenSets: { [key: string]: any[] }, reference?: any[]): any[] {
|
|
39
|
+
let varStack: (Set<unknown>)[] = []
|
|
40
|
+
|
|
41
|
+
let referenceSet: Set<unknown>
|
|
42
|
+
if (reference === undefined) {
|
|
43
|
+
referenceSet = new Set()
|
|
44
|
+
for (let key in tokenSets) {
|
|
45
|
+
referenceSet = new Set([...referenceSet, ...tokenSets[key]])
|
|
46
|
+
}
|
|
60
47
|
} else {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
first
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
48
|
+
referenceSet = new Set(reference)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
for (let token of this._rpn) {
|
|
52
|
+
if (token.tokenType === 'variable') {
|
|
53
|
+
// The variable has no token - assume it's empty.
|
|
54
|
+
if (tokenSets[token.token] === undefined) {
|
|
55
|
+
varStack.push(new Set())
|
|
56
|
+
} else {
|
|
57
|
+
varStack.push(new Set(tokenSets[token.token]));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
} else {
|
|
61
|
+
switch (token.token) {
|
|
62
|
+
case '&':
|
|
63
|
+
if (varStack.length >= 2) {
|
|
64
|
+
let second = varStack.pop(),
|
|
65
|
+
first = varStack.pop()
|
|
66
|
+
|
|
67
|
+
varStack.push(new Set([...first].filter(x => second.has(x))))
|
|
68
|
+
}
|
|
69
|
+
break
|
|
70
|
+
case '|':
|
|
71
|
+
if (varStack.length >= 2) {
|
|
72
|
+
let second = varStack.pop(),
|
|
73
|
+
first = varStack.pop()
|
|
74
|
+
varStack.push(new Set([...first, ...second]))
|
|
75
|
+
}
|
|
76
|
+
break
|
|
77
|
+
case '-':
|
|
78
|
+
if (varStack.length >= 2) {
|
|
79
|
+
let second = varStack.pop(),
|
|
80
|
+
first = varStack.pop()
|
|
81
|
+
varStack.push(new Set([...first].filter(x => !second.has(x))))
|
|
82
|
+
}
|
|
83
|
+
break
|
|
84
|
+
case '!':
|
|
85
|
+
if (varStack.length >= 1) {
|
|
86
|
+
let first = varStack.pop()
|
|
87
|
+
|
|
88
|
+
varStack.push(new Set([...referenceSet].filter(x => !first.has(x))))
|
|
89
|
+
}
|
|
90
|
+
break
|
|
91
|
+
}
|
|
91
92
|
}
|
|
92
93
|
}
|
|
94
|
+
|
|
95
|
+
return [...varStack[0]].sort();
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
98
|
+
vennAB(): any[] {
|
|
99
|
+
return this.evaluate({
|
|
100
|
+
A: ['A', 'AB'],
|
|
101
|
+
B: ['B', 'AB']
|
|
102
|
+
},
|
|
103
|
+
['A', 'B', 'AB', 'E']
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
vennABC(): any[] {
|
|
108
|
+
return this.evaluate({
|
|
109
|
+
A: ['A', 'AB', 'AC', 'ABC'],
|
|
110
|
+
B: ['B', 'AB', 'BC', 'ABC'],
|
|
111
|
+
C: ['C', 'AC', 'BC', 'ABC']
|
|
112
|
+
},
|
|
113
|
+
['A', 'B', 'C', 'AB', 'AC', 'BC', 'E']
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get rpn(): { token: string, tokenType: string }[] {
|
|
118
|
+
return this._rpn
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
get tex(): string {
|
|
122
|
+
let varStack: { token: string, tokenType: string } [] = []
|
|
123
|
+
|
|
124
|
+
for (let token of this._rpn) {
|
|
125
|
+
if (token.tokenType === 'variable') {
|
|
126
|
+
varStack.push(token);
|
|
127
|
+
} else {
|
|
128
|
+
switch (token.token) {
|
|
129
|
+
case '&':
|
|
130
|
+
if (varStack.length >= 2) {
|
|
131
|
+
let second = varStack.pop(),
|
|
132
|
+
first = varStack.pop()
|
|
133
|
+
|
|
134
|
+
if (first.tokenType === 'mix') {
|
|
135
|
+
first.token = `( ${first.token} )`
|
|
136
|
+
}
|
|
137
|
+
if (second.tokenType === 'mix') {
|
|
138
|
+
second.token = `( ${second.token} )`
|
|
139
|
+
}
|
|
140
|
+
varStack.push({token: `${first.token} \\cap ${second.token}`, tokenType: 'mix'})
|
|
141
|
+
}
|
|
142
|
+
break
|
|
143
|
+
case '|':
|
|
144
|
+
if (varStack.length >= 2) {
|
|
145
|
+
let second = varStack.pop(),
|
|
146
|
+
first = varStack.pop()
|
|
147
|
+
|
|
148
|
+
if (first.tokenType === 'mix') {
|
|
149
|
+
first.token = `( ${first.token} )`
|
|
150
|
+
}
|
|
151
|
+
if (second.tokenType === 'mix') {
|
|
152
|
+
second.token = `( ${second.token} )`
|
|
153
|
+
}
|
|
154
|
+
varStack.push({token: `${first.token} \\cup ${second.token}`, tokenType: 'mix'})
|
|
155
|
+
}
|
|
156
|
+
break
|
|
157
|
+
case '-':
|
|
158
|
+
if (varStack.length >= 2) {
|
|
159
|
+
let second = varStack.pop(),
|
|
160
|
+
first = varStack.pop()
|
|
161
|
+
|
|
162
|
+
if (first.tokenType === 'mix') {
|
|
163
|
+
first.token = `( ${first.token} )`
|
|
164
|
+
}
|
|
165
|
+
if (second.tokenType === 'mix') {
|
|
166
|
+
second.token = `( ${second.token} )`
|
|
167
|
+
}
|
|
168
|
+
varStack.push({token: `${first.token} \\setminus ${second.token}`, tokenType: 'mix'})
|
|
169
|
+
}
|
|
170
|
+
break
|
|
171
|
+
case '!':
|
|
172
|
+
if (varStack.length >= 1) {
|
|
173
|
+
let first = varStack.pop()
|
|
174
|
+
varStack.push({token: `\\overline{ ${first.token} }`, tokenType: 'variable'})
|
|
175
|
+
}
|
|
176
|
+
break
|
|
177
|
+
}
|
|
165
178
|
}
|
|
166
179
|
}
|
|
167
|
-
}
|
|
168
180
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
181
|
+
return varStack[0].token
|
|
182
|
+
}
|
|
183
|
+
}
|