Mv.inv is very slow
See original GitHub issueHi,
Here’s another slow snippet (291s) :
from galgebra.ga import Ga
from sympy import Symbol
GA, e_0, e_1, e_2, e_3 = Ga.build("e*0|1|2|3", g='-1 0 0 0, 0 1 0 0, 0 0 1 0, 0 0 0 1')
e_0_inv = e_0.inv()
p = GA.mv((1, Symbol('p1'), Symbol('p2'), Symbol('p3')), 'vector')
q = GA.mv((0, Symbol('q1'), Symbol('q2'), Symbol('q3')), 'vector')
r = GA.mv((0, Symbol('r1'), Symbol('r2'), Symbol('r3')), 'vector')
A = q ^ r
X = (p ^ A) # A plane
d = (e_0_inv < (e_0 ^ X)) / (e_0_inv < X) # Support vector from plane
Very slow :
d_inv = d.inv()
d
doesn’t seem to complex :
(p1*q2**2*r3**2 - 2*p1*q2*q3*r2*r3 + p1*q3**2*r2**2 - p2*q1*q2*r3**2 + p2*q1*q3*r2*r3 + p2*q2*q3*r1*r3 - p2*q3**2*r1*r2 + p3*q1*q2*r2*r3 - p3*q1*q3*r2**2 - p3*q2**2*r1*r3 + p3*q2*q3*r1*r2)*e_1/(q1**2*r2**2 + q1**2*r3**2 - 2*q1*q2*r1*r2 - 2*q1*q3*r1*r3 + q2**2*r1**2 + q2**2*r3**2 - 2*q2*q3*r2*r3 + q3**2*r1**2 + q3**2*r2**2) + (-p1*q1*q2*r3**2 + p1*q1*q3*r2*r3 + p1*q2*q3*r1*r3 - p1*q3**2*r1*r2 + p2*q1**2*r3**2 - 2*p2*q1*q3*r1*r3 + p2*q3**2*r1**2 - p3*q1**2*r2*r3 + p3*q1*q2*r1*r3 + p3*q1*q3*r1*r2 - p3*q2*q3*r1**2)*e_2/(q1**2*r2**2 + q1**2*r3**2 - 2*q1*q2*r1*r2 - 2*q1*q3*r1*r3 + q2**2*r1**2 + q2**2*r3**2 - 2*q2*q3*r2*r3 + q3**2*r1**2 + q3**2*r2**2) + (p1*q1*q2*r2*r3 - p1*q1*q3*r2**2 - p1*q2**2*r1*r3 + p1*q2*q3*r1*r2 - p2*q1**2*r2*r3 + p2*q1*q2*r1*r3 + p2*q1*q3*r1*r2 - p2*q2*q3*r1**2 + p3*q1**2*r2**2 - 2*p3*q1*q2*r1*r2 + p3*q2**2*r1**2)*e_3/(q1**2*r2**2 + q1**2*r3**2 - 2*q1*q2*r1*r2 - 2*q1*q3*r1*r3 + q2**2*r1**2 + q2**2*r3**2 - 2*q2*q3*r2*r3 + q3**2*r1**2 + q3**2*r2**2)
d_inv
will be used later for computing the dual of X. I can provide more information if that matters.
Regards
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (8 by maintainers)
Top GitHub Comments
The following is not slow for me - ’ from galgebra.ga import Ga from sympy import Symbol from galgebra.printer import Format, xtex Format() GA, e_0, e_1, e_2, e_3 = Ga.build(“e*0|1|2|3”, g=‘-1 0 0 0, 0 1 0 0, 0 0 1 0, 0 0 0 1’)
e_0_inv = e_0.inv()
print(‘e_0^{-1} =’, e_0_inv)
p = GA.mv((1, Symbol(‘p1’), Symbol(‘p2’), Symbol(‘p3’)), ‘vector’) q = GA.mv((0, Symbol(‘q1’), Symbol(‘q2’), Symbol(‘q3’)), ‘vector’) r = GA.mv((0, Symbol(‘r1’), Symbol(‘r2’), Symbol(‘r3’)), ‘vector’) print(‘p =’,p) print(‘q =’,q) print(‘r =’,r)
A = q ^ r X = (p ^ A) # A plane
print(r’q\W r = A =‘,A) print(r’p\W A = X =’,X)
D = e_0_inv<X
print(r’e_0^{-1}\lfloor X = D =‘, e_0_inv<X) #Dinv = D.rev()/(DD.rev()).scalar() Dinv = D.inv() print(‘D^{-1} =’, Dinv.Fmt(3)) print(‘DD^{-1} =’, DDinv) N = e_0_inv < (e_0 ^ X) print(r’e_0^{-1}\lfloor (e_0\W X) = N’, N)
d = (e_0_inv < (e_0 ^ X)) * Dinv # Support vector from plane
print(r’(e_0^{-1}\lfloor (e_0\W X)) D^{-1} =',d.Fmt(3))
print(‘N/D =’,N/D) xtex()
’ Output is attached - newslow.pdf
We can close this issue. galgebra isn’t designed to make geometric proof but calculus. If I want to achieve some kind of proofs, I need to reduce the expression lenght myself by fixing things, ignoring norms if useless, using the right basis… 😃