Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def generate_jac_lambda(self,do_cse=False):
"""
translates the symbolic Jacobain to a function using SymEngines `Lambdify` or `LambdifyCSE`. If the symbolic Jacobian has not been generated, it is generated by calling `generate_jac_sym`.
Parameters
----------
do_cse : boolean
Whether a common-subexpression detection, namely `LambdifyCSE`, should be used.
"""
self._prepare_lambdas()
jac_matrix = symengine.Matrix([
[ordered_subs(entry,self._lambda_subs) for entry in line]
for line in self.jac_sym
])
lambdify = symengine.LambdifyCSE if do_cse else symengine.Lambdify
core_jac = lambdify(self._lambda_args,jac_matrix)
self.jac = lambda t,Y: core_jac(np.hstack([t,Y,self.control_par_values]))
self.compile_attempt = False
def make_sym_vector(name, components):
return sym.Matrix(
[sym.Symbol("%s%d" % (name, i)) for i in range(components)])