Prev Next Index-> contents reference index search external Up-> CppAD utility Poly poly.cpp CppAD-> Install Introduction AD ADFun preprocessor multi_thread utility ipopt_solve Example speed Appendix utility-> ErrorHandler NearEqual speed_test SpeedTest time_test test_boolofvoid NumericType CheckNumericType SimpleVector CheckSimpleVector nan pow_int Poly LuDetAndSolve RombergOne RombergMul Runge45 Rosen34 OdeErrControl OdeGear OdeGearControl CppAD_vector thread_alloc index_sort to_string set_union sparse_rc sparse_rcv Poly-> poly.cpp poly.hpp poly.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}} }$
Polynomial Evaluation: Example and Test
 # include <cppad/cppad.hpp> # include <cmath> bool Poly(void) { bool ok = true; // degree of the polynomial size_t deg = 3; // set the polynomial coefficients CPPAD_TESTVECTOR(double) a(deg + 1); size_t i; for(i = 0; i <= deg; i++) a[i] = 1.; // evaluate this polynomial size_t k = 0; double z = 2.; double p = CppAD::Poly(k, a, z); ok &= (p == 1. + z + z*z + z*z*z); // evaluate derivative k = 1; p = CppAD::Poly(k, a, z); ok &= (p == 1 + 2.*z + 3.*z*z); return ok; } 
Input File: example/general/poly.cpp