pygae / galgebra

Symbolic Geometric Algebra/Calculus package for SymPy :crystal_ball:
https://galgebra.rtfd.io/
BSD 3-Clause "New" or "Revised" License
233 stars 62 forks source link

Matrix_to_dictionary and Dictionary_to_Matrix are not inverses #456

Closed eric-wieser closed 4 years ago

eric-wieser commented 4 years ago

This bug was introduced by a3b46512142a03ae8fee1c20a5b7327fd7aaeeee

>>> from sympy import Matrix
>>> from galgebra.lt import Matrix_to_dictionary, Dictionary_to_Matrix
>>> from galgebra.ga import Ga

>>> g2 = Ga('e_x e_y', g=[1,1])
>>> m = Matrix([
... [1, 2],
... [3, 4]])

>>> d = Matrix_to_dictionary(m, g2.basis)
>>> d
{e_x: e_x + 3*e_y, e_y: 2*e_x + 4*e_y}

# this is the transpose of `m`! So one of these functions is wrong
>>> Dictionary_to_Matrix(d, g2)
Matrix([
[1, 3],
[2, 4]]).T
eric-wieser commented 4 years ago

Nevermind, I misread the .T - this is fine