Purpose
This section outlines the steps for adding more CppAD functionality
to cppad_py.
This is done by example showing how the cpp_fun_new_dynamic
was added.
This example case was chosen because it required both changing one
C++ function, cpp_independent
,
and adding a new C++ function, cpp_fun_new_dynamic
.
The independent function is not part of the
d_fun or a_fun class, but
calling it is the first step in creating these objects.
This is why its prototype is in the fun.hpp file.
new_dynamic
The include file include/cppad/py/fun.hpp
was edited to add the following member function to d_fun:
independent
The C++ file lib/cplusplus/fun.cpp
was edited to add the following syntax documentation:
a_both = cppad_py::independent(x, dynamic)
and the corresponding return value was documented; see
a_both
.
Example
The corresponding example file was added to the documentation,
below the cpp_independent
section, using the OMhelp commands:
$children%
lib/example/cplusplus/fun_dynamic_xam.cpp
%$$
In addition, a reference to this example was added under the
example
heading in the independent
documentation.
Example
The file lib/example/cplusplus/fun_dynamic_xam.cpp was added
with the following contents:
fun_dynamic_xam.cpp
.
In addition, in the file lib/example/cplusplus/check_all.cpp,
%
extern bool fun_optimize_xam(void);
%
was added to the external declarations and
%
ok &= Run( fun_optimize_xam, "fun_optimize_xam" );
%
was added to the main program.
Testing
You must do a git add for all of the new files before running
bin/check_all.sh.
After all the C++ changes above were implemented,
bin/check_all.sh was run and the changes were made
until the warnings and errors were fixed.
The command
grep 'fun_dynamic_xam' check_all.log
was used to make sure that the new C++ example / test was run.
Note that if a particular step in bin/check_all.sh is failing,
you can just re-run that step to see if a particular fix works.
Once the C++ tests were working, the changes where checked into using
git.
Input File: lib/cplusplus/more_cpp.omh