-
Notifications
You must be signed in to change notification settings - Fork 62
/
products_latex.py
100 lines (75 loc) · 2.55 KB
/
products_latex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from __future__ import print_function
from sympy import symbols
from galgebra.deprecated import MV
from galgebra.printer import xdvi,Format
def main():
#Format()
coords = (x,y,z) = symbols('x y z')
(ex,ey,ez,grad) = MV.setup('e*x|y|z','[1,1,1]',coords=coords)
s = MV('s','scalar')
v = MV('v','vector')
b = MV('b','bivector')
print(r'#3D Orthogonal Metric\newline')
print('#Multvectors:')
print('s =',s)
print('v =',v)
print('b =',b)
print('#Products:')
X = ((s,'s'),(v,'v'),(b,'b'))
for xi in X:
print('')
for yi in X:
print(xi[1]+'*'+yi[1]+' =',xi[0]*yi[0])
print(xi[1]+'^'+yi[1]+' =',xi[0]^yi[0])
if xi[1] != 's' and yi[1] != 's':
print(xi[1]+'|'+yi[1]+' =',xi[0]|yi[0])
print(xi[1]+'<'+yi[1]+' =',xi[0]<yi[0])
print(xi[1]+'>'+yi[1]+' =',xi[0]>yi[0])
fs = MV('s','scalar',fct=True)
fv = MV('v','vector',fct=True)
fb = MV('b','bivector',fct=True)
print('#Multivector Functions:')
print('s(X) =',fs)
print('v(X) =',fv)
print('b(X) =',fb)
print('#Products:')
fX = ((grad,'grad'),(fs,'s'),(fv,'v'),(fb,'b'))
for xi in fX:
print('')
for yi in fX:
if xi[1] == 'grad' and yi[1] == 'grad':
pass
else:
print(xi[1]+'*'+yi[1]+' =',xi[0]*yi[0])
print(xi[1]+'^'+yi[1]+' =',xi[0]^yi[0])
if xi[1] != 's' and yi[1] != 's':
print(xi[1]+'|'+yi[1]+' =',xi[0]|yi[0])
print(xi[1]+'<'+yi[1]+' =',xi[0]<yi[0])
print(xi[1]+'>'+yi[1]+' =',xi[0]>yi[0])
(ex,ey,grad) = MV.setup('e',coords=(x,y))
print(r'#General 2D Metric\newline')
print('#Multivector Functions:')
s = MV('s','scalar',fct=True)
v = MV('v','vector',fct=True)
b = MV('v','bivector',fct=True)
print('s(X) =',s)
print('v(X) =',v)
print('b(X) =',b)
X = ((grad,'grad'),(s,'s'),(v,'v'))
print('#Products:')
for xi in X:
print('')
for yi in X:
if xi[1] == 'grad' and yi[1] == 'grad':
pass
else:
print(xi[1]+'*'+yi[1]+' =',xi[0]*yi[0])
print(xi[1]+'^'+yi[1]+' =',xi[0]^yi[0])
if xi[1] != 's' and yi[1] != 's':
print(xi[1]+'|'+yi[1]+' =',xi[0]|yi[0])
print(xi[1]+'<'+yi[1]+' =',xi[0]<yi[0])
print(xi[1]+'>'+yi[1]+' =',xi[0]>yi[0])
#xdvi(paper='letter')
return
if __name__ == "__main__":
main()