Prev Next double_poly.cpp

Double Speed: Evaluate a Polynomial

compute_poly
Routine that computes the second derivative of a polynomial using CppAD:
 
# include <cppad/cppad.hpp>
# include <cppad/speed/uniform_01.hpp>

bool compute_poly(
	size_t                     size     , 
	size_t                     repeat   , 
	CppAD::vector<double>     &a        ,  // coefficients of polynomial
	CppAD::vector<double>     &z        ,  // polynomial argument value
	CppAD::vector<double>     &p        )  // second derivative w.r.t z  
{
	// -----------------------------------------------------
	// setup

	// ------------------------------------------------------
	while(repeat--)
	{	// get the next argument value
		CppAD::uniform_01(1, z);

		// evaluate the polynomial at the new argument value
		p[0] = CppAD::Poly(0, a, z[0]);
	}
	return true;
}

Input File: speed/double/poly.cpp