def clambdify(args, expr, **kwargs): """ SymPy expression -> compiled function Supports all standard C math functions, pi and e. >>> from sympy import sqrt >>> from sympy.abc import x, y >>> cf = clambdify((x,y), sqrt(x*y)) >>> cf(0.5, 4) 1.4142135623730951 """ # convert function to lambda string s = getlambdastr(args, expr.evalf(21)) # generate code code = """ # include <math.h> # define pi M_PI # define e M_E %s """ % genfcode(s, **kwargs) # compile code return _compile(code, len(args))
def clambdify(args, expr, **kwargs): """ SymPy expression -> compiled function Supports all standard C math functions, pi and e. >>> from sympy import symbols, sqrt >>> from sympy.abc import x, y >>> cf = clambdify((x,y), sqrt(x*y)) >>> cf(0.5, 4) 1.4142135623730951 """ # convert function to lambda string s = getlambdastr(args, expr.evalf(21)) # generate code code = """ # include <math.h> # define pi M_PI # define e M_E %s """ % genfcode(s, **kwargs) # compile code return _compile(code, len(args))