pygae / clifford

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

Allow non-diagonal metrics #210

Open eric-wieser opened 4 years ago

eric-wieser commented 4 years ago

It would be neat if we could use a metric like:

array([[0, 0, 0, 0, 1],
       [0, 1, 0, 0, 0],
       [0, 0, 1, 0, 0],
       [0, 0, 0, 1, 0],
       [1, 0, 0, 0, 0]])

ie having no and ni be basis blades in our algebra.

I started prototyping this at https://gist.github.com/eric-wieser/56466e4bbfff9f05b3155e012c2afd7a, based on @abrombo's approach in #galgebra, but with optimizations for numerical values.

I do wonder whether there's a simpler approach that can be taken here based on the diagonalization discussed in "Geometric Algebra for Physicists" p.89.

Timing is looking promising, but perhaps something weird is going on in clifford:

# testing clifford
In [179]: %timeit conformalize(Cl(3, 0)[0])
2.37 s ± 862 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
# testing this table initialization
In [180]: %timeit Ga(m)
The slowest run took 5.18 times longer than the fastest. This could mean that an intermediate result is being cached.
73.8 ms ± 66.3 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
arsenovic commented 3 years ago

This came up again, also of interest for ellipsoidal geometry, and probably other things.

arsenovic commented 3 years ago

So by simply removing .astype(int) in https://github.com/pygae/clifford/blob/master/clifford/_layout.py#L330, seems to work to produce diagonal, but non-normal metric, ie elipsoidal geometry. here is a qualitative test

https://gist.github.com/arsenovic/45dc3df07e988aa1d68da78f0fd9f985

however, i am not sure why the .5 ratio of e1/e2 doesnt work, while a ratio of 2 does? (note you need the product to ==1 for rotations of given angles to make sense)