python - What does the following error message mean for an inverse matrix? -
i include of code, because don't know error comes from. here is:
import numpy np import sympy sy sympy import matrix numpy import linalg mu = list(range(16)) # represent possible components (of metric) in 1 line array. t, x, y, z = sy.symbols("t x y z") # spacetime coordinates. lettercoords = [t, x, y, z] # coords in list easy access numcoords = [0, 1, 2, 3] # coords in numbers class metrictensor: # metric tensor class def __init__(self, g0, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15): # metric components self.g0 = g0 self.g1 = g1 self.g2 = g2 self.g3 = g3 self.g4 = g4 self.g5 = g5 self.g6 = g6 self.g7 = g7 self.g8 = g8 self.g9 = g9 self.g10 = g10 self.g11 = g11 self.g12 = g12 self.g13 = g13 self.g14 = g14 self.g15 = g15 def lmetric(self): lstmetric = [self.g0, self.g1, self.g2, self.g3, self.g4, self.g5, self.g6, self.g7, self.g8, self.g9, self.g10, self.g11, self.g12, self.g13, self.g14, self.g15] lmetric = list(lstmetric) return lmetric def mmetric(self, lmetric): mmetric = matrix([[lmetric[0], lmetric[1], lmetric[2], lmetric[3]], [lmetric[8], lmetric[9], lmetric[10], lmetric[11]], [lmetric[4], lmetric[5], lmetric[6], lmetric[7]], [lmetric[12], lmetric[13], lmetric[14], lmetric[15]]]) return mmetric def invmmetric(self, mmetric): invmmetric = np.linalg.inv(mmetric) return invmmetric def linvmetric(self, invmmetric): linvmetric = list(invmmetric) return linvmetric
this code entering components g0...g15. example:
g0 = input("enter g0:") ... g15 = input("enter g15:") mt = metrictensor(g0, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15) lmetric = mt.lmetric() mmetric = mt.mmetric(lmetric) invmmetric = mt.invmmetric(mmetric) linvmetric = mt.linvmetric(invmmetric)
i trying create program computes einstein tensor given metric tensor.i have got 'math' part covered, i'm having problems code.
when run program , enter 16 g(n) components, get:
traceback (most recent call last): file "/users/irene/pycharmprojects/efe/efe.py", line 70, in <module> invmmetric = mt.invmmetric(mmetric) file "/users/irene/pycharmprojects/efe/efe.py", line 42, in invmmetric invmmetric = np.linalg.inv(mmetric) file "/library/frameworks/python.framework/versions/3.5/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 526, in inv ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj) typeerror: no loop matching specified signature , casting found ufunc inv
it seems problem inversing matrix symbolically. if can help, in advance.
Comments
Post a Comment