pygae / galgebra

Symbolic Geometric Algebra/Calculus package for SymPy :crystal_ball:
https://galgebra.rtfd.io/
BSD 3-Clause "New" or "Revised" License
233 stars 62 forks source link

grade involution (brombo/galgebra#40) #121

Open eric-wieser opened 4 years ago

eric-wieser commented 4 years ago

@Nelli-Khlyustova commented on Oct 4, 2018

Is grade involution available for general multivector?
For example, I have V = g3.mv('V', "mv") which is
V + V__xe1 + V__ye2 + V__ze3 + V__xye1^e2 + V__xze1^e3 + V__yze2^e3 + V__xyze1^e2^e3
But I wan to get this:
V - V__x
e1 - V__ye2 - V__ze3 + V__xye1^e2 + V__xze1^e3 + V__yze2^e3 - V__xyze1^e2^e3
How can I do this?

@mevangelista-alvarado commented on Jan 15 • edited

Hi @Nelli-Khlyustova maybe this function helps you, regards.

def involution(multivector):
    '''This method takes a multivector a make your involution, example involution(x*ey+y*ex^ey)=x*ey- 
       y*ex^ey'''
    grades = multivector.grades
    for grade in grades:
        if grade % 2 == 1:
            multivector = multivector + (-2)*multivector.get_grade(grade)
    return multivector 

From http://webcache.googleusercontent.com/search?q=cache:https://github.com/brombo/galgebra/issues/40

utensil commented 4 years ago

involution should be implemented. See also my implementation at https://github.com/pygae/GAlgebra.jl/blob/874dd59844fee98b918d070d6265353dcd3c1547/src/mv.jl#L243 .

GitHub
pygae/GAlgebra.jl
Julia interface to GAlgebra via PyCall. Contribute to pygae/GAlgebra.jl development by creating an account on GitHub.
eric-wieser commented 4 years ago

Should be able to do a (possibly) faster implementation along the lines of

return self.subs({
    b: b if len(i) % 2 == 0 else -b
    for i, b in zip(self.indexes.flat, self.blades.flat)
})
utensil commented 4 years ago

Yeah indeed.