RobinKa / tfga

Python package for Geometric / Clifford Algebra with TensorFlow
MIT License
48 stars 7 forks source link

Add exp and log #14

Open RobinKa opened 4 years ago

RobinKa commented 4 years ago

Here's how galgebra solved exp: https://github.com/pygae/galgebra/blob/b5eb070340434d030dd737a5656fbf709538b0b1/galgebra/mv.py#L1093-L1145

https://www.euclideanspace.com/maths/algebra/clifford/algebra/functions/exponent/index.htm

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4361175/

RobinKa commented 4 years ago

For 2D and 3D (including PGA) this seems to work (just took inspiration from the Quaternion logarithm), although I don't know under what conditions this works.

def rotor_log(x):
    norm_x = tf.sqrt(ga.geom_prod(x, ga.reversion(x))[..., :1])
    bv_indices = ga.get_kind_blade_indices("bivector")
    v = ga.keep_blades(x, bv_indices)
    norm_v = tf.sqrt(ga.geom_prod(v, ga.reversion(v))[..., :1])
    s = x[..., :1]

    scalar = tf.math.log(norm_x)
    rotor = ga.from_tensor_with_kind(tf.math.acos(s / norm_x) / norm_v, "scalar")

    return scalar + ga.geom_prod(v, rotor)
RobinKa commented 3 years ago

General bivector exp and log: https://arxiv.org/abs/2107.03771 (Graded Symmetry Groups: Plane and Simple)