Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simple Robotics
pycppad
Commits
6eba55d6
Commit
6eba55d6
authored
Aug 23, 2021
by
Rohan Budhiraja
Browse files
[example/cppadcg_c_codegen] generate code
parent
6a56d3ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
example/cppadcg_c_codegen.py
View file @
6eba55d6
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
,
""
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment