当前位置: 首页>>代码示例>>Python>>正文


Python ga.Ga类代码示例

本文整理汇总了Python中ga.Ga的典型用法代码示例。如果您正苦于以下问题:Python Ga类的具体用法?Python Ga怎么用?Python Ga使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Ga类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: properties_of_geometric_objects

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
开发者ID:Ignat99,项目名称:galgebra,代码行数:31,代码来源:latex_check.py

示例2: derivatives_in_rectangular_coordinates

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
开发者ID:Ignat99,项目名称:galgebra,代码行数:25,代码来源:latex_check.py

示例3: basic_multivector_operations_3D

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
开发者ID:Ignat99,项目名称:galgebra,代码行数:27,代码来源:latex_check.py

示例4: extracting_vectors_from_conformal_2_blade

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
开发者ID:Ignat99,项目名称:galgebra,代码行数:31,代码来源:latex_check.py

示例5: Fmt_test

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
开发者ID:derekelkins,项目名称:galgebra,代码行数:33,代码来源:latex_check.py

示例6: test_3_4

    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))
开发者ID:meuns,项目名称:galgebra,代码行数:13,代码来源:test_chapter3.py

示例7: rounding_numerical_components

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
开发者ID:Ignat99,项目名称:galgebra,代码行数:13,代码来源:latex_check.py

示例8: test_3_5_4

    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())
开发者ID:meuns,项目名称:galgebra,代码行数:16,代码来源:test_chapter3.py

示例9: derivatives_in_spherical_coordinates

def derivatives_in_spherical_coordinates():
    #Print_Function()
    coords = (r,th,phi) = symbols('r theta phi', real=True)
    (sp3d,er,eth,ephi) = Ga.build('e_r e_theta e_phi',g=[1,r**2,r**2*sin(th)**2],coords=coords)
    grad = sp3d.grad

    f = sp3d.mv('f','scalar',f=True)
    A = sp3d.mv('A','vector',f=True)
    B = sp3d.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 'grad\\times A = -I*(grad^A) =',-sp3d.i*(grad^A)
    print '%\\nabla^{2}f =',grad|(grad*f)
    print 'grad^B =',grad^B

    """
    print '( \\nabla\\W\\nabla )\\bm{e}_{r} =',((grad^grad)*er).trigsimp()
    print '( \\nabla\\W\\nabla )\\bm{e}_{\\theta} =',((grad^grad)*eth).trigsimp()
    print '( \\nabla\\W\\nabla )\\bm{e}_{\\phi} =',((grad^grad)*ephi).trigsimp()
    """

    return
开发者ID:Ignat99,项目名称:galgebra,代码行数:27,代码来源:curvi_linear_latex.py

示例10: main

def main():
    Print_Function()

    (a, b, c) = abc = symbols("a,b,c", real=True)
    (o3d, ea, eb, ec) = Ga.build("e_a e_b e_c", g=[1, 1, 1], coords=abc)
    grad = o3d.grad

    x = symbols("x", real=True)
    A = o3d.lt(
        [
            [x * a * c ** 2, x ** 2 * a * b * c, x ** 2 * a ** 3 * b ** 5],
            [x ** 3 * a ** 2 * b * c, x ** 4 * a * b ** 2 * c ** 5, 5 * x ** 4 * a * b ** 2 * c],
            [x ** 4 * a * b ** 2 * c ** 4, 4 * x ** 4 * a * b ** 2 * c ** 2, 4 * x ** 4 * a ** 5 * b ** 2 * c],
        ]
    )
    print "A =", A

    v = a * ea + b * eb + c * ec

    print "v =", v

    f = v | A(v)

    print r"%f = v\cdot \f{A}{v} =", f

    (grad * f).Fmt(3, r"%\nabla f")

    Av = A(v)

    print r"%\f{A}{v} =", Av

    (grad * Av).Fmt(3, r"%\nabla \f{A}{v}")

    return
开发者ID:Ignat99,项目名称:galgebra,代码行数:34,代码来源:diffeq_sys.py

示例11: main

def main():
    Eprint()

    X = (x,y,z) = symbols('x y z',real=True)
    (o3d,ex,ey,ez) = Ga.build('e_x e_y e_z',g=[1,1,1],coords=(x,y,z))

    A = x*(ey^ez) + y*(ez^ex) + z*(ex^ey)
    print 'A =', A
    print 'grad^A =',(o3d.grad^A).simplify()
    print

    f = o3d.mv(1/sqrt(x**2 + y**2 + z**2))
    print 'f =', f
    print 'grad*f =',(o3d.grad*f).simplify()
    print

    B = f*A
    print 'B =', B
    print

    Curl_B = o3d.grad^B

    print 'grad^B =', Curl_B.simplify()

    return
开发者ID:Ignat99,项目名称:galgebra,代码行数:25,代码来源:prob_not_solenoidal.py

示例12: Maxwells_Equations_in_Geom_Calculus

def Maxwells_Equations_in_Geom_Calculus():
    Print_Function()
    X = symbols("t x y z", real=True)
    (st4d, g0, g1, g2, g3) = Ga.build("gamma*t|x|y|z", g=[1, -1, -1, -1], coords=X)

    I = st4d.i

    B = st4d.mv("B", "vector", f=True)
    E = st4d.mv("E", "vector", f=True)
    B.set_coef(1, 0, 0)
    E.set_coef(1, 0, 0)
    B *= g0
    E *= g0
    J = st4d.mv("J", "vector", f=True)
    F = E + I * B

    print r"\text{Pseudo Scalar\;\;}I =", I
    print "\\text{Magnetic Field Bi-Vector\\;\\;} B = \\bm{B\\gamma_{t}} =", B
    print "\\text{Electric Field Bi-Vector\\;\\;} E = \\bm{E\\gamma_{t}} =", E
    print "\\text{Electromagnetic Field Bi-Vector\\;\\;} F = E+IB =", F
    print "%\\text{Four Current Density\\;\\;} J =", J
    gradF = st4d.grad * F
    print "#Geom Derivative of Electomagnetic Field Bi-Vector"
    gradF.Fmt(3, "grad*F")

    print "#Maxwell Equations"
    print "grad*F = J"
    print "#Div $E$ and Curl $H$ Equations"
    print (gradF.get_grade(1) - J).Fmt(3, "%\\grade{\\nabla F}_{1} -J = 0")
    print "#Curl $E$ and Div $B$ equations"
    print (gradF.get_grade(3)).Fmt(3, "%\\grade{\\nabla F}_{3} = 0")
    return
开发者ID:brombo,项目名称:galgebra,代码行数:32,代码来源:physics_check_latex.py

示例13: Maxwells_Equations_in_Geom_Calculus

def Maxwells_Equations_in_Geom_Calculus():
    Print_Function()
    X = symbols('t x y z',real=True)
    (st4d,g0,g1,g2,g3) = Ga.build('gamma*t|x|y|z',g=[1,-1,-1,-1],coords=X)

    I = st4d.i

    B = st4d.mv('B','vector',f=True)
    E = st4d.mv('E','vector',f=True)
    B.set_coef(1,0,0)
    E.set_coef(1,0,0)
    B *= g0
    E *= g0
    J = st4d.mv('J','vector',f=True)
    F = E+I*B

    print r'\text{Pseudo Scalar\;\;}I =',I
    print '\\text{Magnetic Field Bi-Vector\\;\\;} B = \\bm{B\\gamma_{t}} =',B
    print '\\text{Electric Field Bi-Vector\\;\\;} E = \\bm{E\\gamma_{t}} =',E
    print '\\text{Electromagnetic Field Bi-Vector\\;\\;} F = E+IB =',F
    print '%\\text{Four Current Density\\;\\;} J =',J
    gradF = st4d.grad*F
    print '#Geom Derivative of Electomagnetic Field Bi-Vector'
    gradF.Fmt(3,'grad*F')

    print '#Maxwell Equations'
    print 'grad*F = J'
    print '#Div $E$ and Curl $H$ Equations'
    (gradF.get_grade(1)-J).Fmt(3,'%\\grade{\\nabla F}_{1} -J = 0')
    print '#Curl $E$ and Div $B$ equations'
    (gradF.get_grade(3)).Fmt(3,'%\\grade{\\nabla F}_{3} = 0')
    return
