parameters: (self,name,expr,symbol_order=None)
docstring: - name: the symbolic module name of the function.
          - expr: the Sympy function
          - symbol_order: if you don't want to use lexicographical order for the unbound variables in expr,
            this will contain the desired argument order.
docstring_summary: - name: the symbolic module name of the function.
          - expr: the Sympy function
          - symbol_order: if you don't want to use lexicographical order for the unbound variables in expr,
            this will contain the desired argument order.
docstring_tokens: - name : the symbolic module name of the function . - expr : the Sympy function - symbol_order : if you don t want to use lexicographical order for the unbound variables in expr this will contain the desired argument order .
function: def __init__(self,name,expr,symbol_order=None):
          """
          - name: the symbolic module name of the function.
          - expr: the Sympy function
          - symbol_order: if you don't want to use lexicographical order for the unbound variables in expr,
            this will contain the desired argument order.
          """
          if symbol_order is None:
              symbol_order = sorted([s.name for s in expr.free_symbols])
          else:
              if not all(v.name in set(symbol_order) for v in expr.free_symbols):
                  raise ValueError("symbol_order does not contain some free variables: %s vs %s"%(str(symbol_order),str([s.name for s in expr.free_symbols])))
  
          func = (lambda *args: expr.evalf(subs=dict(zip(symbol_order,args))))
          Function.__init__(self,name,func,symbol_order)
          self.sympy_expr = expr
  
          self.deriv = [None]*len(self.argNames)
          self.jacobian = [None]*len(symbol_order)
          self.sympy_jacobian = [None]*len(symbol_order)
          self.sympy_jacobian_funcs = [None]*len(symbol_order)
          if isinstance(expr,Matrix):
              for i,arg in enumerate(symbol_order):
                  self.sympy_jacobian[i] = expr.diff(arg)
          else:
              for i,arg in enumerate(symbol_order):
                  self.sympy_jacobian[i] = sympy.diff(expr,arg)
          for i in xrange(len(symbol_order)):
              def cache_jacobian(*args):
                  if self.sympy_jacobian_funcs[i] is None:
                      #print "Creating jacobian function",name + "_jac_" + symbol_order[i]
                      self.sympy_jacobian_funcs[i] = SympyFunction(name + "_jac_" + symbol_order[i], self.sympy_jacobian[i],symbol_order)
                  return OperatorExpression(self.sympy_jacobian_funcs[i],args)
              self.jacobian[i] = cache_jacobian
function_tokens: def __init__ ( self , name , expr , symbol_order = None ) : if symbol_order is None : symbol_order = sorted ( [ s . name for s in expr . free_symbols ] ) else : if not all ( v . name in set ( symbol_order ) for v in expr . free_symbols ) : raise ValueError ( "symbol_order does not contain some free variables: %s vs %s" % ( str ( symbol_order ) , str ( [ s . name for s in expr . free_symbols ] ) ) ) func = ( lambda * args : expr . evalf ( subs = dict ( zip ( symbol_order , args ) ) ) ) Function . __init__ ( self , name , func , symbol_order ) self . sympy_expr = expr self . deriv = [ None ] * len ( self . argNames ) self . jacobian = [ None ] * len ( symbol_order ) self . sympy_jacobian = [ None ] * len ( symbol_order ) self . sympy_jacobian_funcs = [ None ] * len ( symbol_order ) if isinstance ( expr , Matrix ) : for i , arg in enumerate ( symbol_order ) : self . sympy_jacobian [ i ] = expr . diff ( arg ) else : for i , arg in enumerate ( symbol_order ) : self . sympy_jacobian [ i ] = sympy . diff ( expr , arg ) for i in xrange ( len ( symbol_order ) ) : def cache_jacobian ( * args ) : if self . sympy_jacobian_funcs [ i ] is None : #print "Creating jacobian function",name + "_jac_" + symbol_order[i] self . sympy_jacobian_funcs [ i ] = SympyFunction ( name + "_jac_" + symbol_order [ i ] , self . sympy_jacobian [ i ] , symbol_order ) return OperatorExpression ( self . sympy_jacobian_funcs [ i ] , args ) self . jacobian [ i ] = cache_jacobian