[email protected] wrote:
Hi,I am trying to understand some apparently old code written by Ondrej trying to implement what I think are indicial tensor expressions. I list below the class definitions and then try to give an example. The example results in an error. I believe I recall that Ondrej says that these definitions don't work, but I am trying to understand them and want to try to create some appropriate classes which can contain indicial tensors. Here is what he has: type(g) <class 'certekten.Indexed'> from sympy import exp, Symbol, sin, Rational, Derivative, dsolve from sympy.core import Basic, Function from sympy.matrices import Matrix class Indexed(Basic): def __init__(self, A, idxlist): self._args = [A, idxlist] def __str__(self): r = str(self[0]) for idx in self[1]: r+=str(idx) return r class Idx(Symbol): def __init__(self, name, dim = 4, up = True): Symbol.__init__(self, name) #self._args.extend([dim,up]) self._name = name self._dim = dim self._up = up def __str__(self): if self._up: r = "^" else: r = "_" return r+self._name @property def up(self): return Idx(self._name, self._dim, True) @property def dn(self): return Idx(self._name, self._dim, False) def values(self): return range(self._dim) mu = Symbol("mu") nu = Symbol("nu") g =Indexed(Symbol("A"),[mu,nu]) g Among lots of output, the following stands out: 'Indexed' object is unsubscriptable What I want is to see g_{\mu,\nu} to give a latex version. So I don't understand what is wrong with the syntax/class def which he gave. I would appreciate some help in both learning more about how sympy works and on this particular task. Thanks a bunch. Comer And here is a try:
What are you trying to do with tensors in particular? -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
