Prev Next a_double_assign_xam.cpp Headings

@(@\newcommand{\B}[1]{ {\bf #1} } \newcommand{\R}[1]{ {\rm #1} }@)@
C++: a_double Assignment Operators: Example and Test
# include <cstdio>
# include <string>
# include <cppad/swig/cppad_swig.hpp>

bool a_double_assign_xam(void) {
     using cppad_swig::a_double;
     using cppad_swig::vec_bool;
     using cppad_swig::vec_int;
     using cppad_swig::vec_double;
     using cppad_swig::vec_a_double;
     using cppad_swig::a_fun;
     using cppad_swig::sparse_rc;
     using cppad_swig::sparse_rcv;
     using cppad_swig::sparse_jac_work;
     using cppad_swig::sparse_hes_work;
     using std::string;
     //
     // initialize return variable
     bool ok = true;
     //------------------------------------------------------------------------
     a_double x = cppad_swig::a_double(2.0);
     //
     x = cppad_swig::a_double(3.0);
     ok = ok && x.value() == 3.0;
     //
     x += cppad_swig::a_double(2.0);
     ok = ok && x.value() == 5.0;
     //
     x -= cppad_swig::a_double(1.0);
     ok = ok && x.value() == 4.0;
     //
     x *= cppad_swig::a_double(3.0);
     ok = ok && x.value() == 12.0;
     //
     x /= cppad_swig::a_double(4.0);
     ok = ok && x.value() == 3.0;
     //
     return( ok );
}

Input File: build/lib/example/cplusplus/a_double_assign_xam.cpp