python - Converting expression involving tranpose of vector to numerical function with lambdify -
i have written script in python uses sympy compute couple of vector/matrix formulas. however, when try convert functions can evaluate sympy.lambdify, a
syntaxerror : eol while scanning string literal
here's code same error, can see mean.
import sympy x = sympy.matrixsymbol('x',3,1) f = sympy.lambdify(x, x.t*x)
so, syntax error has expression "x'.dot(x)" , conversion of ".t" '.
how can work around correctly define f above lambdify?
found work around, although not cleanest looking solution... works.
use implemented_function() method sympy define function. read full documentation here: http://docs.sympy.org/latest/modules/utilities/lambdify.html
here code:
import sympy import numpy np sympy.utilities.lambdify import implemented_function x = sympy.matrixsymbol('x',3,1) f = implemented_function(sympy.function('f'), lambda x: x.t*x) lam_f= sympy.lambdify(x, f(x))
hope solves problem :)
Comments
Post a Comment