python - Vector functions in SymPy -
i have such vector function. first 2 arguments n-dimensional vectors.
i want write function in sympy, problem begins, when need write sum.
this managed do:
w, lam, phi, theta, p, j = sp.symbols('w lam phi theta p j') w = (1 + sp.cos(phi)*sp.cos(theta))*p lam = (1+sp.cos(phi-theta))/(2*(1+sp.cos(phi)*sp.cos(theta))) j = -(1 - sp.sum(w * ((-lam*sp.log(lam,2)) - (1-lam)*sp.log(1-lam, 2)), 1, len(lam)))
last line generates
typeerror traceback (most recent call last) <ipython-input-19-d8b506a75004> in <module>() ----> 1 j = -(1 - sp.sum(w * ((-lam*sp.log(lam,2)) - (1-lam)*sp.log(1-lam, 2)), 1, len(lam))) typeerror: object of type 'mul' has no len()
but of course not real problem. real problem don't know how handle multi-dimensionality. how write such vector function in sympy?
Comments
Post a Comment