@(@\newcommand{\W}[1]{ \; #1 \; }
\newcommand{\R}[1]{ {\rm #1} }
\newcommand{\B}[1]{ {\bf #1} }
\newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} }
\newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} }
\newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} }
\newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@
This is cppad-20221105 documentation. Here is a link to its
current documentation
.
ADFun Function Name: Example and Test
# include <cppad/cppad.hpp>
bool function_name(void)
{ bool ok = true;
using CppAD::AD;
// create empty function
CppAD::ADFun<double> f;
// check its name
ok &= f.function_name_get() == "";
// set and check a new name
f.function_name_set("empty_function");
ok &= f.function_name_get() == "empty_function";
// store an operation sequence in f
size_t nx = 1;
size_t ny = 1;
CPPAD_TESTVECTOR( AD<double> ) ax(nx), ay(ny);
ax[0] = 1.0;
CppAD::Independent(ax);
ay[0] = sin(ax[0]);
f.Dependent(ax, ay);
// check fucntion name has not changed
ok &= f.function_name_get() == "empty_function";
// now set a better name for this function
f.function_name_set("sin");
ok &= f.function_name_get() == "sin";
return ok;
}