RobinKa / tfga

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

Multivector Coefficients #5

Open RobinKa opened 4 years ago

RobinKa commented 4 years ago

Right now only tf's dtypes as coefficients are supported. Multivector coefficients could be convenient for example to use dual numbers for automatic differentiation (although this is already possible without them since we are using tensorflow of course).

Possible implementation

ga = tfga.GeometricAlgebra(metric=[0])

# Coefficient 5 + e_0 for all blades
# coefficients.shape: [2, 2]
# [5 + e_0, 5 + e_0]
coefficients = tf.tile(tf.expand_dims(ga.e0 + 5.0 * ga.e(""), axis=0), [ga.num_blades, 1])

# blades.shape: [2, 2]
# [1, e_0]
blades = ga.blade_mvs

# mv = [5 + e_0, 5 + e_0] elementwise geom. prod. [1, e_0] = [5 + e_0, 5 e_0]
# mv.shape: [2, 2]
mv = ga.geom_prod(coefficients, blades)