pygae / clifford

Geometric Algebra for Python
http://clifford.rtfd.io
BSD 3-Clause "New" or "Revised" License
774 stars 72 forks source link

Add a concise notation for sandwich product #267

Open eric-wieser opened 4 years ago

eric-wieser commented 4 years ago

ganja.js has the R >>> x operator meaning R * x * ~R, which turns out to be very convenient.

It would be nice to have some concise spelling for this in clifford, and would help with #95.

Today we have only clifford.tools.g3c.apply_rotor, which is G3C-specific.

Some options here:

  1. Add a method to the rotor MultiVector, perhaps:
    • R.sandwich(x) (chained: R.sandwich(R2.sandwich(x)) == (R1 * R2).sandwich(x))
    • R.sw(x)
    • R.transform(x)
  2. Add a method to the transformed MultiVector, perhaps
    • x.transform_with(R) (chained: x.transform(R2).transform(R1) == x.transform(R1*R2))
    • x.apply_rotor(R)
  3. Claim one of the unused operators:
    • R @ x - implies something similar to rotation_matrix @ x, which is somewhat handy
    • R % x - % invokes the idea of a I sandwiched between two os. But nothing to do with division.
    • R // x - But nothing to do with division.
      • // and % are tied together with divmod, repurposing just one would be quite weird.
  4. Use an infix operator hack
    • R |apply_to| x

Other ideas welcome.

hugohadfield commented 4 years ago

Hmm, I like the @ notation in 3. (I think the % symbol might serve nicely for a scalar product as well)

arsenovic commented 3 years ago

+1 for the '@'