clifford icon indicating copy to clipboard operation
clifford copied to clipboard

Deviation between MultiVector and MVArray calculation

Open joha2 opened this issue 2 years ago • 0 comments

Hey guys!

First of all: Thank you very much for this library! It helped me a lot discovering GA :smile: I think I found a bug, because there is a discrepancy between the calculation with MultiVectors and with MVArrays. The chosen algebra is PGA in 3D with e0*e0 = 0.

My minimal working example code is the following:

import numpy as np
from clifford import Cl
import clifford

lpga3d, bpga3d = Cl(p=3, q=0, r=1, firstIdx=0)
Ipga = lpga3d.pseudoScalar

e0, e1, e2, e3 = lpga3d.basis_vectors.values()

print("Clifford version: ", clifford.__version__)
print("I = ", Ipga)
print("---------------")
a = e0 + 2*e1+3*e2+4*e3
aI = a*Ipga
scpaI = a|Ipga

print("a = ", a)
print("a*I = ", aI)
print("a|I = ", scpaI)
print("---------------")
b = np.ones(1, dtype=int)*(1*e0 + 2*e1 + 3*e2 + 4*e3)
bI = b*Ipga
scpbI = b|Ipga

print("b = ", b)
print("b*I = ", bI)
print("b|I = ", scpbI)
print("---------------")

The output is given by

Clifford version:  1.4.0
I =  (1^e0123)
---------------
a =  (1^e0) + (2^e1) + (3^e2) + (4^e3)
a*I =  -(4^e012) + (3^e013) - (2^e023)
a|I =  -(4^e012) + (3^e013) - (2^e023)
---------------
b =  [(1^e0) + (2^e1) + (3^e2) + (4^e3)]
b*I =  [-(4^e012) + (3^e013) - (2^e023)]
b|I =  [(4^e012) - (3^e013) + (2^e023)]
---------------

From an analytical point of view a^I = 0 since I has the highest grade. I think the values for a are correct, but the scalar product b|I is wrong.

Is this a bug or did I do something wrong?

Best wishes Johannes

joha2 avatar Jul 24 '23 09:07 joha2