本文整理汇总了Python中ga.Ga.mv方法的典型用法代码示例。如果您正苦于以下问题:Python Ga.mv方法的具体用法?Python Ga.mv怎么用?Python Ga.mv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ga.Ga
的用法示例。
在下文中一共展示了Ga.mv方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Fmt_test
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def Fmt_test():
Print_Function()
e3d = Ga('e1 e2 e3',g=[1,1,1])
v = e3d.mv('v','vector')
B = e3d.mv('B','bivector')
M = e3d.mv('M','mv')
Fmt(2)
print '#Global $Fmt = 2$'
print 'v =',v
print 'B =',B
print 'M =',M
print '#Using $.Fmt()$ Function'
print 'v.Fmt(3) =',v.Fmt(3)
print 'B.Fmt(3) =',B.Fmt(3)
print 'M.Fmt(2) =',M.Fmt(2)
print 'M.Fmt(1) =',M.Fmt(1)
print '#Global $Fmt = 1$'
Fmt(1)
print 'v =',v
print 'B =',B
print 'M =',M
return
示例2: basic_multivector_operations_3D
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def basic_multivector_operations_3D():
Print_Function()
g3d = Ga('e*x|y|z')
(ex,ey,ez) = g3d.mv()
A = g3d.mv('A','mv')
A.Fmt(1,'A')
A.Fmt(2,'A')
A.Fmt(3,'A')
A.even().Fmt(1,'%A_{+}')
A.odd().Fmt(1,'%A_{-}')
X = g3d.mv('X','vector')
Y = g3d.mv('Y','vector')
print 'g_{ij} = ',g3d.g
X.Fmt(1,'X')
Y.Fmt(1,'Y')
(X*Y).Fmt(2,'X*Y')
(X^Y).Fmt(2,'X^Y')
(X|Y).Fmt(2,'X|Y')
return
示例3: derivatives_in_rectangular_coordinates
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def derivatives_in_rectangular_coordinates():
Print_Function()
X = (x,y,z) = symbols('x y z')
o3d = Ga('e_x e_y e_z',g=[1,1,1],coords=X)
(ex,ey,ez) = o3d.mv()
grad = o3d.grad
f = o3d.mv('f','scalar',f=True)
A = o3d.mv('A','vector',f=True)
B = o3d.mv('B','bivector',f=True)
C = o3d.mv('C','mv')
print 'f =',f
print 'A =',A
print 'B =',B
print 'C =',C
print 'grad*f =',grad*f
print 'grad|A =',grad|A
print 'grad*A =',grad*A
print '-I*(grad^A) =',-o3d.i*(grad^A)
print 'grad*B =',grad*B
print 'grad^B =',grad^B
print 'grad|B =',grad|B
return
示例4: test_3_2_2
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def test_3_2_2(self):
"""
Computing the contraction explicitly.
"""
Ga.dual_mode("Iinv+")
R = Ga('e*1|2|3')
A_blades = [R.mv('A', i, 'grade') for i in range(R.n + 1)]
B_blades = [R.mv('B', i, 'grade') for i in range(R.n + 1)]
C_blades = [R.mv('C', i, 'grade') for i in range(R.n + 1)]
# scalar and blades of various grades
A = A_blades[0]
for B in B_blades:
self.assertEquals(A < B, A * B)
A = A_blades[0]
for B in B_blades:
self.assertEquals(B < A, 0 if B.pure_grade() > 0 else A * B)
# vectors
A = A_blades[1]
B = B_blades[1]
self.assertEquals(A < B, A | B)
# vector and the outer product of 2 blades of various grades (scalars, vectors, 2-vectors...)
A = A_blades[1]
for B, C in product(B_blades, C_blades):
self.assertEquals(A < (B ^ C), ((A < B) ^ C) + (-1)**B.pure_grade() * (B ^ (A < C)))
# vector and the outer product of 2 blades of various grades (scalars, vectors, 2-vectors...)
for A, B, C in product(A_blades, B_blades, C_blades):
self.assertEquals((A ^ B) < C, A < (B < C))
# distributive properties
for A, B, C in product(A_blades, B_blades, C_blades):
self.assertEquals((A + B) < C, (A < C) + (B < C))
for A, B, C in product(A_blades, B_blades, C_blades):
self.assertEquals(A < (B + C), (A < B) + (A < C))
alpha = Symbol("alpha")
for A, B in product(A_blades, B_blades):
self.assertEquals((alpha * A) < B, alpha * (A < B))
self.assertEquals((alpha * A) < B, A < (alpha * B))
a = R.mv('a', 1, 'grade')
for A_minus1, B in product(A_blades[:-1], B_blades):
A = A_minus1 ^ a
self.assertEquals(A < B, (A_minus1 ^ a) < B)
self.assertEquals(A < B, A_minus1 < (a < B))
示例5: properties_of_geometric_objects
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def properties_of_geometric_objects():
Print_Function()
global n, nbar
g = '# # # 0 0,'+ \
'# # # 0 0,'+ \
'# # # 0 0,'+ \
'0 0 0 0 2,'+ \
'0 0 0 2 0'
c3d = Ga('p1 p2 p3 n \\bar{n}',g=g)
(p1,p2,p3,n,nbar) = c3d.mv()
print 'g_{ij} =',c3d.g
P1 = F(p1)
P2 = F(p2)
P3 = F(p3)
print '\\text{Extracting direction of line from }L = P1\\W P2\\W n'
L = P1^P2^n
delta = (L|n)|nbar
print '(L|n)|\\bar{n} =',delta
print '\\text{Extracting plane of circle from }C = P1\\W P2\\W P3'
C = P1^P2^P3
delta = ((C^n)|n)|nbar
print '((C^n)|n)|\\bar{n}=',delta
print '(p2-p1)^(p3-p1)=',(p2-p1)^(p3-p1)
return
示例6: extracting_vectors_from_conformal_2_blade
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def extracting_vectors_from_conformal_2_blade():
Print_Function()
print r'B = P1\W P2'
g = '0 -1 #,'+ \
'-1 0 #,'+ \
'# # #'
c2b = Ga('P1 P2 a',g=g)
(P1,P2,a) = c2b.mv()
print 'g_{ij} =',c2b.g
B = P1^P2
Bsq = B*B
print '%B^{2} =',Bsq
ap = a-(a^B)*B
print "a' = a-(a^B)*B =",ap
Ap = ap+ap*B
Am = ap-ap*B
print "A+ = a'+a'*B =",Ap
print "A- = a'-a'*B =",Am
print '%(A+)^{2} =',Ap*Ap
print '%(A-)^{2} =',Am*Am
aB = a|B
print 'a|B =',aB
return
示例7: basic_multivector_operations_2D
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def basic_multivector_operations_2D():
Print_Function()
g2d = Ga('e*x|y')
(ex,ey) = g2d.mv()
print 'g_{ij} =',g2d.g
X = g2d.mv('X','vector')
A = g2d.mv('A','spinor')
X.Fmt(1,'X')
A.Fmt(1,'A')
(X|A).Fmt(2,'X|A')
(X<A).Fmt(2,'X<A')
(A>X).Fmt(2,'A>X')
return
示例8: derivatives_in_spherical_coordinates
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def derivatives_in_spherical_coordinates():
Print_Function()
X = (r,th,phi) = symbols('r theta phi')
s3d = Ga('e_r e_theta e_phi',g=[1,r**2,r**2*sin(th)**2],coords=X,norm=True)
(er,eth,ephi) = s3d.mv()
grad = s3d.grad
f = s3d.mv('f','scalar',f=True)
A = s3d.mv('A','vector',f=True)
B = s3d.mv('B','bivector',f=True)
print 'f =',f
print 'A =',A
print 'B =',B
print 'grad*f =',grad*f
print 'grad|A =',grad|A
print '-I*(grad^A) =',(-s3d.i*(grad^A)).simplify()
print 'grad^B =',grad^B
示例9: test_3_4
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def test_3_4(self):
"""
The other contraction.
"""
Ga.dual_mode("Iinv+")
R = Ga('e*1|2|3')
A_blades = [R.mv('A', i, 'grade') for i in range(R.n + 1)]
B_blades = [R.mv('B', i, 'grade') for i in range(R.n + 1)]
for A, B in product(A_blades, B_blades):
self.assertEquals(B > A, ((-1) ** (A.pure_grade() * (B.pure_grade() - 1))) * (A < B))
示例10: rounding_numerical_components
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def rounding_numerical_components():
Print_Function()
o3d = Ga('e_x e_y e_z',g=[1,1,1])
(ex,ey,ez) = o3d.mv()
X = 1.2*ex+2.34*ey+0.555*ez
Y = 0.333*ex+4*ey+5.3*ez
print 'X =',X
print 'Nga(X,2) =',Nga(X,2)
print 'X*Y =',X*Y
print 'Nga(X*Y,2) =',Nga(X*Y,2)
return
示例11: basic_multivector_operations_2D_orthogonal
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def basic_multivector_operations_2D_orthogonal():
Print_Function()
o2d = Ga('e*x|y',g=[1,1])
(ex,ey) = o2d.mv()
print 'g_{ii} =',o2d.g
X = o2d.mv('X','vector')
A = o2d.mv('A','spinor')
X.Fmt(1,'X')
A.Fmt(1,'A')
(X*A).Fmt(2,'X*A')
(X|A).Fmt(2,'X|A')
(X<A).Fmt(2,'X<A')
(X>A).Fmt(2,'X>A')
(A*X).Fmt(2,'A*X')
(A|X).Fmt(2,'A|X')
(A<X).Fmt(2,'A<X')
(A>X).Fmt(2,'A>X')
return
示例12: test_3_5_4
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def test_3_5_4(self):
"""
The duality relationships.
"""
Ga.dual_mode("Iinv+")
R = Ga('e*1|2|3')
A_blades = [R.mv('A', i, 'grade') for i in range(R.n + 1)]
B_blades = [R.mv('B', i, 'grade') for i in range(R.n + 1)]
for A, B in product(A_blades, B_blades):
self.assertEquals((A ^ B).dual(), A < B.dual())
for A, B in product(A_blades, B_blades):
self.assertEquals((A < B).dual(), A ^ B.dual())
示例13: check_generalized_BAC_CAB_formulas
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def check_generalized_BAC_CAB_formulas():
Print_Function()
g4d = Ga('a b c d')
(a,b,c,d) = g4d.mv()
print 'g_{ij} =',g4d.g
print '\\bm{a|(b*c)} =',a|(b*c)
print '\\bm{a|(b^c)} =',a|(b^c)
print '\\bm{a|(b^c^d)} =',a|(b^c^d)
print '\\bm{a|(b^c)+c|(a^b)+b|(c^a)} =',(a|(b^c))+(c|(a^b))+(b|(c^a))
print '\\bm{a*(b^c)-b*(a^c)+c*(a^b)} =',a*(b^c)-b*(a^c)+c*(a^b)
print '\\bm{a*(b^c^d)-b*(a^c^d)+c*(a^b^d)-d*(a^b^c)} =',a*(b^c^d)-b*(a^c^d)+c*(a^b^d)-d*(a^b^c)
print '\\bm{(a^b)|(c^d)} =',(a^b)|(c^d)
print '\\bm{((a^b)|c)|d} =',((a^b)|c)|d
print '\\bm{(a^b)\\times (c^d)} =',Com(a^b,c^d)
return
示例14: test_3_5_2
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def test_3_5_2(self):
"""
The inverse of a blade.
"""
Ga.dual_mode("Iinv+")
R = Ga('e*1|2|3')
A_blades = [R.mv('A', i, 'grade') for i in range(R.n + 1)]
for A in A_blades:
self.assertEquals(A.inv(), ((-1) ** (A.pure_grade() * (A.pure_grade() - 1) / 2)) * (A / A.norm2()))
for A in A_blades:
self.assertEquals(A < A.inv(), 1)
A = A_blades[1]
self.assertEquals(A.inv(), A / A.norm2())
示例15: conformal_representations_of_circles_lines_spheres_and_planes
# 需要导入模块: from ga import Ga [as 别名]
# 或者: from ga.Ga import mv [as 别名]
def conformal_representations_of_circles_lines_spheres_and_planes():
global n,nbar
Print_Function()
g = '1 0 0 0 0,0 1 0 0 0,0 0 1 0 0,0 0 0 0 2,0 0 0 2 0'
cnfml3d = Ga('e_1 e_2 e_3 n nbar',g=g)
(e1,e2,e3,n,nbar) = cnfml3d.mv()
print 'g_{ij} =\n',cnfml3d.g
e = n+nbar
#conformal representation of points
A = make_vector(e1,ga=cnfml3d) # point a = (1,0,0) A = F(a)
B = make_vector(e2,ga=cnfml3d) # point b = (0,1,0) B = F(b)
C = make_vector(-e1,ga=cnfml3d) # point c = (-1,0,0) C = F(c)
D = make_vector(e3,ga=cnfml3d) # point d = (0,0,1) D = F(d)
X = make_vector('x',3,ga=cnfml3d)
print 'F(a) =',A
print 'F(b) =',B
print 'F(c) =',C
print 'F(d) =',D
print 'F(x) =',X
print 'a = e1, b = e2, c = -e1, and d = e3'
print 'A = F(a) = 1/2*(a*a*n+2*a-nbar), etc.'
print 'Circle through a, b, and c'
print 'Circle: A^B^C^X = 0 =',(A^B^C^X)
print 'Line through a and b'
print 'Line : A^B^n^X = 0 =',(A^B^n^X)
print 'Sphere through a, b, c, and d'
print 'Sphere: A^B^C^D^X = 0 =',(((A^B)^C)^D)^X
print 'Plane through a, b, and d'
print 'Plane : A^B^n^D^X = 0 =',(A^B^n^D^X)
L = (A^B^e)^X
print L.Fmt(3,'Hyperbolic Circle: (A^B^e)^X = 0 =')
return