Prev Next Index-> contents reference index search external Up-> CppAD AD base_require base_example base_complex.hpp complex_poly.cpp base_require-> base_member base_cond_exp base_identical base_ordered base_std_math base_limits base_to_string base_hash base_example base_example-> base_alloc.hpp base_require.cpp base_adolc.hpp base_float.hpp base_double.hpp base_complex.hpp base_complex.hpp-> complex_poly.cpp complex_poly.cpp Headings-> Poly

$\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}} }$
Complex Polynomial: Example and Test

Poly
Select this link to view specifications for Poly :  // Complex examples should supppress conversion warnings # include <cppad/wno_conversion.hpp> # include <cppad/cppad.hpp> # include <complex> bool complex_poly(void) { bool ok = true; size_t deg = 4; using CppAD::AD; using CppAD::Poly; typedef std::complex<double> Complex; // polynomial coefficients CPPAD_TESTVECTOR( Complex ) a (deg + 1); // coefficients for p(z) CPPAD_TESTVECTOR(AD<Complex>) A (deg + 1); size_t i; for(i = 0; i <= deg; i++) A[i] = a[i] = Complex(double(i), double(i)); // independent variable vector CPPAD_TESTVECTOR(AD<Complex>) Z(1); Complex z = Complex(1., 2.); Z[0] = z; Independent(Z); // dependent variable vector and indices CPPAD_TESTVECTOR(AD<Complex>) P(1); // dependent variable values P[0] = Poly(0, A, Z[0]); // create f: Z -> P and vectors used for derivative calculations CppAD::ADFun<Complex> f(Z, P); CPPAD_TESTVECTOR(Complex) v( f.Domain() ); CPPAD_TESTVECTOR(Complex) w( f.Range() ); // check first derivative w.r.t z v[0] = 1.; w = f.Forward(1, v); Complex p = Poly(1, a, z); ok &= ( w[0] == p ); // second derivative w.r.t z is 2 times its second order Taylor coeff v[0] = 0.; w = f.Forward(2, v); p = Poly(2, a, z); ok &= ( 2. * w[0] == p ); return ok; } 
Input File: example/general/complex_poly.cpp