# include <cppad/cppad.hpp> // CppAD include filenamespace { // start empty namespaceusing CppAD::vector; // abbreviate CppAD::vector using vector// start definition of atomic derived class using atomic_three interfaceclass atomic_get_started : public CppAD::atomic_three<double> {
public:
// can use const char* name when calling this constructoratomic_get_started(const std::string& name) : // can have more arguments
CppAD::atomic_three<double>(name) // inform base class of name
{ }
private:
// Create the function f(x) which is eqaul to g(x) for this example.//// domain space vector
size_t n = 1;
double x0 = 0.5;
CPPAD_TESTVECTOR( AD<double> ) ax(n);
ax[0] = x0;
// declare independent variables and start tape recording
CppAD::Independent(ax);
// range space vector
size_t m = 1;
CPPAD_TESTVECTOR( AD<double> ) ay(m);
// call atomic function and store result in au[0]// u = 1 / xCPPAD_TESTVECTOR( AD<double> ) au(m);
afun(ax, au);
// now use AD division to invert to invert the operation
ay[0] = 1.0 / au[0]; // y = 1 / u = x// create f: x -> y and stop tape recording
CppAD::ADFun<double> f;
f.Dependent (ax, ay); // f(x) = x