Prev Next ad_input.cpp Headings

@(@\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 .
AD Output Operator: Example and Test

# include <cppad/cppad.hpp>

# include <sstream>  // std::istringstream
# include <string>   // std::string

bool ad_input(void)
{   bool ok = true;

    // create the input string stream is.
    std::string str ("123 456");
    std::istringstream is(str);

    // start and AD<double> recording
    CPPAD_TESTVECTOR( CppAD::AD<double> ) x(1), y(1);
    x[0] = 1.0;
    CppAD::Independent(x);
    CppAD::AD<double> z = x[0];
    ok &= Variable(z);

    // read first number into z and second into y[0]
    is >> z >> y[0];
    ok   &= Parameter(z);
    ok   &= (z == 123.);
    ok   &= Parameter(y[0]);
    ok   &= (y[0] == 456.);
    //
    // terminate recording starting by call to Independent
    CppAD::ADFun<double> f(x, y);

    return ok;
}

Input File: example/general/ad_input.cpp