开发者ID:Ignat99,项目名称:galgebra,代码行数:32,代码来源:physics_check_latex.py

示例14: test_blade_coefs

    def test_blade_coefs(self):
        """
        Various tests on several multivectors.
        """
        (_g3d, e_1, e_2, e_3) = Ga.build('e*1|2|3')

        m0 =  2 * e_1 + e_2 - e_3 + 3 * (e_1 ^ e_3) + (e_1 ^ e_3) + (e_2 ^ (3 * e_3))
        self.assertTrue(m0.blade_coefs([e_1]) == [2])
        self.assertTrue(m0.blade_coefs([e_2]) == [1])
        self.assertTrue(m0.blade_coefs([e_1, e_2]) == [2, 1])
        self.assertTrue(m0.blade_coefs([e_1 ^ e_3]) == [4])
        self.assertTrue(m0.blade_coefs([e_1 ^ e_3, e_2 ^ e_3]) == [4, 3])
        self.assertTrue(m0.blade_coefs([e_2 ^ e_3, e_1 ^ e_3]) == [3, 4])
        self.assertTrue(m0.blade_coefs([e_1, e_2 ^ e_3]) == [2, 3])

        a = Symbol('a')
        b = Symbol('b')
        m1 = a * e_1 + e_2 - e_3 + b * (e_1 ^ e_2)
        self.assertTrue(m1.blade_coefs([e_1]) == [a])
        self.assertTrue(m1.blade_coefs([e_2]) == [1])
        self.assertTrue(m1.blade_coefs([e_3]) == [-1])
        self.assertTrue(m1.blade_coefs([e_1 ^ e_2]) == [b])
        self.assertTrue(m1.blade_coefs([e_2 ^ e_3]) == [0])
        self.assertTrue(m1.blade_coefs([e_1 ^ e_3]) == [0])
        self.assertTrue(m1.blade_coefs([e_1 ^ e_2 ^ e_3]) == [0])

        # Invalid parameters
        self.assertRaises(ValueError, lambda: m1.blade_coefs([e_1 + e_2]))
        self.assertRaises(ValueError, lambda: m1.blade_coefs([e_2 ^ e_1]))
        self.assertRaises(ValueError, lambda: m1.blade_coefs([e_1, e_2 ^ e_1]))
        self.assertRaises(ValueError, lambda: m1.blade_coefs([a * e_1]))
        self.assertRaises(ValueError, lambda: m1.blade_coefs([3 * e_3]))
开发者ID:brombo,项目名称:galgebra,代码行数:32,代码来源:test_mv.py

示例15: Lorentz_Tranformation_in_Geog_Algebra

def Lorentz_Tranformation_in_Geog_Algebra():
    Print_Function()
    (alpha,beta,gamma) = symbols('alpha beta gamma')
    (x,t,xp,tp) = symbols("x t x' t'",real=True)
    (st2d,g0,g1) = Ga.build('gamma*t|x',g=[1,-1])

    from sympy import sinh,cosh

    R = cosh(alpha/2)+sinh(alpha/2)*(g0^g1)
    X = t*g0+x*g1
    Xp = tp*g0+xp*g1
    print 'R =',R

    print r"#%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} = t'\bm{\gamma'_{t}}+x'\bm{\gamma'_{x}} = R\lp t'\bm{\gamma_{t}}+x'\bm{\gamma_{x}}\rp R^{\dagger}"

    Xpp = R*Xp*R.rev()
    Xpp = Xpp.collect()
    Xpp = Xpp.trigsimp()
    print r"%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} =",Xpp
    Xpp = Xpp.subs({sinh(alpha):gamma*beta,cosh(alpha):gamma})

    print r'%\f{\sinh}{\alpha} = \gamma\beta'
    print r'%\f{\cosh}{\alpha} = \gamma'

    print r"%t\bm{\gamma_{t}}+x\bm{\gamma_{x}} =",Xpp.collect()
    return
开发者ID:Ignat99,项目名称:galgebra,代码行数:26,代码来源:physics_check_latex.py


注:本文中的ga.Ga类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。