wolftype / versor

Versor Geometric Algebra Library
wolftype.github.io/versor/devel/html/
291 stars 47 forks source link

Scalar product? #27

Closed bollu closed 2 years ago

bollu commented 5 years ago

Is there a reason as to why the scalar product is not implemented? It's defined as:

C \scalarprod D = \sum_{r, s} < <C>_r <D>_s>_0

See wikipedia

wolftype commented 5 years ago

Hi, I don't believe I follow this question -- perhaps another user of the library can help illuminate this for me? Versor implements the left inner product, is this not sufficient for your needs?

porky11 commented 5 years ago

There are a bunch of different inner products:

Look here for more information.

In my implementation of geometric algebra I have an implementation for the geometric product, which optionally takes a compile time function to select, which of the blades will be included. This way I implement the outer product and a bunch of inner products.

Since you also represent the blades using integers as bitvectors, you can just test a ^ b == 0. When this is true, the resulting blade (wich will always be a scalar value) will be used as the result.

I'm currently not sure if the left contraction will result in the same value for the scalar part, but the contraction will also calculate the non-scalar vector parts, which means unnecessary calculations.

bollu commented 5 years ago

@wolftype are you saying that I should express the scalar product in terms of the left inner product and grade projection? While I could, it is:

  1. Inefficient
  2. Probably non-obvious, as it was to me a week ago :)

As a newbie to geometric algebra, I actually dropped the library when I saw it does not have scalar products. Only after reading a little more did I realise how simple it is to implement.

wolftype commented 5 years ago

I see -- a very reasonable feature request. Thank you for taking the time to clarify -- it is straight forward to add this at the compiler level, so I will get to it!

wolftype commented 5 years ago

I've pushed a change to devel which supports scalar_product method on multivectors. I don't have a suitable operator overload for this yet. Please test it and let me know if it does the trick. I agree it will be much more efficient this way.

e.g:

Rotor a, b;
a.scalar_product(b);
bollu commented 5 years ago

Thanks, I'll give it a shot!