pygae / galgebra

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

Add support for the right and left complement #215

Open eric-wieser opened 4 years ago

eric-wieser commented 4 years ago

The right complement of the basis blades can be found with

from galgebra.ga import GradedTuple

def right_complement_blades(ga):
    # relies on the lexicographic ordering of `ga.indices`
    blades = []
    for fwd_blades, rev_blades in zip(ga.blades, reversed(ga.blades)):
        blades_single_grade = []
        for fwd_blade, rev_blade in zip(fwd_blades, reversed(rev_blades)):
            sign = ga.wedge(fwd_blade, rev_blade) / ga.e.obj  # swap the order of the wedge for left complement
            blades_single_grade.append(sign * rev_blade)
        blades.append(tuple(blades_single_grade))
    return GradedTuple(blades)

With that in place, the complement of any multivector can be taken componentwise.

This would enable:

utensil commented 4 years ago

👍

eric-wieser commented 3 years ago

Just commenting to note that the above code still works in 0.5.0. The rest of the puzzle is something like

from galgebra import metric

ga = ...

lookup = dict(zip(ga.blades.flat, right_complement_blades(ga).flat))

def right_complement(e):
    return a.Ga.mv(sum([
        coef * lookup[base]
        for coef, base in metric.linear_expand_terms(e.obj)], S.Zero))