Commit 6eba55d6 authored by Rohan Budhiraja's avatar Rohan Budhiraja
Browse files

[example/cppadcg_c_codegen] generate code

parent 6a56d3ba
from pycppad import AD, ADCG, CG, Independent, Value, ADCGFun
from pycppad import AD, ADCG, CG, Independent, Value, ADCGFun, CodeHandler, LanguageC, LangCDefaultVariableNameGenerator
import numpy as np
#/***************************************************************************
......@@ -24,3 +24,21 @@ y[0] = a / ADCG(CG(2.))
fun = ADCGFun(x, y); # the model tape
# /***************************************************************************
# * Generate the C source code
# **************************************************************************/
# /**
# * start the special steps for source code generation for a Jacobian
# */
handler = CodeHandler(50)
indVars = np.array([CG(0.)]*n)
handler.makeVariables(indVars)
jac = fun.Jacobian(indVars)
langC = LanguageC("double", 3)
nameGen = LangCDefaultVariableNameGenerator("y","x","v","array","sarray")
handler.generateCode(langC, jac, nameGen, "")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment