class_docstr: Wrapper for Ufuncify
class_docstr_tok: ["Wrapper","for","Ufuncify"]
docstr: Write a C file with Python wrappers
  
  This file contains all the definitions of the routines in c code.
  
  Arguments
  ---------
  routines
      List of Routine instances
  f
      File-like object to write the file to
  prefix
      The filename prefix, used to name the imported module.
  funcname
      Name of the main function to be returned.
docstr_tok: ["Write","a","C","file","with","Python","wrappers","This","file","contains","all","the","definitions","of","the","routines","in","c","code",".","Arguments","--","--","--","--","-","routines","List","of","Routine","instances","f","File-like","object","to","write","the","file","to","prefix","The","filename","prefix",",","used","to","name","the","imported","module",".","funcname","Name","of","the","main","function","to","be","returned","."]
code: def dump_c(self, routines, f, prefix, funcname=None):
      """Write a C file with Python wrappers
  
      This file contains all the definitions of the routines in c code.
  
      Arguments
      ---------
      routines
          List of Routine instances
      f
          File-like object to write the file to
      prefix
          The filename prefix, used to name the imported module.
      funcname
          Name of the main function to be returned.
      """
      if funcname is None:
          if len(routines) == 1:
              funcname = routines[0].name
          else:
              msg = "funcname must be specified for multiple output routines"
              raise ValueError(msg)
      functions = []
      function_creation = []
      ufunc_init = []
      module = self.module_name
      include_file = '"{}.h"'.format(prefix)
      top = _ufunc_top.substitute(
          include_file=include_file, module=module
      )
  
      name = funcname
  
      # Partition the C function arguments into categories
      # Here we assume all routines accept the same arguments
      r_index = 0
      py_in, _ = self._partition_args(routines[0].arguments)
      n_in = len(py_in)
      n_out = len(routines)
  
      # Declare Args
      form = "char *{0}{1} = args[{2}];"
      arg_decs = [form.format("in", i, i) for i in range(n_in)]
      arg_decs.extend(
          [form.format("out", i, i + n_in) for i in range(n_out)]
      )
      declare_args = "\n    ".join(arg_decs)
  
      # Declare Steps
      form = "npy_intp {0}{1}_step = steps[{2}];"
      step_decs = [form.format("in", i, i) for i in range(n_in)]
      step_decs.extend(
          [form.format("out", i, i + n_in) for i in range(n_out)]
      )
      declare_steps = "\n    ".join(step_decs)
  
      # Call Args
      form = "*(double *)in{0}"
      call_args = ", ".join([form.format(a) for a in range(n_in)])
  
      # Step Increments
      form = "{0}{1} += {0}{1}_step;"
      step_incs = [form.format("in", i) for i in range(n_in)]
      step_incs.extend([form.format("out", i, i) for i in range(n_out)])
      step_increments = "\n        ".join(step_incs)
  
      # Types
      n_types = n_in + n_out
      types = "{" + ", ".join(["NPY_DOUBLE"] * n_types) + "};"
  
      # Docstring
      docstring = '"Created in SymPy with Ufuncify"'
  
      # Function Creation
      function_creation.append("PyObject *ufunc{};".format(r_index))
  
      # Ufunc initialization
      init_form = _ufunc_init_form.substitute(
          module=module,
          funcname=name,
          docstring=docstring,
          n_in=n_in,
          n_out=n_out,
          ind=r_index,
      )
      ufunc_init.append(init_form)
  
      outcalls = [
          _ufunc_outcalls.substitute(
              outnum=i, call_args=call_args, funcname=routines[i].name
          )
          for i in range(n_out)
      ]
  
      body = _ufunc_body.substitute(
          module=module,
          funcname=name,
          declare_args=declare_args,
          declare_steps=declare_steps,
          call_args=call_args,
          step_increments=step_increments,
          n_types=n_types,
          types=types,
          outcalls="\n        ".join(outcalls),
      )
      functions.append(body)
  
      body = "\n\n".join(functions)
      ufunc_init = "\n    ".join(ufunc_init)
      function_creation = "\n    ".join(function_creation)
      bottom = _ufunc_bottom.substitute(
          module=module,
          ufunc_init=ufunc_init,
          function_creation=function_creation,
      )
      text = [top, body, bottom]
      f.write("\n\n".join(text))
  
imports: import sys
  import os
  import shutil
  import tempfile
  from subprocess import STDOUT, CalledProcessError, check_output
  from string import Template
  from warnings import warn
  from sympy.core.cache import cacheit
  from sympy.core.function import Lambda
  from sympy.core.relational import Eq
  from sympy.core.symbol import Dummy, Symbol
  from sympy.tensor.indexed import Idx, IndexedBase
  from sympy.utilities.codegen import make_routine, get_code_generator, OutputArgument, InOutArgument, InputArgument, CodeGenArgumentListError, Result, ResultBase, C99CodeGen
  from sympy.utilities.iterables import iterable
  from sympy.utilities.lambdify import implemented_function
  from sympy.utilities.decorator import doctest_depends_on
label_desc: Use image node_id 8 for calling the UfuncifyCodeWrapper obj's underlying member method code with example usage: obj.dump_c(routines, f, prefix, funcname) without return types