mathai 0.6.1__py3-none-any.whl → 0.6.3__py3-none-any.whl
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.
- mathai/base.py +4 -4
- mathai/matrix.py +6 -1
- mathai/parser.py +7 -4
- mathai/simplify.py +1 -0
- {mathai-0.6.1.dist-info → mathai-0.6.3.dist-info}/METADATA +1 -1
- {mathai-0.6.1.dist-info → mathai-0.6.3.dist-info}/RECORD +8 -8
- {mathai-0.6.1.dist-info → mathai-0.6.3.dist-info}/WHEEL +0 -0
- {mathai-0.6.1.dist-info → mathai-0.6.3.dist-info}/top_level.txt +0 -0
mathai/base.py
CHANGED
|
@@ -8,7 +8,7 @@ def contains_list_or_neg(node):
|
|
|
8
8
|
return True
|
|
9
9
|
return False
|
|
10
10
|
class TreeNode:
|
|
11
|
-
matmul =
|
|
11
|
+
matmul = None
|
|
12
12
|
|
|
13
13
|
def __init__(self, name, children=None):
|
|
14
14
|
if children is None:
|
|
@@ -18,11 +18,11 @@ class TreeNode:
|
|
|
18
18
|
children = copy.deepcopy(children)
|
|
19
19
|
self.name = name
|
|
20
20
|
|
|
21
|
-
if name == "f_add" or (name == "f_mul" and TreeNode.matmul):
|
|
21
|
+
if name == "f_add" or (name == "f_mul" and (TreeNode.matmul == True or TreeNode.matmul is None)):
|
|
22
22
|
keyed = [(str_form(c), c) for c in children]
|
|
23
23
|
self.children = [c for _, c in sorted(keyed)]
|
|
24
24
|
|
|
25
|
-
elif name == "f_mul":
|
|
25
|
+
elif name == "f_mul" and TreeNode.matmul == False:
|
|
26
26
|
sortable = []
|
|
27
27
|
fixed = []
|
|
28
28
|
for c in children:
|
|
@@ -291,7 +291,7 @@ def compute(eq):
|
|
|
291
291
|
return values[0] - values[1]
|
|
292
292
|
elif eq.name == "f_rad":
|
|
293
293
|
return values[0] * math.pi / 180
|
|
294
|
-
elif eq.name
|
|
294
|
+
elif eq.name in ["f_wmul", "f_mul"]:
|
|
295
295
|
result = 1.0
|
|
296
296
|
for v in values:
|
|
297
297
|
result *= v
|
mathai/matrix.py
CHANGED
|
@@ -93,4 +93,9 @@ def fold_wmul(eq):
|
|
|
93
93
|
def flat(eq):
|
|
94
94
|
return flatten_tree(tree_form(str_form(eq).replace("f_w","f_")))
|
|
95
95
|
def matrix_solve(eq):
|
|
96
|
-
|
|
96
|
+
if TreeNode.matmul == True:
|
|
97
|
+
TreeNode.matmul = False
|
|
98
|
+
eq = simplify(eq)
|
|
99
|
+
eq = flat(dowhile(eq, lambda x: fold_wmul(flat(x))))
|
|
100
|
+
TreeNode.matmul = True
|
|
101
|
+
return eq
|
mathai/parser.py
CHANGED
|
@@ -33,7 +33,7 @@ grammar = """
|
|
|
33
33
|
| comparison "<=" arithmetic -> le
|
|
34
34
|
| comparison ">=" arithmetic -> ge
|
|
35
35
|
|
|
36
|
-
?arithmetic: arithmetic "+" term ->
|
|
36
|
+
?arithmetic: arithmetic "+" term -> add
|
|
37
37
|
| arithmetic "-" term -> sub
|
|
38
38
|
| term
|
|
39
39
|
|
|
@@ -130,7 +130,7 @@ def parse(equation, funclist=None):
|
|
|
130
130
|
if tree_node.name == "pass_through":
|
|
131
131
|
return fxchange(tree_node.children[0])
|
|
132
132
|
return TreeNode(
|
|
133
|
-
"f_" + tree_node.name if tree_node.name in tmp3 + ["limitpinf", "limit", "try", "ref", "sqrt","imply","forall","exist","exclude","union","intersection","len","index","angle","charge","sum2","electricfield","line","point","sum","transpose","equationrhs","equationlhs","equation","covariance","variance","expect","error","laplace","dot","curl","pdif","diverge","gradient","rad","ge","le","gt","lt","eqtri","linesegment","midpoint","mag","point1","point2","point3","line1","line2","line3","log10","arcsin","arccos","arctan","list","cosec","sec","cot","equiv","or","not","and","circumcenter","eq","sub","
|
|
133
|
+
"f_" + tree_node.name if tree_node.name in tmp3 + ["limitpinf", "limit", "try", "ref", "sqrt","imply","forall","exist","exclude","union","intersection","len","index","angle","charge","sum2","electricfield","line","point","sum","transpose","equationrhs","equationlhs","equation","covariance","variance","expect","error","laplace","dot","curl","pdif","diverge","gradient","rad","ge","le","gt","lt","eqtri","linesegment","midpoint","mag","point1","point2","point3","line1","line2","line3","log10","arcsin","arccos","arctan","list","cosec","sec","cot","equiv","or","not","and","circumcenter","eq","sub","add","sin","cos","tan","wmul","integrate","dif","pow","div","log","abs"] else "d_" + tree_node.name,
|
|
134
134
|
[fxchange(child) for child in tree_node.children]
|
|
135
135
|
)
|
|
136
136
|
|
|
@@ -153,6 +153,9 @@ def parse(equation, funclist=None):
|
|
|
153
153
|
tree_node.children = [rfx(child) for child in tree_node.children]
|
|
154
154
|
return tree_node
|
|
155
155
|
tree_node = rfx(tree_node)
|
|
156
|
-
tree_node = flatten_tree(tree_node, ["f_wmul"
|
|
157
|
-
|
|
156
|
+
tree_node = flatten_tree(tree_node, ["f_wmul"])
|
|
157
|
+
if TreeNode.matmul == True:
|
|
158
|
+
TreeNode.matmul = False
|
|
159
|
+
tree_node = tree_form(str_form(tree_node).replace("f_w","f_"))
|
|
160
|
+
TreeNode.matmul = True
|
|
158
161
|
return tree_node
|
mathai/simplify.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
mathai/__init__.py,sha256=gzddzgNCG3Bg5BnqrDYvO71SzK4hu9fbo4nGEaDaG5Q,1554
|
|
2
2
|
mathai/apart.py,sha256=VSS3khE9PNuxiRvdU5JDl4IN-KJBSIFjwR17pkhviXI,4197
|
|
3
|
-
mathai/base.py,sha256=
|
|
3
|
+
mathai/base.py,sha256=_VIVHzJ2wYAJjPn7asNvrhlHOqTtOwUgmohvmA9pUso,15552
|
|
4
4
|
mathai/bivariate_inequality.py,sha256=Da-A1kqVynR0tNOlEI7GSTf5T2vNkcF4etL9-EoyPJg,11415
|
|
5
5
|
mathai/console.py,sha256=Sn58iwYE79MLEh67s8X3q6vZjw6g7f9XM1T8_dBBR2o,3048
|
|
6
6
|
mathai/diff.py,sha256=RSTwlfeddvYXUDShCeRdcPjsmAS8Vf5OkYJAaUBPaiM,3060
|
|
@@ -12,17 +12,17 @@ mathai/inverse.py,sha256=ya7P8WjzfaAL3UXL7xqOh5GaIsXLDZ-F6lZFy3IEgaQ,2931
|
|
|
12
12
|
mathai/limit.py,sha256=9F8i9UZh2xb-V8A5Sd1gdhDf9c2RFgpE1GdNn9MvbWI,5703
|
|
13
13
|
mathai/linear.py,sha256=viGlPU8BPrjLWHlyNUvnfPHNH5d4ZBImiQMdyXaKGg0,5702
|
|
14
14
|
mathai/logic.py,sha256=Ndz4Fd6aNCmzFlqoPyyIpSmV_BXmYHsurePjLyZJoNc,9809
|
|
15
|
-
mathai/matrix.py,sha256=
|
|
15
|
+
mathai/matrix.py,sha256=atXZlgiDgqI3cRyQ78GrDCWiy7oWWelq-XHvC_kH_DE,3324
|
|
16
16
|
mathai/ode.py,sha256=zxxTXAOpt7oSsfpgI4vHsCWKXevmM96ZOBZWWs-vj8Y,4801
|
|
17
|
-
mathai/parser.py,sha256=
|
|
17
|
+
mathai/parser.py,sha256=dhI4hRiYDdmSAOrhIWkBs_Boo2BFzC1m5cbAOOfHUas,7220
|
|
18
18
|
mathai/parsetab.py,sha256=TL-4jvRM_Tx6ipwet8CFJc2DkjR4tGsbrGF_r4IC8xI,9651
|
|
19
19
|
mathai/printeq.py,sha256=MKsR6-qXig80R07vLnFPYHQMeS41FrMVj3n3arrhJpQ,1329
|
|
20
|
-
mathai/simplify.py,sha256=
|
|
20
|
+
mathai/simplify.py,sha256=HeZqQbB9SD7CAduvotQOiv4hFqGe68ZmNLl9LLJ7sAo,19619
|
|
21
21
|
mathai/structure.py,sha256=wrU7kqphSN7CqaVffyHHXD2-3t5My_Z_TtYFoUe_lTU,4099
|
|
22
22
|
mathai/tool.py,sha256=ozcXTXLbKUnyPM9r9kz9M43YA2CBcWezcqLZfEs8rpc,6051
|
|
23
23
|
mathai/trig.py,sha256=fnBbfiopcQzFg4ya1BoO5M0X_aCBnse2bjnKh1juw4I,11223
|
|
24
24
|
mathai/univariate_inequality.py,sha256=LPFdWgC1y5zBwnsy1wwZxj-yP_SbqFDhCmTTzhuwoiY,16469
|
|
25
|
-
mathai-0.6.
|
|
26
|
-
mathai-0.6.
|
|
27
|
-
mathai-0.6.
|
|
28
|
-
mathai-0.6.
|
|
25
|
+
mathai-0.6.3.dist-info/METADATA,sha256=ecYnPYus3Nd-KLLG3JOi3YCocVvzqff3iZwgecdebiM,7103
|
|
26
|
+
mathai-0.6.3.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
27
|
+
mathai-0.6.3.dist-info/top_level.txt,sha256=ROP4l3OhGYw3ihkQGASr18xM9GsK4z3_6whV5AyXLwE,7
|
|
28
|
+
mathai-0.6.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|